Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / common / extensions / api / settings_private.idl
blob161e1bc4f507b054b935bce3c560f339712a2e0b
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 {
8 // Type of a pref.
9 enum PrefType { BOOLEAN, NUMBER, STRING, URL, LIST };
11 // Source of a restricted pref, either by policy or other source.
12 enum PolicySource {
13 DEVICE_POLICY,
14 USER_POLICY,
15 OWNER,
16 PRIMARY_USER,
17 EXTENSION
20 // Enforcement type of a restricted pref.
21 enum PolicyEnforcement { ENFORCED, RECOMMENDED };
23 dictionary PrefObject {
24 // The key for the pref.
25 DOMString key;
27 // The type of the pref (e.g., boolean, string, etc.).
28 PrefType type;
30 // The current value of the pref.
31 any value;
33 // The policy source of the pref; an undefined value means there is no
34 // policy.
35 PolicySource? policySource;
37 // The policy enforcement of the pref; must be specified if policySource is
38 // also present.
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.
49 boolean? readOnly;
52 callback OnPrefSetCallback = void (boolean success);
53 callback GetAllPrefsCallback = void (PrefObject[] prefs);
54 callback GetPrefCallback = void (PrefObject pref);
56 interface Functions {
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);
72 interface Events {
73 // Fired when a set of prefs has changed.
75 // |prefs| The prefs that changed.
76 static void onPrefsChanged(PrefObject[] prefs);