WebAPI/SettingsAPI: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
m (syntax fixes)
Line 1: Line 1:
== Status ==
== Status ==


The proposed specification doesn't have a fully working implementation yet. Patches will appear in [bug|678695].
The proposed specification doesn't have a fully working implementation yet. Patches will appear in {{bug|678695}}.


== Proposed API ==
== Proposed API ==
Line 27: Line 27:
== Notes ==
== Notes ==


* SettingsRequest will be similar to SMSRequest described in [WebSMS specification|WebAPI/WebSMS].
* SettingsRequest will be similar to SMSRequest described in [[WebAPI/WebSMS|WebSMS specification]].
* As for BatteryAPI, SettingsManager object might be in window.navigator, window.navigator.devices or even could be created with ''new''.
* As for BatteryAPI, SettingsManager object might be in window.navigator, window.navigator.devices or even could be created with ''new''.
* The allowed types are restricted to the type we know we will be using in the first implementation. Those could be extended.
* The allowed types are restricted to the type we know we will be using in the first implementation. Those could be extended.
* If a setting is unknown, it should fail.
* If a setting is unknown, it should fail.
* But some platforms might not know some settings. Do we want to add a method that checks if the platform knows a specific setting?
* But some platforms might not know some settings. Do we want to add a method that checks if the platform knows a specific setting?

Revision as of 17:29, 4 October 2011

Status

The proposed specification doesn't have a fully working implementation yet. Patches will appear in bug 678695.

Proposed API

There is a readonly mozSettings attribute in window.navigator that would return an object implementing the SettingsManager interface.

 interface SettingsManager
 {
   // List of known settings.
   const DOMString FOOBAR = "foobar";
 
   // Setters. SettingsRequest.result is always null.
   SettingsRequest set(DOMString name, DOMString value);
   SettingsRequest set(DOMString name, long value);
   SettingsRequest set(DOMString name, long long value);
   SettingsRequest set(DOMString name, float value);
 
   // Getters. SettingsRequest.result will be of the requested type if the success event is sent.
   SettingsRequest getString(DOMString name);
   SettingsRequest getInt(DOMString name);
   SettingsRequest getLong(DOMString name);
   SettingsRequest getFloat(DOMString name);
 }

Notes

  • SettingsRequest will be similar to SMSRequest described in WebSMS specification.
  • As for BatteryAPI, SettingsManager object might be in window.navigator, window.navigator.devices or even could be created with new.
  • The allowed types are restricted to the type we know we will be using in the first implementation. Those could be extended.
  • If a setting is unknown, it should fail.
  • But some platforms might not know some settings. Do we want to add a method that checks if the platform knows a specific setting?