blob: 1e2996c39da5c0502a7394db2ff7579e3a191650 [file] [log] [blame]
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.settingsPrivate</code> API to get or set preferences
// from the settings UI. Access is restricted to a whitelisted set of user
// facing preferences.
namespace settingsPrivate {
enum ControlledBy {
enum Enforcement { ENFORCED, RECOMMENDED };
dictionary PrefObject {
// The key for the pref.
DOMString key;
// The type of the pref (e.g., boolean, string, etc.).
PrefType type;
// The current value of the pref.
any value;
// The policy source of the pref; an undefined value means there is no
// policy.
ControlledBy? controlledBy;
// The owner name if controlledBy == OWNER.
// The primary user name if controlledBy == PRIMARY_USER.
// The extension name if controlledBy == EXTENSION.
DOMString? controlledByName;
// The policy enforcement of the pref; must be specified if controlledBy is
// also present.
Enforcement? enforcement;
// The recommended value if enforcement == RECOMMENDED.
any? recommendedValue;
// The extension ID if controlledBy == EXTENSION.
DOMString? extensionId;
// Whether the controlling extension can be disabled if controlledBy ==
boolean? extensionCanBeDisabled;
callback OnPrefSetCallback = void (boolean success);
callback GetAllPrefsCallback = void (PrefObject[] prefs);
callback GetPrefCallback = void (PrefObject pref);
callback GetDefaultZoomCallback = void (double zoom);
callback SetDefaultZoomCallback = void (boolean success);
interface Functions {
// Sets a pref value.
// |name|: The name of the pref.
// |value|: The new value of the pref.
// |pageId|: An optional user metrics identifier.
// |callback|: The callback for whether the pref was set or not.
static void setPref(DOMString name, any value,
optional DOMString pageId, optional OnPrefSetCallback callback);
// Gets an array of all the prefs.
static void getAllPrefs(GetAllPrefsCallback callback);
// Gets the value of a specific pref.
static void getPref(DOMString name, GetPrefCallback callback);
// Gets the default page zoom factor. Possible values are currently between
// 0.25 and 5. For a full list, see zoom::kPresetZoomFactors.
static void getDefaultZoom(GetDefaultZoomCallback callback);
// Sets the page zoom factor. Must be less than 0.001 different than a value
// in zoom::kPresetZoomFactors.
static void setDefaultZoom(
double zoom, optional SetDefaultZoomCallback callback);
interface Events {
// Fired when a set of prefs has changed.
// |prefs| The prefs that changed.
static void onPrefsChanged(PrefObject[] prefs);