Upstream version 8.37.180.0
[platform/framework/web/crosswalk.git] / src / chrome / common / extensions / api / screenlock_private.idl
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.
4
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};
18
19   // Extension resource for a icon representation for a scale factor.
20   dictionary IconRepresentation {
21     // The scale factor the representation is for.
22     double scaleFactor;
23     // The image resource URL.
24     DOMString url;
25   };
26
27   callback BooleanCallback = void(boolean locked);
28   callback AuthTypeCallback = void(AuthType authType);
29
30   interface Functions {
31     // Returns true if the screen is currently locked, false otherwise.
32     static void getLocked(BooleanCallback callback);
33
34     // Set <code>locked=true</code> to lock the screen,
35     // <code>locked=false</code> to unlock it.
36     static void setLocked(boolean locked);
37
38     // Show a message to the user on the unlock UI if the screen is locked.
39     static void showMessage(DOMString message);
40
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);
46
47     // Hides the custom icon added by $(ref:showCustomIcon)().
48     static void hideCustomIcon();
49
50     // Returns the current auth type used for the user pod.
51     static void getAuthType(AuthTypeCallback callback);
52
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);
58
59     // Accepts or rejects the current auth attempt.
60     static void acceptAuthAttempt(boolean accept);
61   };
62
63   interface Events {
64     // Fires whenever the screen is locked or unlocked.
65     static void onChanged(boolean locked);
66
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);
72   };
73 };