Bug 1394304: Part 1 - Use pref to control whether to open url bar results in a new tab. r=adw
authorYuri Khan <yuri.v.khan@gmail.com>
Sun, 28 Jan 2018 22:28:09 +0700
changeset 402517 6c3394c9aec3d9d8e4f78aeb7a69045374886642
parent 402516 ff8ae0661153a0fe72cf7eead67060b4248e8372
child 402518 420221f11352798df551b529727f0dfc8830b65e
push id99585
push usercsabou@mozilla.com
push dateTue, 06 Feb 2018 11:04:29 +0000
treeherdermozilla-inbound@420221f11352 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1394304
milestone60.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: Part 1 - Use pref to control whether to open url bar results in a new tab. r=adw
browser/app/profile/firefox.js
browser/base/content/urlbarBindings.xml
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -338,16 +338,20 @@ pref("browser.urlbar.oneOffSearches", tr
 // If changed to true, copying the entire URL from the location bar will put the
 // human readable (percent-decoded) URL on the clipboard.
 pref("browser.urlbar.decodeURLsOnCopy", false);
 
 // Whether or not to move tabs into the active window when using the "Switch to
 // Tab" feature of the awesomebar.
 pref("browser.urlbar.switchTabs.adoptIntoActiveWindow", false);
 
+// Whether addresses and search results typed into the address bar
+// should be opened in new tabs by default.
+pref("browser.urlbar.openintab", false);
+
 pref("browser.altClickSave", false);
 
 // Enable logging downloads operations to the Console.
 pref("browser.download.loglevel", "Error");
 
 // Number of milliseconds to wait for the http headers (and thus
 // the Content-Disposition filename) before giving up and falling back to
 // picking a filename without that info in hand so that the user sees some
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -68,16 +68,17 @@ file, You can obtain one at http://mozil
 
         this._defaultPrefs = Components.classes["@mozilla.org/preferences-service;1"]
                                        .getService(Components.interfaces.nsIPrefService)
                                        .getDefaultBranch("browser.urlbar.");
 
         Services.prefs.addObserver("browser.search.suggest.enabled", this);
         this.browserSearchSuggestEnabled = Services.prefs.getBoolPref("browser.search.suggest.enabled");
 
+        this.openInTab = this._prefs.getBoolPref("openintab");
         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");
         this.timeout = this._prefs.getIntPref("delay");
         this._formattingEnabled = this._prefs.getBoolPref("formatting.enabled");
         this._mayTrimURLs = this._prefs.getBoolPref("trimURLs");
@@ -525,16 +526,24 @@ file, You can obtain one at http://mozil
           let reuseEmpty = !isMouseEvent;
           let where = undefined;
           if (isMouseEvent) {
             where = whereToOpenLink(event, false, false);
           } else {
             let altEnter = event && event.altKey;
             where = altEnter ? "tab" : "current";
           }
+          if (this.openInTab) {
+            if (where == "current") {
+              where = "tab";
+            } else if (where == "tab") {
+              where = "current";
+            }
+            reuseEmpty = true;
+          }
           if (where == "tab" && reuseEmpty && isTabEmpty(gBrowser.selectedTab)) {
             where = "current";
           }
           return where;
         ]]></body>
       </method>
 
       <!--
@@ -1121,16 +1130,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 "openintab":
+                this.openInTab = this._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.