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
3 // found in the LICENSE file.
5 // Use the <code>chrome.settingsPrivate</code> API to get or set preferences
6 // from the settings UI.
7 namespace settingsPrivate
{
9 enum PrefType
{ BOOLEAN, NUMBER
, STRING, URL
, LIST
};
11 // Source of a restricted pref, either by policy or other source.
20 // Enforcement type of a restricted pref.
21 enum PolicyEnforcement
{ ENFORCED
, RECOMMENDED
};
23 dictionary PrefObject
{
24 // The key for the pref.
27 // The type of the pref (e.g., boolean, string, etc.).
30 // The current value of the pref.
33 // The policy source of the pref; an undefined value means there is no
35 PolicySource? policySource
;
37 // The policy enforcement of the pref; must be specified if policySource is
39 PolicyEnforcement? policyEnforcement
;
41 // The recommended value if policyEnforcement == RECOMMENDED.
42 any? recommendedValue
;
44 // The extension ID if policySource == EXTENSION.
45 DOMString? extensionId
;
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.
52 callback OnPrefSetCallback
= void (boolean success
);
53 callback GetAllPrefsCallback
= void (PrefObject
[] prefs
);
54 callback GetPrefCallback
= void (PrefObject pref
);
57 // Sets a settings value.
58 // |name|: The name of the pref.
59 // |value|: The new value of the pref.
60 // |pageId|: The user metrics identifier or null.
61 // |callback|: The callback for whether the pref was set or not.
62 static
void setPref
(DOMString name
, any value
,
63 DOMString pageId
, OnPrefSetCallback
callback);
65 // Gets an array of all the prefs.
66 static
void getAllPrefs
(GetAllPrefsCallback
callback);
68 // Gets the value of a specific pref.
69 static
void getPref
(DOMString name
, GetPrefCallback
callback);
73 // Fired when a set of prefs has changed.
75 // |prefs| The prefs that changed.
76 static
void onPrefsChanged
(PrefObject
[] prefs
);