Bug 575581 - Default keyword search does not work for single-word keywords [r=mfinkle]
authorMatt Brubeck <mbrubeck@mozilla.com>
Thu, 22 Jul 2010 23:55:58 -0400
changeset 66390 5840b05bd4b1c0c06e317b786dffd872c5bae36e
parent 66389 725e79210addfa6c54b810e3022a42ed898c5302
child 66391 75544c41a88cc2ad3d36fd7e3612e66ad4e37d04
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)
reviewersmfinkle
bugs575581
Bug 575581 - Default keyword search does not work for single-word keywords [r=mfinkle]
mobile/chrome/content/bindings/browser.xml
mobile/chrome/content/browser-ui.js
--- a/mobile/chrome/content/bindings/browser.xml
+++ b/mobile/chrome/content/bindings/browser.xml
@@ -424,17 +424,19 @@
           STOP_ALL: 3,
 
           canGoBack: false,
           canGoForward: false,
           goBack: function() { this._sendMessage("WebNavigation:GoBack", {}); },
           goForward: function() { this._sendMessage("WebNavigation:GoForward", {}); },
           gotoIndex: function(aIndex) { this._sendMessage("WebNavigation:GotoIndex", {index: aIndex}); },
           loadURI: function(aURI, aLoadFlags, aReferrer, aPostData, aHeaders) {
-            this._currentURI = this._browser._ios.newURI(aURI, null, null);
+            try {
+              this._currentURI = this._browser._ios.newURI(aURI, null, null);
+            } catch(e) {}
             this._browser._contentTitle = "";
             this._sendMessage("WebNavigation:LoadURI", {uri: aURI, flags: aLoadFlags});
           },
           reload: function(aReloadFlags) { this._sendMessage("WebNavigation:Reload", {flags: aReloadFlags}); },
           stop: function(aStopFlags) { this._sendMessage("WebNavigation:Stop", {flags: aStopFlags}); },
           get document() { Components.utils.reportError("contentDocument is not available"); return null; },
           get currentURI() {
             if (!this._currentURI)
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -441,22 +441,19 @@ var BrowserUI = {
     else {
       this._favicon.hidden = false;
       this._throbber.hidden = true;
       this._throbber.removeAttribute("loading");
     }
   },
 
   getDisplayURI: function(browser) {
-    if (!this._URIFixup)
-      this._URIFixup = Cc["@mozilla.org/docshell/urifixup;1"].getService(Ci.nsIURIFixup);
-
     let uri = browser.currentURI;
     try {
-      uri = this._URIFixup.createExposableURI(uri);
+      uri = gURIFixup.createExposableURI(uri);
     } catch (ex) {}
 
     return uri.spec;
   },
 
   /* Set the location to the current content */
   updateURI: function() {
     var browser = Browser.selectedBrowser;
@@ -487,31 +484,32 @@ var BrowserUI = {
     Util.forceOnline();
 
     // Give the new page lots of room
     Browser.hideSidebars();
     this.closeAutoComplete(true);
 
     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 = Util.isLocalScheme(uri.spec);
+    let useLocal = Util.isLocalScheme(aURI);
     let hasLocal = Util.isLocalScheme(currentURI.spec);
     if (hasLocal != useLocal) {
-      Browser.addTab(uri.spec, true);
+      Browser.addTab(aURI, true);
     } else {
       let loadFlags = Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP;
-      getBrowser().loadURIWithFlags(uri.spec, loadFlags, null, null);
+      getBrowser().loadURIWithFlags(aURI, loadFlags, null, null);
     }
 
+    // Delay doing the fixup so the raw URI is passed to loadURIWithFlags
+    // and the proper third-party fixup can be done
+    let fixupFlags = Ci.nsIURIFixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP;
+    let uri = gURIFixup.createFixupURI(aURI, fixupFlags);
     gHistSvc.markPageAsTyped(uri);
   },
 
   showAutoComplete: function showAutoComplete() {
     if (this.isAutoCompleteOpen())
       return;
 
     BrowserSearch.updateSearchButtons();