Bug 576343 - Make sure search provider loads are in a remote browser [r=mbrubeck]
authorMark Finkle <mfinkle@mozilla.com>
Fri, 02 Jul 2010 13:48:46 -0400
changeset 66354 47b71fe6798d0f19f4ab6385119b6f88a39bf69b
parent 66353 b6a3acc77e44ffb6187a7fdc4ad91fd3c8a495c0
child 66355 9077f5a079fc1a322c4b796a9542cd7f63ba463c
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
bugs576343
Bug 576343 - Make sure search provider loads are in a remote browser [r=mbrubeck]
mobile/chrome/content/Util.js
mobile/chrome/content/browser-ui.js
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/Util.js
+++ b/mobile/chrome/content/Util.js
@@ -133,16 +133,20 @@ let Util = {
     return gIOService.newURI(aURL, aOriginCharset, aBaseURI);
   },
 
   makeURLAbsolute: function makeURLAbsolute(base, url) {
     // Note:  makeURI() will throw if url is not a valid URI
     return this.makeURI(url, null, this.makeURI(base)).spec;
   },
 
+  isLocalScheme: function isLocalScheme(aURL) {
+    return (aURL.indexOf("about:") == 0 && aURL != "about:blank") || aURL.indexOf("chrome:") == 0;
+  },
+
   clamp: function(num, min, max) {
     return Math.max(min, Math.min(max, num));
   },
 
   /**
    * Determines whether a home page override is needed.
    * Returns:
    *  "new profile" if this is the first run with a new profile.
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -511,20 +511,20 @@ var BrowserUI = {
     this._edit.value = aURI;
 
     let fixupFlags = Ci.nsIURIFixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP;
     let uri = gURIFixup.createFixupURI(aURI, fixupFlags);
 
     // 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");
+    let useLocal = Util.isLocalScheme(uri.spec);
+    let hasLocal = Util.isLocalScheme(currentURI.spec);
     if (useLocal || hasLocal != useLocal) {
-      BrowserUI.newTab(uri.spec);
+      Browser.addTab(uri.spec, true);
     } else {
       let loadFlags = Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP;
       getBrowser().loadURIWithFlags(uri.spec, loadFlags, null, null);
     }
 
     gHistSvc.markPageAsTyped(uri);
   },
 
@@ -563,16 +563,25 @@ var BrowserUI = {
     Browser.hideSidebars();
     this.closeAutoComplete(false);
 
     // Make sure we're online before attempting to load
     Util.forceOnline();
 
     let submission = button.engine.getSubmission(this._edit.value, null);
     let flags = Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
+
+    let currentURI = getBrowser().currentURI;
+    let hasLocal = Util.isLocalScheme(currentURI.spec);
+    if (hasLocal) {
+      // We are in a local browser, so make a new tab and stop the initial load
+      let tab = Browser.addTab("about:blank", true);
+      tab.browser.stop();
+    }
+
     getBrowser().loadURIWithFlags(submission.uri.spec, flags, null, null, submission.postData);
   },
 
   updateStar : function() {
     if (PlacesUtils.getMostRecentBookmarkForURI(Browser.selectedBrowser.currentURI) != -1)
       this.starButton.setAttribute("starred", "true");
     else
       this.starButton.removeAttribute("starred");
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -2608,17 +2608,17 @@ Tab.prototype = {
 
     // 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");
-    let useLocal = aURI.indexOf("about") == 0 && aURI != "about:blank";
+    let useLocal = Util.isLocalScheme(aURI);
     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();