WebAPI/SettingsAPI: Difference between revisions
< WebAPI
Jump to navigation
Jump to search
m (syntax fixes) |
(improving the proposal) |
||
Line 12: | Line 12: | ||
const DOMString FOOBAR = "foobar"; | const DOMString FOOBAR = "foobar"; | ||
// | // SettingsRequest.result contains the new value of the setting. | ||
SettingsRequest set(DOMString name, DOMString value); | SettingsRequest set(DOMString name, DOMString value); | ||
// | // SettingsRequest.result contains the value of the setting. | ||
SettingsRequest | SettingsRequest get(DOMString name); | ||
} | |||
/* Similar to SmsRequest. */ | |||
interface SettingsRequest | |||
{ | |||
readonly attribute DOMString readyState; // "processing" or "done" | |||
readonly attribute DOMError? error; | |||
attribute EventListener onsuccess; | |||
attribute EventListener onerror; | |||
attribute readonly any? result; | |||
}; | |||
[Constructor(DOMString type, optional SettingsEventInit settingsEventInitDict)] | |||
interface SettingsEvent : Event | |||
{ | |||
readonly attribute DOMString settingName; | |||
readonly attribute DOMString settingValue; | |||
}; | |||
dictionary SettingsEventInit : EventInit { | |||
DOMString settingName; | |||
DOMString settingValue; | |||
} | } | ||
Line 28: | Line 44: | ||
* SettingsRequest will be similar to SMSRequest described in [[WebAPI/WebSMS|WebSMS specification]]. | * SettingsRequest will be similar to SMSRequest described in [[WebAPI/WebSMS|WebSMS specification]]. | ||
* If a setting is unknown by the platform, 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 14:02, 22 November 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"; // SettingsRequest.result contains the new value of the setting. SettingsRequest set(DOMString name, DOMString value); // SettingsRequest.result contains the value of the setting. SettingsRequest get(DOMString name); }
/* Similar to SmsRequest. */ interface SettingsRequest { readonly attribute DOMString readyState; // "processing" or "done" readonly attribute DOMError? error; attribute EventListener onsuccess; attribute EventListener onerror; attribute readonly any? result; };
[Constructor(DOMString type, optional SettingsEventInit settingsEventInitDict)] interface SettingsEvent : Event { readonly attribute DOMString settingName; readonly attribute DOMString settingValue; }; dictionary SettingsEventInit : EventInit { DOMString settingName; DOMString settingValue; }
Notes
- SettingsRequest will be similar to SMSRequest described in WebSMS specification.
- If a setting is unknown by the platform, 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?