Bug 537742 - disable plugins by default on the n810. r=mfinkle
authorDoug Turner <dougt@dougt.org>
Tue, 05 Jan 2010 15:12:04 -0800
changeset 1266 3c75260a9b45215a8138bdc5abec74ac045b32e1
parent 1265 3877bec117f2b1bdb19f6525368bd6e8099c1201
child 1267 6e55a68ebe6122a539d33421b1c2210dc9eb4c3b
push id1127
push userdougt@mozilla.com
push dateTue, 05 Jan 2010 23:12:27 +0000
reviewersmfinkle
bugs537742
Bug 537742 - disable plugins by default on the n810. r=mfinkle
chrome/content/BrowserView.js
chrome/content/browser.js
--- a/chrome/content/BrowserView.js
+++ b/chrome/content/BrowserView.js
@@ -240,35 +240,16 @@ BrowserView.prototype = {
     this._contentWindow = null;
     this._renderMode = 0;
     this._offscreenDepth = 0;
 
     let cacheSize = kBrowserViewCacheSize;
     try {
       cacheSize = gPrefService.getIntPref("tile.cache.size");
     } catch(e) {}
-
-    if (cacheSize == -1) {
-      let sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
-      let device = sysInfo.get("device");
-      switch (device) {
-#ifdef MOZ_PLATFORM_HILDON
-        case "Nokia N900":
-          cacheSize = 26;
-          break;
-        case "Nokia N8xx":
-          // N8xx has half the memory of N900 and crashes with higher numbers
-          cacheSize = 10;
-          break;
-#endif
-        default:
-          // Use a minimum number of tiles sice we don't know the device
-          cacheSize = 6;
-      }
-    }
     
     this._tileManager = new TileManager(this._appendTile, this._removeTile, this, cacheSize);
     this._visibleRectFactory = visibleRectFactory;
 
     this._idleServiceObserver = new BrowserView.IdleServiceObserver(this);
     this._idleService = Cc["@mozilla.org/widget/idleservice;1"].getService(Ci.nsIIdleService);
     this._idleService.addIdleObserver(this._idleServiceObserver, kBrowserViewPrefetchBeginIdleWait);
     this._idleServiceWait = kBrowserViewPrefetchBeginIdleWait;
--- a/chrome/content/browser.js
+++ b/chrome/content/browser.js
@@ -340,16 +340,20 @@ var Browser = {
   controlsScrollboxScroller: null,
   pageScrollbox: null,
   pageScrollboxScroller: null,
   styles: {},
 
   startup: function() {
     var self = this;
 
+    let needOverride = Util.needHomepageOverride();
+    if (needOverride == "new profile")
+      this.initNewProfile();
+
     let container = document.getElementById("tile-container");
     let bv = this._browserView = new BrowserView(container, Browser.getVisibleRect);
 
     /* handles dispatching clicks on tiles into clicks in content or zooms */
     container.customClicker = new ContentCustomClicker(bv);
 
     /* scrolling box that contains tiles */
     let contentScrollbox = this.contentScrollbox = document.getElementById("content-scrollbox");
@@ -494,17 +498,17 @@ var Browser = {
     // Login Manager
     Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
 
     // Make sure we're online before attempting to load
     Util.forceOnline();
 
     // Command line arguments/initial homepage
     let whereURI = "about:blank";
-    switch (Util.needHomepageOverride()) {
+    switch (needOverride) {
       case "new profile":
         whereURI = "about:firstrun";
         break;
       case "new version":
       case "none":
         whereURI = "about:blank";
         break;
     }
@@ -625,16 +629,54 @@ var Browser = {
     var plugins = phs.getPluginTags({ });
     for (var i = 0; i < plugins.length; ++i) {
       if (nameMatch && !nameMatch.test(plugins[i].name))
         continue;
       plugins[i].disabled = !enabled;
     }
   },
 
+  initNewProfile: function initNewProfile() {
+    let sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
+    let device = sysInfo.get("device");
+
+#ifdef MOZ_PLATFORM_HILDON
+    // The flash plugin on the n8xx doesn't support the image expose fast
+    // drawing we are doing. Disable all plugins by default. Users can override
+    // in prefs
+    if (device == "Nokia N8xx") {
+      gPrefService.setBoolPref("plugins.enabled", false);
+      this.setPluginState(true);
+    }
+#endif
+    // set up the cache size
+    let cacheSize = -1;
+    try {
+      cacheSize = gPrefService.getIntPref("tile.cache.size");
+    } catch(e) {}
+
+    if (cacheSize == -1) {
+      switch (device) {
+#ifdef MOZ_PLATFORM_HILDON
+        case "Nokia N900":
+          cacheSize = 26;
+          break;
+        case "Nokia N8xx":
+          // N8xx has half the memory of N900 and crashes with higher numbers
+          cacheSize = 10;
+          break;
+#endif
+        default:
+          // Use a minimum number of tiles sice we don't know the device
+          cacheSize = 6;
+      }
+      gPrefService.setIntPref("tile.cache.size", cacheSize);
+    }
+  },
+
   get browsers() {
     return this._tabs.map(function(tab) { return tab.browser; });
   },
 
   scrollContentToTop: function scrollContentToTop() {
     this.contentScrollboxScroller.scrollTo(0, 0);
     this.pageScrollboxScroller.scrollTo(0, 0);
     this._browserView.onAfterVisibleMove();