Bug 1245204 - warn user that runtime will be disabled; r=marco
authorMyk Melez <myk@mykzilla.org>
Tue, 01 Mar 2016 14:29:41 -0800
changeset 324564 c1b18e68fdb5794f85fc21a9e5da47ec67760dbb
parent 324563 dea50f252713843fc6041f5bb6d46af6c2e139fd
child 324565 baabb61180e8fe2d55d76ef20fa8ad8c7f4667aa
push id1128
push userjlund@mozilla.com
push dateWed, 01 Jun 2016 01:31:59 +0000
treeherdermozilla-release@fe0d30de989d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarco
bugs1245204
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1245204 - warn user that runtime will be disabled; r=marco
webapprt/Startup.jsm
webapprt/locales/en-US/webapprt/webapp.properties
--- a/webapprt/Startup.jsm
+++ b/webapprt/Startup.jsm
@@ -4,16 +4,17 @@
 
 /* This module is imported at the startup of an application.  It takes care of
  * permissions installation, application url loading, security settings.  Put
  * stuff here that you want to happen once on startup before the webapp is
  * loaded.  */
 
 this.EXPORTED_SYMBOLS = ["startup"];
 
+const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cu = Components.utils;
 
 /* We load here modules that are needed to perform the application startup.
  * We lazily load modules that aren't needed on every startup.
  * We load modules that aren't used here but that need to perform some
  * initialization steps later in the startup function. */
 
@@ -98,16 +99,53 @@ this.startup = function(window) {
     }
 
     let appUpdated = false;
     let updatePending = yield WebappRT.isUpdatePending();
     if (updatePending) {
       appUpdated = yield WebappRT.applyUpdate();
     }
 
+    const SHOW_DISABLE_WARNING_PREF = "webapprt.showDisableWarning";
+    let checkState = { value: Services.prefs.prefHasUserValue(SHOW_DISABLE_WARNING_PREF) ?
+                              Services.prefs.getBoolPref(SHOW_DISABLE_WARNING_PREF) : true };
+    if (checkState.value) {
+      const webappBundle = Services.strings.createBundle("chrome://webapprt/locale/webapp.properties");
+
+      let windowTitle = webappBundle.GetStringFromName("disable-warning.title");
+      let windowText = webappBundle.GetStringFromName("disable-warning.description");
+      let infoLabel = webappBundle.GetStringFromName("disable-warning.info.label");
+      let infoURL = webappBundle.GetStringFromName("disable-warning.info.url");
+      let showAgainLabel = webappBundle.GetStringFromName("disable-warning.show-again");
+
+      let buttonFlags = (Services.prompt.BUTTON_POS_0 * Services.prompt.BUTTON_TITLE_OK) +
+                        (Services.prompt.BUTTON_POS_1 * Services.prompt.BUTTON_TITLE_IS_STRING) +
+                        Services.prompt.BUTTON_POS_0_DEFAULT;
+
+      let rv = Services.prompt.confirmEx(
+        window,
+        windowTitle,
+        windowText,
+        buttonFlags,
+        null,
+        infoLabel,
+        null,
+        showAgainLabel,
+        checkState
+      );
+      if (rv === 1) {
+        var uri = Services.io.newURI(infoURL, null, null);
+        Cc["@mozilla.org/uriloader/external-protocol-service;1"].
+        getService(Ci.nsIExternalProtocolService).
+        getProtocolHandlerInfo(uri.scheme).
+        launchWithURI(uri);
+      }
+    }
+    Services.prefs.setBoolPref(SHOW_DISABLE_WARNING_PREF, checkState.value);
+
     yield WebappRT.configPromise;
 
     let appData = WebappRT.config.app;
 
     // Initialize DOMApplicationRegistry by importing Webapps.jsm.
     Cu.import("resource://gre/modules/Webapps.jsm");
     // Initialize window-independent handling of webapps- notifications.
     Cu.import("resource://webapprt/modules/WebappManager.jsm");
--- a/webapprt/locales/en-US/webapprt/webapp.properties
+++ b/webapprt/locales/en-US/webapprt/webapp.properties
@@ -46,8 +46,14 @@ webapps.uninstall.title=Uninstall %S
 # LOCALIZATION NOTE (webapps.uninstall.description): %S will be replaced with the
 # name of the webapp being uninstalled.
 webapps.uninstall.description=Do you want to uninstall %S?
 webapps.uninstall.uninstall=Uninstall App
 webapps.uninstall.dontuninstall=Don't Uninstall
 
 paymentDialog.title=Payment
 paymentDialog.message=Which payment provider do you want to use?
+
+disable-warning.title=Warning: App Will Be Disabled
+disable-warning.description=This app will be disabled after you upgrade to a newer version of Firefox, which no longer includes a feature to run web apps separately from the browser.
+disable-warning.info.label=More information…
+disable-warning.info.url=https://support.mozilla.org/kb/runtime
+disable-warning.show-again=Show this warning the next time I start this app