diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js
index d9681f64a14f..2efecf27b1a8 100644
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -308,6 +308,12 @@ pref("browser.urlbar.suggest.history.onlyTyped", false);
pref("browser.urlbar.formatting.enabled", true);
pref("browser.urlbar.trimURLs", true);
+#if defined(NIGHTLY_BUILD)
+pref("browser.urlbar.oneOffSearches", true);
+#else
+pref("browser.urlbar.oneOffSearches", false);
+#endif
+
pref("browser.altClickSave", false);
// Enable logging downloads operations to the Console.
diff --git a/browser/base/content/browser.xul b/browser/base/content/browser.xul
index 51eb4077f029..b137c4235db2 100644
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -152,14 +152,7 @@
noautofocus="true"
hidden="true"
flip="none"
- level="parent">
-#ifdef NIGHTLY_BUILD
-
-#endif
-
+ level="parent"/>
-
+
+
+
{
- [url, postData, mayInheritPrincipal] = response;
- if (url) {
- matchLastLocationChange = (lastLocationChange ==
- gBrowser.selectedBrowser.lastLocationChange);
- continueOperation.call(this);
- }
- });
+ let isMouseEvent = event instanceof MouseEvent;
+ if (isMouseEvent && event.button == 2) {
+ // Do nothing for right clicks.
+ return;
}
- function continueOperation()
- {
- this.value = url;
- gBrowser.userTypedValue = url;
- if (gInitialPages.includes(url)) {
- gBrowser.selectedBrowser.initialPageLoadedFromURLBar = url;
- }
- try {
- addToUrlbarHistory(url);
- } catch (ex) {
- // Things may go wrong when adding url to session history,
- // but don't let that interfere with the loading of the url.
- Cu.reportError(ex);
- }
+ // Do the command of the selected one-off if it's not an engine.
+ let selectedOneOff =
+ this.popup.oneOffSearchButtons.visuallySelectedButton;
+ if (selectedOneOff && !selectedOneOff.engine) {
+ selectedOneOff.doCommand();
+ return;
+ }
- let loadCurrent = () => {
- try {
- openUILinkIn(url, "current", {
- allowThirdPartyFixup: true,
- indicateErrorPageLoad: true,
- disallowInheritPrincipal: !mayInheritPrincipal,
- allowPinnedTabHostChange: true,
- postData: postData,
- allowPopups: url.startsWith("javascript:"),
- });
- } catch (ex) {
- // This load can throw an exception in certain cases, which means
- // we'll want to replace the URL with the loaded URL:
- if (ex.result != Cr.NS_ERROR_LOAD_SHOWED_ERRORPAGE) {
- this.handleRevert();
- }
- }
-
- // Ensure the start of the URL is visible for UX reasons:
- this.selectionStart = this.selectionEnd = 0;
- };
-
- // Focus the content area before triggering loads, since if the load
- // occurs in a new tab, we want focus to be restored to the content
- // area when the current tab is re-selected.
- gBrowser.selectedBrowser.focus();
-
- let isMouseEvent = aTriggeringEvent instanceof MouseEvent;
-
- // If the current tab is empty, ignore Alt+Enter (just reuse this tab)
- let altEnter = !isMouseEvent && aTriggeringEvent &&
- aTriggeringEvent.altKey && !isTabEmpty(gBrowser.selectedTab);
-
- if (isMouseEvent || altEnter) {
- // Use the standard UI link behaviors for clicks or Alt+Enter
- let where = "tab";
- if (isMouseEvent)
- where = whereToOpenLink(aTriggeringEvent, false, false);
-
- if (where == "current") {
- if (matchLastLocationChange) {
- loadCurrent();
- }
- } else {
- this.handleRevert();
- let params = { allowThirdPartyFixup: true,
- postData: postData,
- initiatingDoc: document };
- openUILinkIn(url, where, params);
- }
+ let where = openUILinkWhere;
+ if (!where) {
+ if (isMouseEvent) {
+ where = whereToOpenLink(event, false, false);
} else {
- if (matchLastLocationChange) {
- loadCurrent();
- }
+ // 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";
}
}
+
+ let url = this.value;
+ let mayInheritPrincipal = false;
+ let postData = null;
+ let lastLocationChange = gBrowser.selectedBrowser.lastLocationChange;
+ let matchLastLocationChange = true;
+
+ let action = this._parseActionUrl(url);
+ if (action) {
+ switch (action.type) {
+ case "visiturl":
+ case "keyword":
+ case "remotetab":
+ url = action.params.url;
+ break;
+ case "switchtab":
+ url = action.params.url;
+ if (this.hasAttribute("actiontype")) {
+ this.handleRevert();
+ let prevTab = gBrowser.selectedTab;
+ if (switchToTabHavingURI(url) && isTabEmpty(prevTab)) {
+ gBrowser.removeTab(prevTab);
+ }
+ return;
+ }
+ break;
+ case "searchengine":
+ if (selectedOneOff && selectedOneOff.engine) {
+ // Replace the engine with the selected one-off engine.
+ action.params.engineName = engine.name;
+ }
+ [url, postData] = this._recordSearchEngineLoad(
+ action.params.engineName,
+ action.params.searchSuggestion || action.params.searchQuery,
+ event,
+ where,
+ openUILinkParams
+ );
+ break;
+ }
+ this._loadURL(url, postData, where, openUILinkParams,
+ matchLastLocationChange, mayInheritPrincipal);
+ return;
+ }
+
+ // If there's a selected one-off button and the input value is a
+ // search query (or "keyword" in URI-fixup terminology), then load a
+ // search using the one-off's engine.
+ if (selectedOneOff && selectedOneOff.engine) {
+ // `url` (which is this.value) may be an autofilled string. Search
+ // only with the portion that the user typed, if any, by preferring
+ // the autocomplete controller's searchString.
+ let value = this._searchStringOnHandleEnter ||
+ this.mController.searchString ||
+ url;
+ let fixup;
+ try {
+ fixup = Services.uriFixup.getFixupURIInfo(
+ value,
+ Services.uriFixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP
+ );
+ } catch (ex) {}
+ if (fixup && fixup.keywordProviderName) {
+ [url, postData] =
+ this._recordSearchEngineLoad(selectedOneOff.engine, value,
+ event, where, openUILinkParams);
+ this._loadURL(url, postData, where, openUILinkParams,
+ matchLastLocationChange, mayInheritPrincipal);
+ return;
+ }
+ }
+
+ this._canonizeURL(event, response => {
+ [url, postData, mayInheritPrincipal] = response;
+ if (url) {
+ matchLastLocationChange =
+ lastLocationChange ==
+ gBrowser.selectedBrowser.lastLocationChange;
+ this._loadURL(url, postData, where, openUILinkParams,
+ matchLastLocationChange, mayInheritPrincipal);
+ }
+ });
+ ]]>
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
@@ -728,11 +823,21 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
case "trimURLs":
this._mayTrimURLs = this._prefs.getBoolPref(aData);
break;
+ case "oneOffSearches":
+ this._enableOrDisableOneOffSearches();
+ break;
}
}
]]>