OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Use the <code>chrome.settingsPrivate</code> API to get or set preferences | 5 // Use the <code>chrome.settingsPrivate</code> API to get or set preferences |
6 // from the settings UI. | 6 // from the settings UI. |
7 namespace settingsPrivate { | 7 namespace settingsPrivate { |
8 // Type of a pref. | 8 // Type of a pref. |
9 enum PrefType { BOOLEAN, NUMBER, STRING, URL, LIST }; | 9 enum PrefType { BOOLEAN, NUMBER, STRING, URL, LIST }; |
10 | 10 |
11 // Policy source of a pref. | 11 // Source of a restricted pref, either by policy or other source. |
12 enum PolicySource { DEVICE, USER }; | 12 enum PolicySource { |
| 13 DEVICE_POLICY, |
| 14 USER_POLICY, |
| 15 OWNER, |
| 16 PRIMARY_USER, |
| 17 EXTENSION |
| 18 }; |
13 | 19 |
14 // Policy enforcement of a pref. | 20 // Enforcement type of a restricted pref. |
15 enum PolicyEnforcement { ENFORCED, RECOMMENDED }; | 21 enum PolicyEnforcement { ENFORCED, RECOMMENDED }; |
16 | 22 |
17 dictionary PrefObject { | 23 dictionary PrefObject { |
18 // The key for the pref. | 24 // The key for the pref. |
19 DOMString key; | 25 DOMString key; |
20 | 26 |
21 // The type of the pref (e.g., boolean, string, etc.). | 27 // The type of the pref (e.g., boolean, string, etc.). |
22 PrefType type; | 28 PrefType type; |
23 | 29 |
24 // The current value of the pref. | 30 // The current value of the pref. |
25 any value; | 31 any value; |
26 | 32 |
27 // The policy source of the pref; an undefined value means there is no | 33 // The policy source of the pref; an undefined value means there is no |
28 // policy. | 34 // policy. |
29 PolicySource? policySource; | 35 PolicySource? policySource; |
30 | 36 |
31 // The policy enforcement of the pref; must be specified if policySource is | 37 // The policy enforcement of the pref; must be specified if policySource is |
32 // also present. | 38 // also present. |
33 PolicyEnforcement? policyEnforcement; | 39 PolicyEnforcement? policyEnforcement; |
| 40 |
| 41 // The recommended value if policyEnforcement == RECOMMENDED. |
| 42 any? recommendedValue; |
| 43 |
| 44 // The extension ID if policySource == EXTENSION. |
| 45 DOMString? extensionId; |
| 46 |
| 47 // True if the pref is not controlled by a policy or user, but it can not be |
| 48 // modified (pref->IsUserModifiable() is false). Defaults to false. |
| 49 boolean? readOnly; |
34 }; | 50 }; |
35 | 51 |
36 callback OnPrefSetCallback = void (boolean success); | 52 callback OnPrefSetCallback = void (boolean success); |
37 callback GetAllPrefsCallback = void (PrefObject[] prefs); | 53 callback GetAllPrefsCallback = void (PrefObject[] prefs); |
38 callback GetPrefCallback = void (PrefObject pref); | 54 callback GetPrefCallback = void (PrefObject pref); |
39 | 55 |
40 interface Functions { | 56 interface Functions { |
41 // Sets a settings value. | 57 // Sets a settings value. |
42 // |name|: The name of the pref. | 58 // |name|: The name of the pref. |
43 // |value|: The new value of the pref. | 59 // |value|: The new value of the pref. |
44 // |pageId|: The user metrics identifier or null. | 60 // |pageId|: The user metrics identifier or null. |
45 // |callback|: The callback for whether the pref was set or not. | 61 // |callback|: The callback for whether the pref was set or not. |
46 static void setPref(DOMString name, any value, | 62 static void setPref(DOMString name, any value, |
47 DOMString pageId, OnPrefSetCallback callback); | 63 DOMString pageId, OnPrefSetCallback callback); |
48 | 64 |
49 // Gets an array of all the prefs. | 65 // Gets an array of all the prefs. |
50 static void getAllPrefs(GetAllPrefsCallback callback); | 66 static void getAllPrefs(GetAllPrefsCallback callback); |
51 | 67 |
52 // Gets the value of a specific pref. | 68 // Gets the value of a specific pref. |
53 static void getPref(DOMString name, GetPrefCallback callback); | 69 static void getPref(DOMString name, GetPrefCallback callback); |
54 }; | 70 }; |
55 | 71 |
56 interface Events { | 72 interface Events { |
57 // Fired when a set of prefs has changed. | 73 // Fired when a set of prefs has changed. |
58 // | 74 // |
59 // |prefs| The prefs that changed. | 75 // |prefs| The prefs that changed. |
60 static void onPrefsChanged(PrefObject[] prefs); | 76 static void onPrefsChanged(PrefObject[] prefs); |
61 }; | 77 }; |
62 }; | 78 }; |
OLD | NEW |