summaryrefslogtreecommitdiff
path: root/dom/webidl/SettingsManager.webidl
blob: ad707a2588a54874d3e9f812a528223102faf30e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/.
 */

[JSImplementation="@mozilla.org/settingsLock;1",
 Pref="dom.mozSettings.enabled"]
interface SettingsLock : EventTarget {
  // Whether this lock is invalid
  readonly attribute boolean closed;

  // Contains a JSON object with name/value pairs to be set.
  DOMRequest set(object settings);

  // Result contains the value of the setting.
  DOMRequest get(DOMString name);

  DOMRequest clear();
  attribute EventHandler onsettingstransactionsuccess;
  attribute EventHandler onsettingstransactionfailure;
};

dictionary SettingChange {
  DOMString settingName;
  DOMString settingValue;
};

callback SettingChangeCallback = void (SettingChange setting);

[JSImplementation="@mozilla.org/settingsManager;1",
 NavigatorProperty="mozSettings",
 Pref="dom.mozSettings.enabled",
 ChromeOnly]
interface SettingsManager : EventTarget {
  SettingsLock createLock();

  void addObserver(DOMString name, SettingChangeCallback callback);
  void removeObserver(DOMString name, SettingChangeCallback callback);

  attribute EventHandler onsettingchange;
};