Bug 520021: disable flash for beta 4, r+a=stuart
authorGavin Sharp <gavin@gavinsharp.com>
Thu, 01 Oct 2009 15:57:10 -0400
changeset 65623 ecb895f9db8ad180a0f368b584abdab45c85a12d
parent 65622 0883475f694fc31e67a1fefa4feb111c6a41ece2
child 65624 1197be5b8913b339bcdbd9e23e2adc6f58151bd9
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs520021
Bug 520021: disable flash for beta 4, r+a=stuart
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -533,39 +533,45 @@ var Browser = {
     this.addTab(whereURI, true);
 
     // JavaScript Error Console
     if (gPrefService.getBoolPref("browser.console.showInPanel")){
       let tool_console = document.getElementById("tool-console");
       tool_console.hidden = false;
     }
 
-    // Re-enable plugins if we had previously disabled them. We should get rid of
-    // this code eventually...
-    if (gPrefService.prefHasUserValue("temporary.disablePlugins")) {
-      gPrefService.clearUserPref("temporary.disablePlugins");
-      this.setPluginState(true);
-    }
-
     bv.commitBatchOperation();
 
     // If some add-ons were disabled during during an application update, alert user
     if (gPrefService.prefHasUserValue("extensions.disabledAddons")) {
       let addons = gPrefService.getCharPref("extensions.disabledAddons").split(",");
       if (addons.length > 0) {
         let disabledStrings = document.getElementById("bundle_browser").getString("alertAddonsDisabled");
         let label = PluralForm.get(addons.length, disabledStrings).replace("#1", addons.length);
   
         let alerts = Cc["@mozilla.org/alerts-service;1"].getService(Ci.nsIAlertsService);
         alerts.showAlertNotification(URI_GENERIC_ICON_XPINSTALL, strings.getString("alertAddons"),
                                      label, false, "", null);
       }
       gPrefService.clearUserPref("extensions.disabledAddons");
     }
 
+    // Re-enable plugins if we had previously disabled them. We should get rid of
+    // this code eventually...
+    if (gPrefService.prefHasUserValue("temporary.disablePlugins")) {
+      gPrefService.clearUserPref("temporary.disablePlugins");
+      this.setPluginState(true);
+    }
+
+    // XXX temporarily disable flash
+    if (!gPrefService.prefHasUserValue("temporary.disabledFlash")) {
+      this.setPluginState(false, /flash/i);
+      gPrefService.setBoolPref("temporary.disabledFlash", true);
+    }
+
     //dump("end startup\n");
   },
 
   shutdown: function() {
     this._browserView.setBrowser(null, null, false);
 
     BrowserUI.uninit();
 
@@ -577,22 +583,28 @@ var Browser = {
     os.removeObserver(SoftKeyboardObserver, "softkb-change");
 #endif
     os.removeObserver(BrowserSearch, "browser-search-engine-modified");
 
     window.controllers.removeController(this);
     window.controllers.removeController(BrowserUI);
   },
 
-  setPluginState: function(enabled)
-  {
+  setPluginState: function(enabled, nameMatch) {
+    // XXX clear this out so that we always disable flash on startup, even
+    // after the user has disabled/re-enabled plugins
+    gPrefService.clearUserPref("temporary.disabledFlash");
+
     var phs = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
     var plugins = phs.getPluginTags({ });
-    for (var i = 0; i < plugins.length; ++i)
+    for (var i = 0; i < plugins.length; ++i) {
+      if (nameMatch && !nameMatch.test(plugins[i].name))
+        continue;
       plugins[i].disabled = !enabled;
+    }
   },
 
   get browsers() {
     return this._tabs.map(function(tab) { return tab.browser; });
   },
 
   scrollContentToTop: function scrollContentToTop() {
     this.contentScrollboxScroller.scrollTo(0, 0);