Bug 552832 - Make about: pages in Fennec be local, in-content UI [r=mbrubeck r=vingtetun]
authorMark Finkle <mfinkle@mozilla.com>
Thu, 17 Jun 2010 12:27:26 -0400
changeset 66294 f96a7037c7e17d0976adf49446e677e862fdc9fc
parent 66293 bdd353e67e8a5cefde98fef6f2db403631cf45be
child 66295 840acf753e00b8932f6c6578dec2fc6419a6e14e
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)
reviewersmbrubeck, vingtetun
bugs552832
Bug 552832 - Make about: pages in Fennec be local, in-content UI [r=mbrubeck r=vingtetun]
mobile/chrome/content/browser-ui.js
mobile/chrome/content/browser.js
mobile/chrome/content/content.js
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -525,18 +525,27 @@ var BrowserUI = {
     Browser.hideSidebars();
     this.closeAutoComplete(true);
 
     this._edit.value = aURI;
 
     let fixupFlags = Ci.nsIURIFixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP;
     let uri = gURIFixup.createFixupURI(aURI, fixupFlags);
 
-    let loadFlags = Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP;
-    getBrowser().loadURIWithFlags(uri.spec, loadFlags, null, null);
+    // We need to keep about: pages opening in new "local" tabs. We also want to spawn
+    // new "remote" tabs if opening web pages from a "local" about: page.
+    let currentURI = getBrowser().currentURI;
+    let useLocal = (uri.schemeIs("about") && uri.spec != "about:blank");
+    let hasLocal = (currentURI.schemeIs("about") && currentURI.spec != "about:blank");
+    if (useLocal || hasLocal != useLocal) {
+      BrowserUI.newTab(uri.spec);
+    } else {
+      let loadFlags = Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP;
+      getBrowser().loadURIWithFlags(uri.spec, loadFlags, null, null);
+    }
 
     gHistSvc.markPageAsTyped(uri);
   },
 
   showAutoComplete : function showAutoComplete() {
     if (this.isAutoCompleteOpen())
       return;
 
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -756,25 +756,23 @@ var Browser = {
     for (var t = 0; t < this._tabs.length; t++) {
       if (this._tabs[t].chromeTab == chromeTab)
         return this._tabs[t];
     }
     return null;
   },
 
   addTab: function(uri, bringFront, aOwner) {
-    let newTab = new Tab();
+    let newTab = new Tab(uri);
     newTab.owner = aOwner || null;
     this._tabs.push(newTab);
 
     if (bringFront)
       this.selectedTab = newTab;
 
-    newTab.load(uri);
-
     let event = document.createEvent("Events");
     event.initEvent("TabOpen", true, false);
     newTab.chromeTab.dispatchEvent(event);
 
     return newTab;
   },
 
   closeTab: function(tab) {
@@ -2953,33 +2951,33 @@ var OfflineApps = {
 
   receiveMessage: function receiveMessage(aMessage) {
     if (aMessage.name == "Browser:MozApplicationManifest") {
       this.offlineAppRequested(aMessage.json);
     }
   }
 };
 
-function Tab() {
+function Tab(aURI) {
   this._id = null;
   this._browser = null;
   this._browserViewportState = null;
   this._state = null;
   this._listener = null;
   this._loading = false;
   this._chromeTab = null;
   this._resizeAndPaint = Util.bind(this._resizeAndPaint, this);
 
   this.owner = null;
 
   // Set to 0 since new tabs that have not been viewed yet are good tabs to
   // toss if app needs more memory.
   this.lastSelected = 0;
 
-  this.create();
+  this.create(aURI);
 }
 
 Tab.prototype = {
   get browser() {
     return this._browser;
   },
 
   get browserViewportState() {
@@ -3125,68 +3123,67 @@ Tab.prototype = {
     // if this tab was sacrificed previously, restore its state
     this.restoreState();
   },
 
   isLoading: function isLoading() {
     return this._loading;
   },
 
-  load: function load(uri) {
-    this._browser.setAttribute("src", uri);
-  },
-
-  create: function create() {
+  create: function create(aURI) {
     // Initialize a viewport state for BrowserView
     this._browserViewportState = BrowserView.Util.createBrowserViewportState();
 
     this._chromeTab = document.getElementById("tabs").addTab();
-    this._createBrowser();
+    this._createBrowser(aURI);
   },
 
   destroy: function destroy() {
     document.getElementById("tabs").removeTab(this._chromeTab);
     this._chromeTab = null;
     this._destroyBrowser();
   },
 
   /** Create browser if it doesn't already exist. */
   ensureBrowserExists: function ensureBrowserExists() {
     if (!this._browser) {
       this._createBrowser();
       this.browser.contentDocument.location = this._state._url;
     }
   },
 
-  _createBrowser: function _createBrowser() {
+  _createBrowser: function _createBrowser(aURI) {
     if (this._browser)
       throw "Browser already exists";
 
     // Create the browser using the current width the dynamically size the height
     let browser = this._browser = document.createElement("browser");
 
     browser.setAttribute("style", "overflow: -moz-hidden-unscrollable; visibility: hidden;");
     browser.setAttribute("type", "content");
 
     let useRemote = gPrefService.getBoolPref("browser.tabs.remote");
-    browser.setAttribute("remote", useRemote ? "true" : "false");
-
+    let useLocal = aURI.indexOf("about") == 0 && aURI != "about:blank";
+    browser.setAttribute("remote", (!useLocal && useRemote) ? "true" : "false");
+    
     // Append the browser to the document, which should start the page load
     document.getElementById("browsers").appendChild(browser);
 
     // stop about:blank from loading
     browser.stop();
 
     // Attach a separate progress listener to the browser
     let flags = Ci.nsIWebProgress.NOTIFY_LOCATION |
                 Ci.nsIWebProgress.NOTIFY_SECURITY |
                 Ci.nsIWebProgress.NOTIFY_STATE_NETWORK |
                 Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT;
     this._listener = new ProgressController(this);
     browser.webProgress.addProgressListener(this._listener, flags);
+
+    browser.setAttribute("src", aURI);
   },
 
   _destroyBrowser: function _destroyBrowser() {
     if (this._browser) {
       var browser = this._browser;
       browser.removeProgressListener(this._listener);
 
       this._browser = null;
--- a/mobile/chrome/content/content.js
+++ b/mobile/chrome/content/content.js
@@ -914,12 +914,12 @@ let ViewportHandler = {
       defaultZoom: defaultZoom,
       minZoom: minZoom,
       maxZoom: maxZoom,
       width: viewportWidth,
       height: viewportHeight,
       autoSize: autoSize,
       allowZoom: windowUtils.getDocumentMetadata("viewport-user-scalable") != "no"
     };
-  },
+  }
 };
 
 ViewportHandler.init();