Bug 990125 - Ignore automatic update checks in webapp processes. r=mfinkle, a=sledru
authorMyk Melez <myk@mozilla.org>
Fri, 11 Apr 2014 15:34:28 -0700
changeset 183756 3960907890b7dbcd94a9afb9d3c1dc851f16f8df
parent 183755 3a3224245147f2c9775ada56229f5c93cad5c69a
child 183757 3437e5663d9e7962be2226ffe378317d8df56182
push id3473
push userryanvm@gmail.com
push dateMon, 14 Apr 2014 20:03:53 +0000
treeherdermozilla-beta@3437e5663d9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle, sledru
bugs990125
milestone29.0
Bug 990125 - Ignore automatic update checks in webapp processes. r=mfinkle, a=sledru
mobile/android/app/mobile.js
mobile/android/chrome/content/WebappRT.js
mobile/android/components/WebappsUpdateTimer.js
--- a/mobile/android/app/mobile.js
+++ b/mobile/android/app/mobile.js
@@ -818,14 +818,27 @@ pref("browser.snippets.syncPromo.enabled
 
 #ifdef MOZ_ANDROID_SYNTHAPKS
 // The URL of the APK factory from which we obtain APKs for webapps.
 pref("browser.webapps.apkFactoryUrl", "https://controller.apk.firefox.com/application.apk");
 
 // How frequently to check for webapp updates, in seconds (86400 is daily).
 pref("browser.webapps.updateInterval", 86400);
 
+// Whether or not to check for updates.  Enabled by default, but the runtime
+// disables it for webapp profiles on firstrun, so only the main Fennec process
+// checks for updates (to avoid duplicate update notifications).
+//
+// In the future, we might want to make each webapp process check for updates
+// for its own webapp, in which case we'll need to have a third state for this
+// preference.  Thus it's an integer rather than a boolean.
+//
+// Possible values:
+//   0: don't check for updates
+//   1: do check for updates
+pref("browser.webapps.checkForUpdates", 1);
+
 // The URL of the service that checks for updates.
 // To test updates, set this to http://apk-update-checker.paas.allizom.org,
 // which is a test server that always reports all apps as having updates.
 pref("browser.webapps.updateCheckUrl", "https://controller.apk.firefox.com/app_updates");
 
 #endif
--- a/mobile/android/chrome/content/WebappRT.js
+++ b/mobile/android/chrome/content/WebappRT.js
@@ -34,16 +34,18 @@ let WebappRT = {
     pref("extensions.autoDisableScopes", 1),
     // Disable add-on installation via the web-exposed APIs
     pref("xpinstall.enabled", false),
     // Set a future policy version to avoid the telemetry prompt.
     pref("toolkit.telemetry.prompted", 999),
     pref("toolkit.telemetry.notifiedOptOut", 999),
     pref("media.useAudioChannelService", true),
     pref("dom.mozTCPSocket.enabled", true),
+    // Don't check for updates in webapp processes to avoid duplicate notifications.
+    pref("browser.webapps.checkForUpdates", 0),
   ],
 
   init: function(aStatus, aUrl, aCallback) {
     this.deck = document.getElementById("browsers");
     this.deck.addEventListener("click", this, false, true);
 
     // on first run, update any prefs
     if (aStatus == "new") {
--- a/mobile/android/components/WebappsUpdateTimer.js
+++ b/mobile/android/components/WebappsUpdateTimer.js
@@ -28,16 +28,22 @@ function log(message) {
 function WebappsUpdateTimer() {}
 
 WebappsUpdateTimer.prototype = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsITimerCallback,
                                          Ci.nsISupportsWeakReference]),
   classID: Components.ID("{8f7002cb-e959-4f0a-a2e8-563232564385}"),
 
   notify: function(aTimer) {
+    if (Services.prefs.getIntPref("browser.webapps.checkForUpdates") == 0) {
+      // Do nothing, because updates are disabled.
+      log("Webapps update timer invoked in webapp process; ignoring.");
+      return;
+    }
+
     // If we are offline, wait to be online to start the update check.
     if (Services.io.offline) {
       log("network offline for webapp update check; waiting");
       Services.obs.addObserver(this, "network:offline-status-changed", true);
       return;
     }
 
     log("periodic check for webapp updates");