46 this._console = Components.classes[
"@mozilla.org/consoleservice;1"]
47 .getService(
Ci.nsIConsoleService);
53 log :
function cs_log(aMsg) {
54 this._console.logStringMessage(aMsg);
57 open :
function cs_open() {
58 var wMediator = Components.classes[
"@mozilla.org/appshell/window-mediator;1"]
59 .getService(
Ci.nsIWindowMediator);
60 var console = wMediator.getMostRecentWindow(
"global:console");
62 var wWatch = Components.classes[
"@mozilla.org/embedcomp/window-watcher;1"]
63 .getService(
Ci.nsIWindowWatcher);
64 wWatch.openWindow(
null,
"chrome://global/content/console.xul",
"_blank",
65 "chrome,dialog=no,all",
null);
96 preventDefault :
function ei_pd() {
107 this._listeners = [];
113 addListener :
function evts_al(aEvent, aListener) {
114 if (this._listeners.some(hasFilter))
117 this._listeners.push({
127 removeListener :
function evts_rl(aEvent, aListener) {
128 this._listeners = this._listeners.filter(hasFilter);
131 return (
element.event != aEvent) || (
element.listener != aListener);
135 dispatch :
function evts_dispatch(aEvent, aEventItem) {
136 eventItem =
new EventItem(aEvent, aEventItem);
138 this._listeners.forEach(
function(
key){
139 if (
key.event == aEvent) {
140 key.listener.handleEvent ?
141 key.listener.handleEvent(eventItem) :
142 key.listener(eventItem);
146 return !eventItem._cancel;
159 this._root = aBranch;
160 this.
_prefs = Components.classes[
"@mozilla.org/preferences-service;1"]
161 .getService(
Ci.nsIPrefService);
166 this.
_prefs.QueryInterface(
Ci.nsIPrefBranch);
167 this.
_prefs.QueryInterface(
Ci.nsIPrefBranch2);
170 this.
_prefs.addObserver(
"",
this,
true);
171 this._events =
new Events();
174 gShutdown.push(
function() {
self._shutdown(); });
181 _shutdown:
function prefs_shutdown() {
182 this.
_prefs.removeObserver(this._root,
this);
189 observe:
function prefs_observe(aSubject, aTopic,
aData) {
190 if (aTopic ==
"nsPref:changed")
191 this._events.dispatch(
"change",
aData);
199 return this.find({});
212 find :
function prefs_find(aOptions) {
214 var items = this.
_prefs.getChildList(
"", []);
216 for (var
i = 0;
i < items.length;
i++) {
223 has :
function prefs_has(
aName) {
224 return (this.
_prefs.getPrefType(
aName) !=
Ci.nsIPrefBranch.PREF_INVALID);
227 get :
function prefs_get(
aName) {
235 case Ci.nsIPrefBranch2.PREF_STRING:
238 case Ci.nsIPrefBranch2.PREF_BOOL:
241 case Ci.nsIPrefBranch2.PREF_INT:
254 var
str = Components.classes[
"@mozilla.org/supports-string;1"]
255 .createInstance(
Ci.nsISupportsString);
257 this.
_prefs.setComplexValue(
aName,
Ci.nsISupportsString, str);
266 throw(
"Unknown preference value specified.");
270 reset :
function prefs_reset() {
271 this.
_prefs.resetBranch(
"");
274 QueryInterface : XPCOMUtils.generateQI([
Ci.extIPreferenceBranch,
Ci.nsISupportsWeakReference])
282 this._branch = aBranch;
283 this._events =
new Events();
287 this.branch.events.addListener(
"change",
function(aEvent){
288 if (aEvent.data ==
self.name)
289 self.events.dispatch(aEvent.type, aEvent.data);
302 var type = this.branch._prefs.getPrefType(this._name);
305 case Ci.nsIPrefBranch2.PREF_STRING:
308 case Ci.nsIPrefBranch2.PREF_BOOL:
311 case Ci.nsIPrefBranch2.PREF_INT:
320 return this.branch.getValue(this._name,
null);
324 return this.branch.setValue(this._name,
aValue);
328 return this.branch._prefs.prefIsLocked(this.
name);
332 this.branch._prefs[
aValue ?
"lockPref" :
"unlockPref" ](this.
name);
336 return this.branch._prefs.prefHasUserValue(this.
name);
347 reset :
function pref_reset() {
348 this.branch._prefs.clearUserPref(this.
name);
359 this._events =
new Events();
369 has :
function ss_has(
aName) {
370 return this._storage.hasOwnProperty(
aName);
375 this._events.dispatch(
"change",
aName);
378 get :
function ss_get(
aName, aDefaultValue) {
379 return this.has(
aName) ? this._storage[
aName] : aDefaultValue;
390 this._firstRun =
false;
393 this._events =
new Events();
395 var installPref =
"install-event-fired";
396 if (!this.
_prefs.has(installPref)) {
397 this.
_prefs.setValue(installPref,
true);
398 this._firstRun =
true;
401 this._enabled =
false;
403 const PREFIX_NS_EM =
"http://www.mozilla.org/2004/em-rdf#";
404 var rdf =
Cc[
"@mozilla.org/rdf/rdf-service;1"].getService(
Ci.nsIRDFService);
407 var extmgr =
Cc[
"@mozilla.org/extensions/manager;1"].getService(
Ci.nsIExtensionManager);
408 var ds = extmgr.datasource;
409 var
target = ds.GetTarget(itemResource, rdf.GetResource(
PREFIX_NS_EM +
"isDisabled"),
true);
410 if (target && target instanceof
Ci.nsIRDFLiteral)
411 this._enabled = (target.Value !=
"true");
414 var
os = Components.classes[
"@mozilla.org/observer-service;1"]
415 .getService(
Ci.nsIObserverService);
416 os.addObserver(
this,
"em-action-requested",
false);
419 gShutdown.push(
function(){
self._shutdown(); });
426 _shutdown:
function ext_shutdown() {
427 var
os = Components.classes[
"@mozilla.org/observer-service;1"]
428 .getService(
Ci.nsIObserverService);
429 os.removeObserver(
this,
"em-action-requested");
432 this._storage =
null;
439 if ((aSubject instanceof
Ci.nsIUpdateItem) && (aSubject.id ==
this._item.id))
441 if (
aData ==
"item-uninstalled")
442 this._events.dispatch(
"uninstall", this._item.id);
443 else if (
aData ==
"item-disabled")
444 this._events.dispatch(
"disable", this._item.id);
445 else if (
aData ==
"item-enabled")
446 this._events.dispatch(
"enable", this._item.id);
447 else if (
aData ==
"item-cancel-action")
448 this._events.dispatch(
"cancel", this._item.id);
449 else if (
aData ==
"item-upgraded")
450 this._events.dispatch(
"upgrade", this._item.id);
455 return this._item.id;
459 return this._item.name;
463 return this._enabled;
467 return this._item.version;
471 return this._firstRun;
475 return this._storage;
493 this._extmgr = Components.classes[
"@mozilla.org/extensions/manager;1"]
494 .getService(
Ci.nsIExtensionManager);
499 gShutdown.push(
function() {
self._shutdown(); });
505 _shutdown :
function exts_shutdown() {
513 _get :
function exts_get(aId) {
514 if (this._cache.hasOwnProperty(aId))
515 return this._cache[aId];
517 var newExt =
new Extension(this._extmgr.getItemForID(aId));
518 this._cache[aId] = newExt;
523 return this.find({});
532 find :
function exts_find(aOptions) {
534 var items = this._extmgr.getItemList(
Ci.nsIUpdateItem.TYPE_EXTENSION, {});
536 for (var
i = 0;
i < items.length;
i++) {
537 retVal.push(this.
_get(items[
i].
id));
543 has :
function exts_has(aId) {
544 return this._extmgr.getItemForID(aId) !=
null;
547 get :
function exts_get(aId) {
548 return this.has(aId) ? this.
_get(aId) :
null;
562 initToolkitHelpers:
function extApp_initToolkitHelpers() {
563 this._console =
null;
564 this._storage =
null;
566 this._extensions =
null;
569 this._info = Components.classes[
"@mozilla.org/xre/app-info;1"]
570 .getService(
Ci.nsIXULAppInfo);
572 var os = Components.classes[
"@mozilla.org/observer-service;1"]
573 .getService(
Ci.nsIObserverService);
575 os.addObserver(
this,
"final-ui-startup",
false);
576 os.addObserver(
this,
"quit-application-requested",
false);
577 os.addObserver(
this,
"xpcom-shutdown",
false);
583 { category:
"app-startup",
service:
true },
586 { category:
"JavaScript global privileged property" }
590 flags :
Ci.nsIClassInfo.SINGLETON,
595 aCount.value = interfaces.length;
605 return this._info.ID;
609 return this._info.name;
613 return this._info.version;
617 observe:
function app_observe(aSubject, aTopic,
aData) {
618 if (aTopic ==
"app-startup") {
619 this.
events.dispatch(
"load",
"application");
621 else if (aTopic ==
"final-ui-startup") {
622 this.
events.dispatch(
"ready",
"application");
624 else if (aTopic ==
"quit-application-requested") {
626 if (this.
events.dispatch(
"quit",
"application") ==
false)
627 aSubject.data =
true;
629 else if (aTopic ==
"xpcom-shutdown") {
631 this.
events.dispatch(
"unload",
"application");
639 var os = Components.classes[
"@mozilla.org/observer-service;1"]
640 .getService(
Ci.nsIObserverService);
642 os.removeObserver(
this,
"final-ui-startup");
643 os.removeObserver(
this,
"quit-application-requested");
644 os.removeObserver(
this,
"xpcom-shutdown");
647 this._console =
null;
649 this._storage =
null;
651 this._extensions =
null;
656 if (this._console ==
null)
659 return this._console;
663 if (this._storage ==
null)
666 return this._storage;
677 if (this._extensions ==
null)
680 return this._extensions;
684 if (this._events ==
null)
685 this._events =
new Events();
691 _quitWithFlags:
function app__quitWithFlags(aFlags) {
692 let os = Components.classes[
"@mozilla.org/observer-service;1"]
693 .getService(Components.interfaces.nsIObserverService);
694 let cancelQuit = Components.classes[
"@mozilla.org/supports-PRBool;1"]
695 .createInstance(Components.interfaces.nsISupportsPRBool);
696 os.notifyObservers(cancelQuit,
"quit-application-requested",
null);
700 let appStartup = Components.classes[
'@mozilla.org/toolkit/app-startup;1']
701 .getService(Components.interfaces.nsIAppStartup);
702 appStartup.quit(aFlags);
706 quit:
function app_quit() {
707 return this._quitWithFlags(Components.interfaces.nsIAppStartup.eAttemptQuit);
710 restart:
function app_restart() {
711 return this._quitWithFlags(Components.interfaces.nsIAppStartup.eAttemptQuit |
712 Components.interfaces.nsIAppStartup.eRestart);
715 QueryInterface : XPCOMUtils.generateQI([
Ci.extIApplication,
Ci.nsISupportsWeakReference])
function EventItem(aType, aData)
sbDeviceFirmwareAutoCheckForUpdate prototype flags
sbOSDControlService prototype QueryInterface
function SessionStorage()
sbDeviceFirmwareAutoCheckForUpdate prototype getHelperForLanguage
BogusChannel prototype open
datepicker _get(inst,'showOptions')
function PreferenceBranch(aBranch)
restoreHistoryPrecursor aCount
sbWindowsAutoPlayServiceCfg _xpcom_categories
sbDeviceFirmwareAutoCheckForUpdate prototype getInterfaces
sbDeviceFirmwareAutoCheckForUpdate prototype interfaces
classDescription implementationLanguage
_getSelectedPageStyle s i
function extApplication()
_updateTextAndScrollDataForFrame aData
sbDeviceFirmwareAutoCheckForUpdate prototype observe
function Extension(aItem)
function Preference(aName, aBranch)