blob: 815cf61082a5f8798700d55394e38d3dd94ddffc [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.
namespace settingsPrivate {
// Type of a pref.
enum PrefType { BOOLEAN, NUMBER, STRING, URL, LIST, DICTIONARY };
// Source of a restricted pref, either by policy or other source.
enum PolicySource {
DEVICE_POLICY,
USER_POLICY,
OWNER,
PRIMARY_USER,
EXTENSION
};
// Enforcement type of a restricted pref.
enum PolicyEnforcement { 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.
PolicySource? policySource;
// The owner name if policySource == OWNER.
// The primary user name if policySource == PRIMARY_USER.
// The extension name if policySource == EXTENSION.
DOMString? policySourceName;
// The policy enforcement of the pref; must be specified if policySource is
// also present.
PolicyEnforcement? policyEnforcement;
// The recommended value if policyEnforcement == RECOMMENDED.
any? recommendedValue;
// The extension ID if policySource == EXTENSION.
DOMString? extensionId;
// True if the pref is not controlled by a policy or user, but it can not be
// modified (pref->IsUserModifiable() is false). Defaults to false.
boolean? readOnly;
};
callback OnPrefSetCallback = void (boolean success);
callback GetAllPrefsCallback = void (PrefObject[] prefs);
callback GetPrefCallback = void (PrefObject pref);
callback GetDefaultZoomPercentCallback = void (long percent);
callback SetDefaultZoomPercentCallback = void (boolean success);
interface Functions {
// Sets a settings value.
// |name|: The name of the pref.
// |value|: The new value of the pref.
// |pageId|: The user metrics identifier or null.
// |callback|: The callback for whether the pref was set or not.
static void setPref(DOMString name, any value,
DOMString pageId, 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 page zoom factor as an integer percentage.
static void getDefaultZoomPercent(GetDefaultZoomPercentCallback callback);
// Sets the page zoom factor from a zoom percentage.
static void setDefaultZoomPercent(long percent,
optional SetDefaultZoomPercentCallback callback);
};
interface Events {
// Fired when a set of prefs has changed.
//
// |prefs| The prefs that changed.
static void onPrefsChanged(PrefObject[] prefs);
};
};