1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Control and monitor the screen locker.
6 [permissions=screenlockPrivate, nodoc]
7 namespace screenlockPrivate {
8 // Supported authentication types shown on the user pod.
9 // |offlinePassword|: The standard password field, which authenticates using
10 // the user's regular password. The $(ref:onAuthAttempted)()
11 // event will not be fired for this authentication type.
12 // |numericPin|: An input field for a 4 digit numeric pin code.
13 // |userClick|: Makes the user pod clickable when it is focused, and
14 // clicking on it attempts the authentication. If |value| is
15 // specified with $(ref:setAuthType)(), the text is displayed
16 // in the password field.
17 enum AuthType {offlinePassword, numericPin, userClick};
19 // Extension resource for a icon representation for a scale factor.
20 dictionary IconRepresentation {
21 // The scale factor the representation is for.
23 // The image resource URL.
27 callback BooleanCallback = void(boolean locked);
28 callback AuthTypeCallback = void(AuthType authType);
31 // Returns true if the screen is currently locked, false otherwise.
32 static void getLocked(BooleanCallback callback);
34 // Set <code>locked=true</code> to lock the screen,
35 // <code>locked=false</code> to unlock it.
36 static void setLocked(boolean locked);
38 // Show a message to the user on the unlock UI if the screen is locked.
39 static void showMessage(DOMString message);
41 // Show a custom icon beside the input field on the user pod.
42 // |icon|: Extension resoucres for the icon's multi-scale representations.
43 // Currently, only scales 1 and 2 are supported. The list must have a
44 // resource for at least scale 1.
45 static void showCustomIcon(IconRepresentation[] icon);
47 // Hides the custom icon added by $(ref:showCustomIcon)().
48 static void hideCustomIcon();
50 // Returns the current auth type used for the user pod.
51 static void getAuthType(AuthTypeCallback callback);
53 // Set the type of the authentication for the user pod. The input field
54 // area of the user pod below the user's portrait will be changed.
55 // |authType|: The type of authentication to use.
56 // |initialValue|: The initial value to populate the input field.
57 static void setAuthType(AuthType authType, optional DOMString initialValue);
59 // Accepts or rejects the current auth attempt.
60 static void acceptAuthAttempt(boolean accept);
64 // Fires whenever the screen is locked or unlocked.
65 static void onChanged(boolean locked);
67 // Fires when the user attempts to authenticate with the user's input.
68 // There will be at most one auth attempt active at any time.
69 // Call $(ref:acceptAuthAttempt)() to accept or reject this attempt.
70 // Note: Some authentication types will not have an input.
71 static void onAuthAttempted(AuthType type, DOMString input);