49 Components.utils.import(
"resource://app/jsmodules/DOMUtils.jsm");
50 Components.utils.import(
"resource://app/jsmodules/SBDataRemoteUtils.jsm");
51 Components.utils.import(
"resource://app/jsmodules/SBUtils.jsm");
52 Components.utils.import(
"resource://app/jsmodules/StringUtils.jsm");
61 const Cc = Components.classes;
62 const Ci = Components.interfaces;
63 const Cr = Components.results
102 openModalDialog:
function WindowUtils_openModalDialog(aParent,
109 return this.openDialog(aParent,
150 openDialog:
function WindowUtils_openDialog(aParent,
161 dialogPB = this._setArgs(aInArgs, aLocale);
164 var
options = aOptions.split(
",");
167 options.push(
"dialog");
169 options.push(
"modal=yes");
171 options.push(
"resizable=no");
175 options.push(
"titlebar=yes");
177 options.push(
"titlebar=no");
180 options = options.join(
",");
186 var prompter =
Cc[
"@songbirdnest.com/Songbird/Prompter;1"]
187 .createInstance(
Ci.sbIPrompter);
188 var
window = prompter.openDialog(aParent, aURL,
aName, options, dialogPB);
189 var accepted = dialogWatcher.getAccepted(window);
192 dialogWatcher.finalize();
196 this._getArgs(dialogPB, aOutArgs);
212 sizeToContent:
function WindowUtils_sizeToContent(aWindow) {
215 if ((aWindow.innerHeight >= 10) &&
216 (aWindow.innerHeight ==
217 aWindow.document.documentElement.boxObject.height)) {
223 SBUtils.deferFunction(
function() { aWindow.sizeToContent(); });
231 restartApp:
function WindowUtils_restartApp() {
233 var
os =
Cc[
"@mozilla.org/observer-service;1"]
234 .getService(
Ci.nsIObserverService);
235 var cancelQuit =
Cc[
"@mozilla.org/supports-PRBool;1"]
236 .createInstance(
Ci.nsISupportsPRBool);
237 os.notifyObservers(cancelQuit,
"quit-application-requested",
"restart");
244 var
as =
Cc[
"@mozilla.org/toolkit/app-startup;1"]
245 .getService(
Ci.nsIAppStartup);
246 as.quit(
Ci.nsIAppStartup.eRestart |
Ci.nsIAppStartup.eAttemptQuit);
260 _setArgs:
function WindowUtils__setArgs(aArgs, aLocale) {
262 if (aArgs instanceof
Ci.nsIArray) {
267 var dialogPB =
Cc[
"@mozilla.org/embedcomp/dialogparam;1"]
268 .createInstance(
Ci.nsIDialogParamBlock);
271 var stringArgNum = 0;
272 for (var
i = 0;
i < aArgs.length;
i++) {
278 if (arg instanceof
Ci.nsISupports) {
279 if (!dialogPB.objects) {
280 dialogPB.objects =
Cc[
"@songbirdnest.com/moz/xpcom/threadsafe-array;1"]
281 .createInstance(
Ci.nsIMutableArray);
283 dialogPB.objects.appendElement(arg,
false);
285 dialogPB.SetString(stringArgNum, this._getArgString(arg, aLocale));
303 _getArgs:
function WindowUtils__getArgs(aDialogPB, aArgs) {
305 for (var
i = 0;
i < aArgs.length;
i++)
306 aArgs[
i].
value = aDialogPB.GetString(
i);
322 _getArgString:
function WindowUtils__getArgString(aArg, aLocale) {
323 if (aArg instanceof
Array) {
324 var localeKeyMatch = aArg[0].match(/^&(.*);$/);
328 var localeKeyMatch = aArg.match(/^&(.*);$/);
369 _windowInfoList:
null,
370 _windowWatcher:
null,
384 initialize:
function sbDialogWatcher_initialize() {
386 this._windowInfoList = [];
389 this._windowWatcher =
Cc[
"@mozilla.org/embedcomp/window-watcher;1"]
390 .getService(
Ci.nsIWindowWatcher);
391 this._windowWatcher.registerNotification(
this);
399 finalize:
function sbDialogWatcher_finalize() {
401 this._windowWatcher.unregisterNotification(
this);
404 this._removeAllWindows();
407 this._windowWatcher =
null;
420 getAccepted:
function sbDialogWatcher_getAccepted(aWindow) {
422 var windowInfo = this._getWindowInfo(aWindow);
424 return windowInfo ? windowInfo.accepted :
false;
442 observe:
function sbDialogWatcher_observe(aSubject, aTopic,
aData) {
444 case "domwindowopened" :
445 this._addWindow(aSubject);
448 case "domwindowclosed" :
449 this._doWindowClosed(aSubject);
470 _doLoad:
function sbDialogWatcher__doLoad(aWindowInfo) {
475 var documentElement = aWindowInfo.window.document.documentElement;
476 func =
function() { _this._doAccept(aWindowInfo); };
477 aWindowInfo.domEventListenerSet.add(documentElement,
481 func =
function() { _this._doCancel(aWindowInfo); };
482 aWindowInfo.domEventListenerSet.add(documentElement,
495 _doWindowClosed:
function sbDialogWatcher__doWindowClosed(aWindow) {
497 var windowInfo = this._getWindowInfo(aWindow);
502 windowInfo.domEventListenerSet.removeAll();
503 windowInfo.domEventListenerSet =
null;
513 _doAccept:
function sbDialogWatcher__doAccept(aWindowInfo) {
515 aWindowInfo.accepted =
true;
525 _doCancel:
function sbDialogWatcher__doCancel(aWindowInfo) {
527 aWindowInfo.accepted =
false;
543 _addWindow:
function sbDialogWatcher__addWindow(aWindow) {
545 if (this._getWindowInfo(aWindow))
549 var windowInfo = {
window: aWindow, accepted:
false };
550 this._windowInfoList.push(windowInfo);
557 var func =
function() { _this._doLoad(windowInfo); };
558 windowInfo.domEventListenerSet.add(aWindow,
"load", func,
false,
true);
566 _removeAllWindows:
function sbDialogWatcher__removeAllWindows() {
568 for (var
i = 0;
i < this._windowInfoList.length;
i++) {
570 var windowInfo = this._windowInfoList[
i];
573 if (windowInfo.domEventListenerSet) {
574 windowInfo.domEventListenerSet.removeAll();
575 windowInfo.domEventListenerSet =
null;
578 this._windowInfoList =
null;
590 _getWindowInfo:
function sbDialogWatcher__getWindowInfo(aWindow) {
592 var windowInfo =
null;
593 for (var
i = 0;
i < this._windowInfoList.length;
i++) {
594 if (this._windowInfoList[
i].
window == aWindow) {
595 windowInfo = this._windowInfoList[
i];
function SBFormattedString(aKey, aParams, aDefault, aStringBundle)
function sbDialogWatcher()
function DOMEventListenerSet()
function SBString(aKey, aDefault, aStringBundle)
function SBDataGetBoolValue(aKey)
Get the value of the data in boolean format.
DataRemote prototype constructor
_getSelectedPageStyle s i
_updateTextAndScrollDataForFrame aData
sbDeviceFirmwareAutoCheckForUpdate prototype observe