diff --git a/browser/locales/en-US/chrome/browser/browser.properties b/browser/locales/en-US/chrome/browser/browser.properties index 7f58fe4f6ec..5a0c9acb943 100644 --- a/browser/locales/en-US/chrome/browser/browser.properties +++ b/browser/locales/en-US/chrome/browser/browser.properties @@ -357,7 +357,6 @@ webapps.install = Install webapps.install.accesskey = I #LOCALIZATION NOTE (webapps.requestInstall) %1$S is the web app name, %2$S is the site from which the web app is installed webapps.requestInstall = Do you want to install "%1$S" from this site (%2$S)? -webapps.install.success = Application Installed # Telemetry opt-out prompt for Aurora and Nightly # LOCALIZATION NOTE (telemetryOptOutPrompt): %1$S and %3$S will be replaced by diff --git a/browser/modules/webappsUI.jsm b/browser/modules/webappsUI.jsm index e24ef83dbe7..052da45b3d8 100644 --- a/browser/modules/webappsUI.jsm +++ b/browser/modules/webappsUI.jsm @@ -29,12 +29,10 @@ let webappsUI = { switch(aTopic) { case "webapps-ask-install": - let win = this._getWindowForId(data.oid); - if (win && win.location.href == data.from) { - this.doInstall(data, win); - } + let [chromeWin, browser] = this._getBrowserForId(data.oid); + if (chromeWin) + this.doInstall(data, browser, chromeWin); break; - case "webapps-launch": DOMApplicationRegistry.getManifestFor(data.origin, (function(aManifest) { if (!aManifest) @@ -85,14 +83,27 @@ let webappsUI = { } }, - doInstall: function(aData, aWindow) { - let browser = aWindow.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell) - .chromeEventHandler; + _getBrowserForId: function(aId) { + let someWindow = Services.wm.getMostRecentWindow(null); - let chromeWin = browser.ownerDocument.defaultView; - let bundle = chromeWin.gNavigatorBundle; + if (someWindow) { + let windowUtils = someWindow.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIDOMWindowUtils); + let content = windowUtils.getOuterWindowWithId(aId); + if (content) { + let browser = content.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIWebNavigation) + .QueryInterface(Ci.nsIDocShell).chromeEventHandler; + let win = browser.ownerDocument.defaultView; + return [win, browser]; + } + } + + return [null, null]; + }, + + doInstall: function(aData, aBrowser, aWindow) { + let bundle = aWindow.gNavigatorBundle; let mainAction = { label: bundle.getString("webapps.install"), @@ -106,14 +117,13 @@ let webappsUI = { } DOMApplicationRegistry.confirmInstall(aData, false, localDir); - installationSuccessNotification(app, chromeWin); } else { DOMApplicationRegistry.denyInstall(aData); } } }; - let requestingURI = chromeWin.makeURI(aData.from); + let requestingURI = aWindow.makeURI(aData.from); let manifest = new DOMApplicationManifest(aData.app.manifest, aData.app.origin); let host; @@ -124,35 +134,10 @@ let webappsUI = { } let message = bundle.getFormattedString("webapps.requestInstall", - [manifest.name, host]); + [manifest.name, host], 2); - chromeWin.PopupNotifications.show(browser, "webapps-install", message, - "webapps-notification-icon", mainAction); - }, + aWindow.PopupNotifications.show(aBrowser, "webapps-install", message, + "webapps-notification-icon", mainAction); - _getWindowForId: function(aId) { - let someWindow = Services.wm.getMostRecentWindow(null); - return someWindow && - someWindow.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDOMWindowUtils) - .getOuterWindowWithId(aId); - } -} - -function installationSuccessNotification(app, aWindow) { - let bundle = aWindow.gNavigatorBundle; - - if (("@mozilla.org/alerts-service;1" in Cc)) { - let notifier; - try { - notifier = Cc["@mozilla.org/alerts-service;1"]. - getService(Ci.nsIAlertsService); - - notifier.showAlertNotification(app.iconURI.spec, - bundle.getString("webapps.install.success"), - app.appNameAsFilename, - false, null, null); - - } catch (ex) {} } } diff --git a/dom/apps/src/Webapps.jsm b/dom/apps/src/Webapps.jsm index 1ea0011d02b..87c5d551ee1 100644 --- a/dom/apps/src/Webapps.jsm +++ b/dom/apps/src/Webapps.jsm @@ -14,7 +14,6 @@ let EXPORTED_SYMBOLS = ["DOMApplicationRegistry", "DOMApplicationManifest"]; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/FileUtils.jsm"); -Cu.import("resource://gre/modules/WebappOSUtils.jsm"); const WEBAPP_RUNTIME = Services.appinfo.ID == "webapprt@mozilla.org"; @@ -172,7 +171,7 @@ let DOMApplicationRegistry = { this.uninstall(msg); break; case "Webapps:Launch": - WebappOSUtils.launch(msg); + Services.obs.notifyObservers(this, "webapps-launch", JSON.stringify(msg)); break; case "Webapps:GetInstalled": this.getInstalled(msg); diff --git a/dom/tests/mochitest/webapps/Makefile.in b/dom/tests/mochitest/webapps/Makefile.in index d5679ad6163..d2e7e887580 100644 --- a/dom/tests/mochitest/webapps/Makefile.in +++ b/dom/tests/mochitest/webapps/Makefile.in @@ -16,7 +16,6 @@ DIRS = \ MOCHITEST_CHROME_FILES = \ test_bug_765063.xul \ - test_bug_771294.xul \ test_install_app.xul \ test_list_api.xul \ test_install_errors.xul \ diff --git a/dom/tests/mochitest/webapps/apps/Makefile.in b/dom/tests/mochitest/webapps/apps/Makefile.in index e297ba2d478..53f4500dba4 100644 --- a/dom/tests/mochitest/webapps/apps/Makefile.in +++ b/dom/tests/mochitest/webapps/apps/Makefile.in @@ -12,7 +12,6 @@ include $(DEPTH)/config/autoconf.mk MOCHITEST_CHROME_FILES = \ bug_765063.xul \ - bug_771294.xul \ include.html \ wild_crazy.webapp \ wild_crazy.webapp^headers^ \ diff --git a/dom/tests/mochitest/webapps/apps/bug_765063.xul b/dom/tests/mochitest/webapps/apps/bug_765063.xul index 462f06870cf..8f8d1c01f66 100644 --- a/dom/tests/mochitest/webapps/apps/bug_765063.xul +++ b/dom/tests/mochitest/webapps/apps/bug_765063.xul @@ -6,6 +6,6 @@ diff --git a/dom/tests/mochitest/webapps/apps/bug_771294.xul b/dom/tests/mochitest/webapps/apps/bug_771294.xul deleted file mode 100644 index 66d1d6f7a28..00000000000 --- a/dom/tests/mochitest/webapps/apps/bug_771294.xul +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - diff --git a/dom/tests/mochitest/webapps/test_bug_765063.xul b/dom/tests/mochitest/webapps/test_bug_765063.xul index 21f503e68f3..5ac9a6d6647 100644 --- a/dom/tests/mochitest/webapps/test_bug_765063.xul +++ b/dom/tests/mochitest/webapps/test_bug_765063.xul @@ -18,22 +18,19 @@ - - - - - - - - -