| 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 // Policy source of a pref. |
| 12 enum PolicySource { DEVICE, USER }; | 12 enum PolicySource { DEVICE, USER }; |
| 13 | 13 |
| 14 // Policy enforcement of a pref. | 14 // Policy enforcement of a pref. |
| 15 enum PolicyEnforcement { ENFORCED, RECOMMENDED }; | 15 enum PolicyEnforcement { ENFORCED, RECOMMENDED }; |
| 16 | 16 |
| 17 dictionary PrefObject { | 17 dictionary PrefData { |
| 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 }; | 34 }; |
| 35 | 35 |
| 36 callback OnPrefSetCallback = void (boolean success); | 36 callback OnPrefSetCallback = void (boolean success); |
| 37 callback GetAllPrefsCallback = void (PrefObject[] prefs); | 37 callback GetAllPrefsCallback = void (PrefData[] prefs); |
| 38 callback GetPrefCallback = void (PrefObject pref); | 38 callback GetPrefCallback = void (PrefData pref); |
| 39 | 39 |
| 40 interface Functions { | 40 interface Functions { |
| 41 // Sets a settings value. | 41 // Sets a settings value. |
| 42 // |name|: The name of the pref. | 42 // |name|: The name of the pref. |
| 43 // |value|: The new value of the pref. | 43 // |value|: The new value of the pref. |
| 44 // |pageId|: The user metrics identifier or null. | 44 // |pageId|: The user metrics identifier or null. |
| 45 // |callback|: The callback for whether the pref was set or not. | 45 // |callback|: The callback for whether the pref was set or not. |
| 46 static void setPref(DOMString name, any value, | 46 static void setPref(DOMString name, any value, |
| 47 DOMString pageId, OnPrefSetCallback callback); | 47 DOMString pageId, OnPrefSetCallback callback); |
| 48 | 48 |
| 49 // Gets an array of all the prefs. | 49 // Gets an array of all the prefs. |
| 50 static void getAllPrefs(GetAllPrefsCallback callback); | 50 static void getAllPrefs(GetAllPrefsCallback callback); |
| 51 | 51 |
| 52 // Gets the value of a specific pref. | 52 // Gets the value of a specific pref. |
| 53 static void getPref(DOMString name, GetPrefCallback callback); | 53 static void getPref(DOMString name, GetPrefCallback callback); |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 interface Events { | 56 interface Events { |
| 57 // Fired when a set of prefs has changed. | 57 // Fired when a set of prefs has changed. |
| 58 // | 58 // |
| 59 // |prefs| The prefs that changed. | 59 // |prefs| The prefs that changed. |
| 60 static void onPrefsChanged(PrefObject[] prefs); | 60 static void onPrefsChanged(PrefData[] prefs); |
| 61 }; | 61 }; |
| 62 }; | 62 }; |
| OLD | NEW |