User:Mconnor/Past/Extensions2.0
This is totally a draft/work in progress/piece of junk.
We propose to add an Extensions object to the sandbox, which exposes the following:
Contents
UI
General Notes
These are objects, they have add/remove methods, take an argument that specifies a mount point (left as null, we do the right thing).
Possible example would be something like:
function doStuff() { alert("hello world!") } var menuitem = new Extensions.UI.Menuitem({label: "Click Me!";action: doStuff();id: "myButton"}); menuitem.add("context-menu");
Menu
Menuitem
ContextMenu
Toolbar
ToolbarButton
StatusbarItem
Shortcut
Actions
showAlert
Exposes nsIAlertsService.showAlertNotification
showAlert(aTitle, aMessage, aImage, aCallback)
showPrompt
showPrompt(title, message, button0Label, button1Label, button2Label, checkboxLabel, checked);
Description: wraps promptservice, used for all modal dialogs
- returns an array: [0/1/2, checked]
- if a label is not provided, the element is not used
- Extensions.Actions.showPrompt("Hi","Please click OK","OK");
showSidebar
Description: opens aURL in the sidebar (HTML, can be local)
showSidebar(aOpen, aURL)
Content
TBD
Prefs
Notes: this is just going to be a basic key pair array, that gets saved as JSON. No int/bool/etc nonsense, duck typing hurrah, screw prefapi and about:config, this at least is isolated and doesn't need prefbranches or about:config or anything.
savePrefs
savePrefs()
takes no args, just allows an explicit dump of prefs to disk. Prefs are automatically saved on exit.
loadPrefs
loadPrefs()
loads the saved prefs from disk, replacing the current in-memory prefs
resetPrefs
resetPrefs()
clears all prefs.
setPref
setPref(prefName, value)
Saves the value given for the given prefName
getPref
getPref(prefName, defaultValue)
Gets the stored value of prefName, returns defaultValue if no value is provided.
clearPref
clearPref(prefName)
Deletes the pref and stored value.
Storage
TBD
need to talk to sdwilsh about this. Looking to provide minimal functionality to store stuff beyond prefs, not sure we need more than one table in a DB. Seems elaborate for what is otherwise a simple API
Is there a big difference between mozStorage and the HTML 5 API for SQLITE access? my instinct is to just kill two birds w/ one stone and uplift Google Gears' content sqlite functionality into Firefox... Dunno though. - Atul