Bug 1394304 - Use pref to control whether to open url bar results in a new tab. r=adw
authorTing-Yu Lin <tlin@mozilla.com>
Mon, 28 Aug 2017 13:31:20 +0800
changeset 378119 b7a2fb849cfa6e12d5e43b8af3cee6eca97854d5
parent 378118 14960c3fbf80f4f366b7224792c65089e6192a69
child 378120 78eebfdf0ec211b5a2f47c2cab8dba1b1207d17c
push id50188
push usertlin@mozilla.com
push dateFri, 01 Sep 2017 03:21:24 +0000
treeherderautoland@b7a2fb849cfa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1394304
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1394304 - Use pref to control whether to open url bar results in a new tab. r=adw MozReview-Commit-ID: 9cIttOqOU4d
browser/base/content/urlbarBindings.xml
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -69,16 +69,18 @@ file, You can obtain one at http://mozil
                                 .getService(Components.interfaces.nsIPrefService)
                                 .getBranch("browser.urlbar.");
         this._prefs.addObserver("", this);
 
         this._defaultPrefs = Components.classes["@mozilla.org/preferences-service;1"]
                                        .getService(Components.interfaces.nsIPrefService)
                                        .getDefaultBranch("browser.urlbar.");
 
+        Services.prefs.addObserver("browser.search.openintab", this);
+        this.browserSearchOpenInTab = Services.prefs.getBoolPref("browser.search.openintab");
         Services.prefs.addObserver("browser.search.suggest.enabled", this);
         this.browserSearchSuggestEnabled = Services.prefs.getBoolPref("browser.search.suggest.enabled");
 
         this.clickSelectsAll = this._prefs.getBoolPref("clickSelectsAll");
         this.doubleClickSelectsAll = this._prefs.getBoolPref("doubleClickSelectsAll");
         this.completeDefaultIndex = this._prefs.getBoolPref("autoFill");
         this.speculativeConnectEnabled = this._prefs.getBoolPref("speculativeConnect.enabled");
         this.urlbarSearchSuggestEnabled = this._prefs.getBoolPref("suggest.searches");
@@ -132,16 +134,17 @@ file, You can obtain one at http://mozil
         // to handle cases like backspace, autofill or repeated searches.
         // Ensure to clear those internal caches when switching tabs.
         gBrowser.tabContainer.addEventListener("TabSelect", this);
       ]]></constructor>
 
       <destructor><![CDATA[
         this._prefs.removeObserver("", this);
         this._prefs = null;
+        Services.prefs.removeObserver("browser.search.openintab", this);
         Services.prefs.removeObserver("browser.search.suggest.enabled", this);
         this.inputField.controllers.removeController(this._copyCutController);
         this.inputField.removeEventListener("paste", this);
         this.inputField.removeEventListener("mousedown", this);
         this.inputField.removeEventListener("mousemove", this);
         this.inputField.removeEventListener("mouseout", this);
         this.inputField.removeEventListener("overflow", this);
         this.inputField.removeEventListener("underflow", this);
@@ -552,16 +555,18 @@ file, You can obtain one at http://mozil
             selectedOneOff.doCommand();
             return;
           }
 
           let where = openUILinkWhere;
           if (!where) {
             if (isMouseEvent) {
               where = whereToOpenLink(event, false, false);
+            } else if (this.browserSearchOpenInTab) {
+              where = "tab";
             } else {
               // If the current tab is empty, ignore Alt+Enter (reuse this tab)
               let altEnter = !isMouseEvent &&
                              event &&
                              event.altKey &&
                              !isTabEmpty(gBrowser.selectedTab);
               where = altEnter ? "tab" : "current";
             }
@@ -1088,16 +1093,19 @@ file, You can obtain one at http://mozil
                 this.timeout = this._prefs.getIntPref(aData);
                 break;
               case "formatting.enabled":
                 this._formattingEnabled = this._prefs.getBoolPref(aData);
                 break;
               case "speculativeConnect.enabled":
                 this.speculativeConnectEnabled = this._prefs.getBoolPref(aData);
                 break;
+              case "browser.search.openintab":
+                this.browserSearchOpenInTab = Services.prefs.getBoolPref(aData);
+                break;
               case "browser.search.suggest.enabled":
                 this.browserSearchSuggestEnabled = Services.prefs.getBoolPref(aData);
                 break;
               case "suggest.searches":
                 this.urlbarSearchSuggestEnabled = this._prefs.getBoolPref(aData);
               case "userMadeSearchSuggestionsChoice":
                 // Mirror the value for future use, see the comment in the
                 // binding's constructor.