Chromium Code Reviews| 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. |
|
michaelpg
2015/08/27 23:40:01
Source of a restricted pref (e.g., policy).
stevenjb
2015/08/28 23:18:08
Hmm... I like it as-is.
| |
| 12 enum PolicySource { DEVICE, USER }; | 12 enum PolicySource { DEVICE, USER, OWNER, PRIMARY_USER, EXTENSION }; |
| 13 | 13 |
| 14 // Policy enforcement of a pref. | 14 // Enforcement type of a restricted pref. |
| 15 enum PolicyEnforcement { ENFORCED, RECOMMENDED }; | 15 enum PolicyEnforcement { ENFORCED, RECOMMENDED }; |
| 16 | 16 |
| 17 dictionary PrefObject { | 17 dictionary PrefObject { |
| 18 // The key for the pref. | 18 // The key for the pref. |
| 19 DOMString key; | 19 DOMString key; |
| 20 | 20 |
| 21 // The type of the pref (e.g., boolean, string, etc.). | 21 // The type of the pref (e.g., boolean, string, etc.). |
| 22 PrefType type; | 22 PrefType type; |
| 23 | 23 |
| 24 // The current value of the pref. | 24 // The current value of the pref. |
| 25 any value; | 25 any value; |
| 26 | 26 |
| 27 // The policy source of the pref; an undefined value means there is no | 27 // The policy source of the pref; an undefined value means there is no |
| 28 // policy. | 28 // policy. |
| 29 PolicySource? policySource; | 29 PolicySource? policySource; |
| 30 | 30 |
| 31 // The policy enforcement of the pref; must be specified if policySource is | 31 // The policy enforcement of the pref; must be specified if policySource is |
| 32 // also present. | 32 // also present. |
| 33 PolicyEnforcement? policyEnforcement; | 33 PolicyEnforcement? policyEnforcement; |
| 34 | |
| 35 // The recommended value if policyEnforcement == RECOMMENDED. | |
| 36 any? recommendedValue; | |
| 34 }; | 37 }; |
| 35 | 38 |
| 36 callback OnPrefSetCallback = void (boolean success); | 39 callback OnPrefSetCallback = void (boolean success); |
| 37 callback GetAllPrefsCallback = void (PrefObject[] prefs); | 40 callback GetAllPrefsCallback = void (PrefObject[] prefs); |
| 38 callback GetPrefCallback = void (PrefObject pref); | 41 callback GetPrefCallback = void (PrefObject pref); |
| 39 | 42 |
| 40 interface Functions { | 43 interface Functions { |
| 41 // Sets a settings value. | 44 // Sets a settings value. |
| 42 // |name|: The name of the pref. | 45 // |name|: The name of the pref. |
| 43 // |value|: The new value of the pref. | 46 // |value|: The new value of the pref. |
| 44 // |pageId|: The user metrics identifier or null. | 47 // |pageId|: The user metrics identifier or null. |
| 45 // |callback|: The callback for whether the pref was set or not. | 48 // |callback|: The callback for whether the pref was set or not. |
| 46 static void setPref(DOMString name, any value, | 49 static void setPref(DOMString name, any value, |
| 47 DOMString pageId, OnPrefSetCallback callback); | 50 DOMString pageId, OnPrefSetCallback callback); |
| 48 | 51 |
| 49 // Gets an array of all the prefs. | 52 // Gets an array of all the prefs. |
| 50 static void getAllPrefs(GetAllPrefsCallback callback); | 53 static void getAllPrefs(GetAllPrefsCallback callback); |
| 51 | 54 |
| 52 // Gets the value of a specific pref. | 55 // Gets the value of a specific pref. |
| 53 static void getPref(DOMString name, GetPrefCallback callback); | 56 static void getPref(DOMString name, GetPrefCallback callback); |
| 54 }; | 57 }; |
| 55 | 58 |
| 56 interface Events { | 59 interface Events { |
| 57 // Fired when a set of prefs has changed. | 60 // Fired when a set of prefs has changed. |
| 58 // | 61 // |
| 59 // |prefs| The prefs that changed. | 62 // |prefs| The prefs that changed. |
| 60 static void onPrefsChanged(PrefObject[] prefs); | 63 static void onPrefsChanged(PrefObject[] prefs); |
| 61 }; | 64 }; |
| 62 }; | 65 }; |
| OLD | NEW |