Back out ec6dd0cc8053:3c55e92d87a6 (bug 738818) for being on top of bustage, and b50153f9e011 (bug 819493) for bustage

CLOSED TREE
This commit is contained in:
Phil Ringnalda 2013-04-09 21:14:56 -07:00
parent 453405ab1e
commit b5220914bd
33 changed files with 355 additions and 328 deletions

View File

@ -102,6 +102,7 @@ pref("dom.disable_open_during_load", true);
pref("privacy.popups.showBrowserMessage", true);
pref("keyword.enabled", true);
pref("keyword.URL", "https://www.google.com/m?ie=UTF-8&oe=UTF-8&sourceid=navclient&gfns=1&q=");
pref("accessibility.typeaheadfind", false);
pref("accessibility.typeaheadfind.timeout", 5000);

View File

@ -210,6 +210,9 @@ pref("xpinstall.whitelist.add.180", "marketplace.firefox.com");
pref("lightweightThemes.update.enabled", true);
pref("keyword.enabled", true);
// Override the default keyword.URL. Empty value means
// "use the search service's default engine"
pref("keyword.URL", "");
pref("general.useragent.locale", "@AB_CD@");
pref("general.skins.selectedSkin", "classic/1.0");

View File

@ -140,8 +140,7 @@ a {
}
#defaultSnippet1,
#defaultSnippet2,
#rightsSnippet {
#defaultSnippet2 {
display: block;
min-height: 38px;
background: 30px center no-repeat;
@ -149,13 +148,8 @@ a {
-moz-padding-start: 79px;
}
#rightsSnippet[hidden] {
display: none;
}
#defaultSnippet1:-moz-dir(rtl),
#defaultSnippet2:-moz-dir(rtl),
#rightsSnippet:-moz-dir(rtl) {
#defaultSnippet2:-moz-dir(rtl) {
background-position: right 30px center;
}
@ -357,8 +351,7 @@ body[narrow] #restorePreviousSession::before {
*/
@media not all and (max-resolution: 1dppx) {
#defaultSnippet1,
#defaultSnippet2,
#rightsSnippet {
#defaultSnippet2 {
background-size: 40px;
}

View File

@ -256,6 +256,19 @@ function onSearchSubmit(aEvent)
function setupSearchEngine()
{
let searchEngineName = document.documentElement.getAttribute("searchEngineName");
let searchEngineInfo = SEARCH_ENGINES[searchEngineName];
if (!searchEngineInfo) {
return;
}
// Add search engine logo.
if (searchEngineInfo.image) {
let logoElt = document.getElementById("searchEngineLogo");
logoElt.src = searchEngineInfo.image;
logoElt.alt = searchEngineName;
}
// The "autofocus" attribute doesn't focus the form element
// immediately when the element is first drawn, so the
// attribute is also used for styling when the page first loads.
@ -264,26 +277,6 @@ function setupSearchEngine()
searchText.removeEventListener("blur", searchText_onBlur);
searchText.removeAttribute("autofocus");
});
let searchEngineName = document.documentElement.getAttribute("searchEngineName");
let searchEngineInfo = SEARCH_ENGINES[searchEngineName];
let logoElt = document.getElementById("searchEngineLogo");
// Add search engine logo.
if (searchEngineInfo && searchEngineInfo.image) {
logoElt.parentNode.hidden = false;
logoElt.src = searchEngineInfo.image;
#ifdef XP_MACOSX
if (searchEngineInfo.imageHD && !window.matchMedia("(max-resolution: 1dppx)").matches)
logoElt.src = searchEngineInfo.imageHD;
#endif
logoElt.alt = searchEngineName;
searchText.placeholder = "";
}
else {
logoElt.parentNode.hidden = true;
searchText.placeholder = searchEngineName;
}
}
@ -347,19 +340,6 @@ function loadSnippets()
let _snippetsShown = false;
function showSnippets()
{
let snippetsElt = document.getElementById("snippets");
// Show about:rights notification, if needed.
let showRights = document.documentElement.getAttribute("showKnowYourRights");
if (showRights) {
let rightsElt = document.getElementById("rightsSnippet");
let anchor = rightsElt.getElementsByTagName("a")[0];
anchor.href = "about:rights";
snippetsElt.appendChild(rightsElt);
rightsElt.removeAttribute("hidden");
return;
}
if (!gSnippetsMap)
throw new Error("Snippets map has not properly been initialized");
if (_snippetsShown) {
@ -370,6 +350,7 @@ function showSnippets()
}
_snippetsShown = true;
let snippetsElt = document.getElementById("snippets");
let snippets = gSnippetsMap.get("snippets");
// If there are remotely fetched snippets, try to to show them.
if (snippets) {

View File

@ -49,7 +49,6 @@
<span id="defaultSnippet1">&abouthome.defaultSnippet1.v1;</span>
<span id="defaultSnippet2">&abouthome.defaultSnippet2.v1;</span>
</div>
<span id="rightsSnippet" hidden="true">&abouthome.rightsSnippet;</span>
<div id="snippets"/>
</div>
</div>

View File

@ -2276,15 +2276,7 @@ function BrowserOnAboutPageLoad(doc) {
// Inject search engine and snippets URL.
let docElt = doc.documentElement;
// set the following attributes BEFORE searchEngineURL, which triggers to
// show the snippets when it's set.
docElt.setAttribute("snippetsURL", AboutHomeUtils.snippetsURL);
if (AboutHomeUtils.showKnowYourRights) {
docElt.setAttribute("showKnowYourRights", "true");
// Set pref to indicate we've shown the notification.
let currentVersion = Services.prefs.getIntPref("browser.rights.version");
Services.prefs.setBoolPref("browser.rights." + currentVersion + ".shown", true);
}
docElt.setAttribute("snippetsVersion", AboutHomeUtils.snippetsVersion);
docElt.setAttribute("searchEngineName",
AboutHomeUtils.defaultSearchEngine.name);

View File

@ -9,14 +9,14 @@ XPCOMUtils.defineLazyModuleGetter(this, "Task",
XPCOMUtils.defineLazyModuleGetter(this, "AboutHomeUtils",
"resource:///modules/AboutHomeUtils.jsm");
let gRightsVersion = Services.prefs.getIntPref("browser.rights.version");
registerCleanupFunction(function() {
// Ensure we don't pollute prefs for next tests.
Services.prefs.clearUserPref("network.cookies.cookieBehavior");
Services.prefs.clearUserPref("network.cookie.lifetimePolicy");
Services.prefs.clearUserPref("browser.rights.override");
Services.prefs.clearUserPref("browser.rights." + gRightsVersion + ".shown");
try {
Services.prefs.clearUserPref("network.cookies.cookieBehavior");
} catch (ex) {}
try {
Services.prefs.clearUserPref("network.cookie.lifetimePolicy");
} catch (ex) {}
});
let gTests = [
@ -200,50 +200,6 @@ let gTests = [
}
},
{
desc: "Check if the 'Know Your Rights default snippet is shown when 'browser.rights.override' pref is set",
beforeRun: function ()
{
Services.prefs.setBoolPref("browser.rights.override", false);
},
setup: function () { },
run: function (aSnippetsMap)
{
let doc = gBrowser.selectedTab.linkedBrowser.contentDocument;
let showRights = AboutHomeUtils.showKnowYourRights;
ok(showRights, "AboutHomeUtils.showKnowYourRights should be TRUE");
let snippetsElt = doc.getElementById("snippets");
ok(snippetsElt, "Found snippets element");
is(snippetsElt.getElementsByTagName("a")[0].href, "about:rights", "Snippet link is present.");
Services.prefs.clearUserPref("browser.rights.override");
}
},
{
desc: "Check if the 'Know Your Rights default snippet is NOT shown when 'browser.rights.override' pref is NOT set",
beforeRun: function ()
{
Services.prefs.setBoolPref("browser.rights.override", true);
},
setup: function () { },
run: function (aSnippetsMap)
{
let doc = gBrowser.selectedTab.linkedBrowser.contentDocument;
let rightsData = AboutHomeUtils.knowYourRightsData;
ok(!rightsData, "AboutHomeUtils.knowYourRightsData should be FALSE");
let snippetsElt = doc.getElementById("snippets");
ok(snippetsElt, "Found snippets element");
ok(snippetsElt.getElementsByTagName("a")[0].href != "about:rights", "Snippet link should not point to about:rights.");
Services.prefs.clearUserPref("browser.rights.override");
}
}
];
function test()
@ -254,9 +210,6 @@ function test()
for (let test of gTests) {
info(test.desc);
if (test.beforeRun)
yield test.beforeRun();
let tab = yield promiseNewTabLoadEvent("about:home", "DOMContentLoaded");
// Must wait for both the snippets map and the browser attributes, since

View File

@ -17,7 +17,7 @@ var pairs = [
["1.1.1.1", "http://1.1.1.1/"],
["ftp://example", "ftp://example/"],
["ftp.example.bar", "ftp://ftp.example.bar/"],
["ex ample", Services.search.defaultEngine.getSubmission("ex ample", null, "keyword").uri.spec],
["ex ample", Services.search.originalDefaultEngine.getSubmission("ex ample", null, "keyword").uri.spec],
];
function testNext() {

View File

@ -7,12 +7,30 @@ var gTests = [
{
name: "normal search (search service)",
testText: "test search",
searchURL: Services.search.defaultEngine.getSubmission("test search", null, "keyword").uri.spec
searchURL: Services.search.originalDefaultEngine.getSubmission("test search", null, "keyword").uri.spec
},
{
name: "?-prefixed search (search service)",
testText: "? foo ",
searchURL: Services.search.defaultEngine.getSubmission("foo", null, "keyword").uri.spec
searchURL: Services.search.originalDefaultEngine.getSubmission("foo", null, "keyword").uri.spec
},
{
name: "normal search (keyword.url)",
testText: "test search",
keywordURLPref: "http://example.com/?q=",
searchURL: "http://example.com/?q=test+search"
},
{
name: "?-prefixed search (keyword.url)",
testText: "? foo ",
keywordURLPref: "http://example.com/?q=",
searchURL: "http://example.com/?q=foo"
},
{
name: "encoding test (keyword.url)",
testText: "test encoded+%/",
keywordURLPref: "http://example.com/?q=",
searchURL: "http://example.com/?q=test+encoded%2B%25%2F"
}
];

View File

@ -20,4 +20,8 @@ EXTRA_PP_COMPONENTS = \
EXTRA_JS_MODULES = distribution.js
ifdef MOZILLA_OFFICIAL
DEFINES += -DOFFICIAL_BUILD=1
endif
include $(topsrcdir)/config/rules.mk

View File

@ -53,6 +53,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "webrtcUI",
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
"resource://gre/modules/PrivateBrowsingUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "KeywordURLResetPrompter",
"resource:///modules/KeywordURLResetPrompter.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "RecentWindow",
"resource:///modules/RecentWindow.jsm");
@ -261,6 +264,13 @@ BrowserGlue.prototype = {
this._initPlaces(false);
}
break;
case "defaultURIFixup-using-keyword-pref":
if (KeywordURLResetPrompter.shouldPrompt) {
let keywordURI = subject.QueryInterface(Ci.nsIURI);
KeywordURLResetPrompter.prompt(this.getMostRecentBrowserWindow(),
keywordURI);
}
break;
case "initial-migration-will-import-default-bookmarks":
this._migrationImportsDefaultBookmarks = true;
break;
@ -334,6 +344,7 @@ BrowserGlue.prototype = {
os.addObserver(this, "distribution-customization-complete", false);
os.addObserver(this, "places-shutdown", false);
this._isPlacesShutdownObserver = true;
os.addObserver(this, "defaultURIFixup-using-keyword-pref", false);
os.addObserver(this, "handle-xul-text-link", false);
os.addObserver(this, "profile-before-change", false);
#ifdef MOZ_SERVICES_HEALTHREPORT
@ -367,6 +378,7 @@ BrowserGlue.prototype = {
os.removeObserver(this, "places-database-locked");
if (this._isPlacesShutdownObserver)
os.removeObserver(this, "places-shutdown");
os.removeObserver(this, "defaultURIFixup-using-keyword-pref");
os.removeObserver(this, "handle-xul-text-link");
os.removeObserver(this, "profile-before-change");
#ifdef MOZ_SERVICES_HEALTHREPORT
@ -516,6 +528,11 @@ BrowserGlue.prototype = {
// All initial windows have opened.
_onWindowsRestored: function BG__onWindowsRestored() {
// Show about:rights notification, if needed.
if (this._shouldShowRights()) {
this._showRightsNotification();
}
// Show update notification, if needed.
if (Services.prefs.prefHasUserValue("app.update.postupdate"))
this._showUpdateNotification();
@ -547,6 +564,9 @@ BrowserGlue.prototype = {
});
}
let keywordURLUserSet = Services.prefs.prefHasUserValue("keyword.URL");
Services.telemetry.getHistogramById("FX_KEYWORD_URL_USERSET").add(keywordURLUserSet);
// Perform default browser checking.
var shell;
try {
@ -741,6 +761,78 @@ BrowserGlue.prototype = {
}
},
/*
* _shouldShowRights - Determines if the user should be shown the
* about:rights notification. The notification should *not* be shown if
* we've already shown the current version, or if the override pref says to
* never show it. The notification *should* be shown if it's never been seen
* before, if a newer version is available, or if the override pref says to
* always show it.
*/
_shouldShowRights: function BG__shouldShowRights() {
// Look for an unconditional override pref. If set, do what it says.
// (true --> never show, false --> always show)
try {
return !Services.prefs.getBoolPref("browser.rights.override");
} catch (e) { }
// Ditto, for the legacy EULA pref.
try {
return !Services.prefs.getBoolPref("browser.EULA.override");
} catch (e) { }
#ifndef OFFICIAL_BUILD
// Non-official builds shouldn't shouldn't show the notification.
return false;
#endif
// Look to see if the user has seen the current version or not.
var currentVersion = Services.prefs.getIntPref("browser.rights.version");
try {
return !Services.prefs.getBoolPref("browser.rights." + currentVersion + ".shown");
} catch (e) { }
// Legacy: If the user accepted a EULA, we won't annoy them with the
// equivalent about:rights page until the version changes.
try {
return !Services.prefs.getBoolPref("browser.EULA." + currentVersion + ".accepted");
} catch (e) { }
// We haven't shown the notification before, so do so now.
return true;
},
_showRightsNotification: function BG__showRightsNotification() {
// Stick the notification onto the selected tab of the active browser window.
var win = this.getMostRecentBrowserWindow();
var notifyBox = win.gBrowser.getNotificationBox();
var brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties");
var rightsBundle = Services.strings.createBundle("chrome://global/locale/aboutRights.properties");
var buttonLabel = rightsBundle.GetStringFromName("buttonLabel");
var buttonAccessKey = rightsBundle.GetStringFromName("buttonAccessKey");
var productName = brandBundle.GetStringFromName("brandFullName");
var notifyRightsText = rightsBundle.formatStringFromName("notifyRightsText", [productName], 1);
var buttons = [
{
label: buttonLabel,
accessKey: buttonAccessKey,
popup: null,
callback: function(aNotificationBar, aButton) {
win.openUILinkIn("about:rights", "tab");
}
}
];
// Set pref to indicate we've shown the notification.
var currentVersion = Services.prefs.getIntPref("browser.rights.version");
Services.prefs.setBoolPref("browser.rights." + currentVersion + ".shown", true);
var notification = notifyBox.appendNotification(notifyRightsText, "about-rights", null, notifyBox.PRIORITY_INFO_LOW, buttons);
notification.persistence = -1; // Until user closes it
},
_showUpdateNotification: function BG__showUpdateNotification() {
Services.prefs.clearUserPref("app.update.postupdate");

View File

@ -45,7 +45,6 @@ var gEngineManagerDialog = {
break;
case "engine-removed":
case "engine-current":
case "engine-default":
// Not relevant
break;
}

View File

@ -121,12 +121,8 @@
<field name="searchButton">document.getAnonymousElementByAttribute(this,
"anonid", "searchbar-engine-button");</field>
<property name="currentEngine">
<setter><![CDATA[
let ss = this.searchService;
ss.defaultEngine = ss.currentEngine = val;
return val;
]]></setter>
<property name="currentEngine"
onset="this.searchService.currentEngine = val; return val;">
<getter><![CDATA[
var currentEngine = this.searchService.currentEngine;
// Return a dummy engine if there is no currentEngine
@ -426,9 +422,8 @@
var newIndex = this.engines.indexOf(this.currentEngine);
newIndex += isNextEngine ? 1 : -1;
if (newIndex >= 0 && newIndex < this.engines.length) {
if (newIndex >= 0 && newIndex < this.engines.length)
this.currentEngine = this.engines[newIndex];
}
aEvent.preventDefault();
aEvent.stopPropagation();

View File

@ -57,7 +57,7 @@ function test() {
let engine = Services.search.getEngineByName("Google");
ok(engine, "Google");
is(Services.search.defaultEngine, engine, "Check that Google is the default search engine");
is(Services.search.originalDefaultEngine, engine, "Check that Google is the default search engine");
let distributionID;
try {

View File

@ -21,8 +21,6 @@
text in <a/> will be linked to the featured add-ons on addons.mozilla.org
-->
<!ENTITY abouthome.defaultSnippet2.v1 "It's easy to customize your Firefox exactly the way you want it. <a>Choose from thousands of add-ons</a>.">
<!-- LOCALIZATION NOTE (abouthome.rightsSnippet): text in <a/> will be linked to about:rights -->
<!ENTITY abouthome.rightsSnippet "&brandFullName; is free and open source software from the non-profit Mozilla Foundation. <a>Know your rights…</a>">
<!ENTITY abouthome.bookmarksButton.label "Bookmarks">
<!ENTITY abouthome.historyButton.label "History">

View File

@ -361,6 +361,21 @@ dataReportingNotification.message = %1$S automatically sends some data to
dataReportingNotification.button.label = Choose What I Share
dataReportingNotification.button.accessKey = C
# Keyword.URL reset prompt
# LOCALIZATION NOTE (keywordPrompt.message):
# - %1$S is brandShortName
# - %2$S is a host name (e.g. "somewebsearch.com") from the current value of keyword.URL
# - %3$S is the name of the default search engine (e.g. "Google")
keywordPrompt.message = %1$S is using '%2$S' for searches from the location bar. Would you like to restore the default search (%3$S)?
# LOCALIZATION NOTE (keywordPrompt.yesButton): %1$S is the name of the default search engine
keywordPrompt.yesButton = Yes, use %1$S
keywordPrompt.yesButton.accessKey = Y
# LOCALIZATION NOTE (keywordPrompt.noButton): %1$S is a host name (e.g. "somewebsearch.com") from the current value of keyword.URL
keywordPrompt.noButton = No, continue using '%1$S'
keywordPrompt.noButton.accessKey = N
# Webapps notification popup
webapps.install = Install
webapps.install.accesskey = I

View File

@ -198,6 +198,7 @@ pref("privacy.popups.showBrowserMessage", true);
pref("dom.disable_window_open_dialog_feature", true);
pref("keyword.enabled", true);
pref("keyword.URL", "http://www.bing.com/search?q=");
pref("accessibility.typeaheadfind", false);
pref("accessibility.typeaheadfind.timeout", 5000);

View File

@ -16,66 +16,26 @@ const SNIPPETS_URL_PREF = "browser.aboutHomeSnippets.updateUrl";
const STARTPAGE_VERSION = 4;
this.AboutHomeUtils = {
get snippetsVersion() STARTPAGE_VERSION,
/**
* Returns an object containing the name and searchURL of the original default
* search engine.
*/
get defaultSearchEngine() {
let defaultEngine = Services.search.defaultEngine;
let submission = defaultEngine.getSubmission("_searchTerms_", null, "homepage");
if (submission.postData) {
throw new Error("Home page does not support POST search engines.");
}
return Object.freeze({
name: defaultEngine.name,
searchURL: submission.uri.spec
});
},
/*
* showKnowYourRights - Determines if the user should be shown the
* about:rights notification. The notification should *not* be shown if
* we've already shown the current version, or if the override pref says to
* never show it. The notification *should* be shown if it's never been seen
* before, if a newer version is available, or if the override pref says to
* always show it.
*/
get showKnowYourRights() {
// Look for an unconditional override pref. If set, do what it says.
// (true --> never show, false --> always show)
try {
return !Services.prefs.getBoolPref("browser.rights.override");
} catch (e) { }
// Ditto, for the legacy EULA pref.
try {
return !Services.prefs.getBoolPref("browser.EULA.override");
} catch (e) { }
#ifndef MOZILLA_OFFICIAL
// Non-official builds shouldn't show the notification.
return false;
#endif
// Look to see if the user has seen the current version or not.
var currentVersion = Services.prefs.getIntPref("browser.rights.version");
try {
return !Services.prefs.getBoolPref("browser.rights." + currentVersion + ".shown");
} catch (e) { }
// Legacy: If the user accepted a EULA, we won't annoy them with the
// equivalent about:rights page until the version changes.
try {
return !Services.prefs.getBoolPref("browser.EULA." + currentVersion + ".accepted");
} catch (e) { }
// We haven't shown the notification before, so do so now.
return true;
}
get snippetsVersion() STARTPAGE_VERSION
};
/**
* Returns an object containing the name and searchURL of the original default
* search engine.
*/
XPCOMUtils.defineLazyGetter(AboutHomeUtils, "defaultSearchEngine", function() {
let defaultEngine = Services.search.originalDefaultEngine;
let submission = defaultEngine.getSubmission("_searchTerms_", null, "homepage");
if (submission.postData) {
throw new Error("Home page does not support POST search engines.");
}
return Object.freeze({
name: defaultEngine.name,
searchURL: submission.uri.spec
});
});
/**
* Returns the URL to fetch snippets from, in the urlFormatter service format.
*/

View File

@ -0,0 +1,105 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
let EXPORTED_SYMBOLS = [ "KeywordURLResetPrompter" ];
const Ci = Components.interfaces;
const Cc = Components.classes;
const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
const KEYWORD_PROMPT_REV = 1;
let KeywordURLResetPrompter = {
get shouldPrompt() {
let keywordURLUserSet = Services.prefs.prefHasUserValue("keyword.URL");
let declinedRev;
try {
declinedRev = Services.prefs.getIntPref("browser.keywordURLPromptDeclined");
} catch (ex) {}
return keywordURLUserSet && declinedRev != KEYWORD_PROMPT_REV;
},
prompt: function KeywordURLResetPrompter_prompt(win, keywordURI) {
let tabbrowser = win.gBrowser;
let notifyBox = tabbrowser.getNotificationBox();
let existingNotification = notifyBox.getNotificationWithValue("keywordURL-reset");
if (existingNotification)
return;
// Find the name/URI of this build's original default engine.
// XXX: Can't use originalDefaultEngine getter here, because that doesn't
// use the default pref branch.
let defaultURI;
let defaultEngine;
try {
let defaultPB = Services.prefs.getDefaultBranch(null);
const nsIPLS = Ci.nsIPrefLocalizedString;
let defaultName = defaultPB.getComplexValue("browser.search.defaultenginename", nsIPLS).data;
defaultEngine = Services.search.getEngineByName(defaultName);
defaultURI = defaultEngine.getSubmission("foo").uri;
} catch (ex) {
// Something went horribly wrong! bail out
return;
}
// If the user-set value has the same base domain as the default, don't
// prompt.
let keywordBaseDomain;
try {
keywordBaseDomain = Services.eTLD.getBaseDomain(keywordURI);
if (keywordBaseDomain == Services.eTLD.getBaseDomain(defaultURI))
return;
} catch (ex) {}
if (!keywordBaseDomain)
return;
let brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties");
let brandShortName = brandBundle.GetStringFromName("brandShortName");
let browserBundle = win.gNavigatorBundle;
let msg = browserBundle.getFormattedString("keywordPrompt.message",
[brandShortName, keywordBaseDomain,
defaultEngine.name]);
let buttons = [
{
label: browserBundle.getFormattedString("keywordPrompt.yesButton",
[defaultEngine.name]),
accessKey: browserBundle.getString("keywordPrompt.yesButton.accessKey"),
popup: null,
callback: function(aNotificationBar, aButton) {
Services.prefs.clearUserPref("keyword.URL");
try {
// If the currently loaded URI still has the same base domain as the
// keyword URI (this is used as a rough approximation of whether the
// user is still seeing search results as opposed to having clicked
// on a result link), load the default engine's searchForm URL so
// that they can re-do their search.
let currentBaseDomain = Services.eTLD.getBaseDomain(tabbrowser.currentURI);
if (currentBaseDomain == keywordBaseDomain)
tabbrowser.loadURI(defaultEngine.searchForm);
} catch (ex) {}
}
},
{
label: browserBundle.getFormattedString("keywordPrompt.noButton",
[keywordBaseDomain]),
accessKey: browserBundle.getString("keywordPrompt.noButton.accessKey"),
popup: null,
callback: function(aNotificationBar, aButton) {
Services.prefs.setIntPref("browser.keywordURLPromptDeclined", KEYWORD_PROMPT_REV);
}
}
];
let notification = notifyBox.appendNotification(msg, "keywordURL-reset", null, notifyBox.PRIORITY_WARNING_HIGH, buttons);
notification.setAttribute("hideclose", true);
// stick around for a few page loads in case there are redirects involved
notification.persistence = 3;
}
}

View File

@ -12,6 +12,7 @@ include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/config.mk
EXTRA_JS_MODULES = \
AboutHomeUtils.jsm \
BrowserNewTabPreloader.jsm \
openLocationLastURL.jsm \
NetworkPrioritizer.jsm \
@ -19,12 +20,12 @@ EXTRA_JS_MODULES = \
SignInToWebsite.jsm \
webappsUI.jsm \
webrtcUI.jsm \
KeywordURLResetPrompter.jsm \
Social.jsm \
SharedFrame.jsm \
$(NULL)
EXTRA_PP_JS_MODULES = \
AboutHomeUtils.jsm \
RecentWindow.jsm \
$(NULL)
@ -36,8 +37,4 @@ EXTRA_JS_MODULES += \
$(NULL)
endif
ifdef MOZILLA_OFFICIAL
DEFINES += -DMOZILLA_OFFICIAL=1
endif
include $(topsrcdir)/config/rules.mk

View File

@ -330,12 +330,41 @@ NS_IMETHODIMP nsDefaultURIFixup::KeywordToURI(const nsACString& aKeyword,
}
keyword.Trim(" ");
nsAdoptingCString url = Preferences::GetLocalizedCString("keyword.URL");
if (!url) {
// Fall back to a non-localized pref, for backwards compat
url = Preferences::GetCString("keyword.URL");
}
// If the pref is set and non-empty, use it.
if (!url.IsEmpty()) {
// Escape keyword, then prepend URL
nsAutoCString spec;
if (!NS_Escape(keyword, spec, url_XPAlphas)) {
return NS_ERROR_OUT_OF_MEMORY;
}
spec.Insert(url, 0);
nsresult rv = NS_NewURI(aURI, spec);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService();
if (obsSvc) {
obsSvc->NotifyObservers(*aURI,
"defaultURIFixup-using-keyword-pref",
nullptr);
}
return NS_OK;
}
#ifdef MOZ_TOOLKIT_SEARCH
// Try falling back to the search service's default search engine
nsCOMPtr<nsIBrowserSearchService> searchSvc = do_GetService("@mozilla.org/browser/search-service;1");
if (searchSvc) {
nsCOMPtr<nsISearchEngine> defaultEngine;
searchSvc->GetDefaultEngine(getter_AddRefs(defaultEngine));
searchSvc->GetOriginalDefaultEngine(getter_AddRefs(defaultEngine));
if (defaultEngine) {
nsCOMPtr<nsISearchSubmission> submission;
// We allow default search plugins to specify alternate

View File

@ -11,7 +11,7 @@ function test() {
Services.obs.removeObserver(observer, "keyword-search");
is(topic, "keyword-search", "Got keyword-search notification");
let engine = Services.search.defaultEngine;
let engine = Services.search.originalDefaultEngine;
ok(engine, "Have default search engine.");
is(engine.name, data, "Notification data is engine name.");

View File

@ -219,6 +219,7 @@ pref("dom.disable_window_print", true);
pref("dom.disable_window_find", true);
pref("keyword.enabled", true);
pref("keyword.URL", "");
pref("accessibility.typeaheadfind", false);
pref("accessibility.typeaheadfind.timeout", 5000);

View File

@ -5775,7 +5775,8 @@ var SearchEngines = {
getSuggestionEngine: function () {
let engines = [ Services.search.currentEngine,
Services.search.defaultEngine ];
Services.search.defaultEngine,
Services.search.originalDefaultEngine ];
for (let i = 0; i < engines.length; i++) {
let engine = engines[i];

View File

@ -19,6 +19,7 @@
* - Computed values (e.g. 50 * 1024) don't work.
*/
pref("keyword.URL", "https://www.google.com/search?ie=UTF-8&oe=utf-8&q=");
pref("keyword.enabled", false);
pref("general.useragent.locale", "chrome://global/locale/intl.properties");
pref("general.useragent.compatMode.firefox", false);

View File

@ -154,7 +154,7 @@ interface nsIBrowserSearchInitObserver : nsISupports
void onInitComplete(in nsresult aStatus);
};
[scriptable, uuid(89beea9f-61a8-45d3-818d-b259f00195fe)]
[scriptable, uuid(a676eb70-6987-4429-a668-3e253b6f7c7c)]
interface nsIBrowserSearchService : nsISupports
{
/**
@ -330,13 +330,20 @@ interface nsIBrowserSearchService : nsISupports
* The default search engine. Returns the first visible engine if the default
* engine is hidden. May be null if there are no visible search engines.
*/
attribute nsISearchEngine defaultEngine;
readonly attribute nsISearchEngine defaultEngine;
/**
* The currently active search engine. May be null if there are no visible
* search engines.
*/
attribute nsISearchEngine currentEngine;
/**
* The original default engine. This differs from the "defaultEngine"
* attribute in that it always returns a given build's default engine,
* regardless of whether it is hidden.
*/
readonly attribute nsISearchEngine originalDefaultEngine;
};
%{ C++
@ -376,11 +383,4 @@ interface nsIBrowserSearchService : nsISupports
*/
#define SEARCH_ENGINE_CURRENT "engine-current";
/**
* Sent when the "default" engine is changed.
*/
#define SEARCH_ENGINE_DEFAULT "engine-default";
%}

View File

@ -58,7 +58,6 @@ const SEARCH_ENGINE_ADDED = "engine-added";
const SEARCH_ENGINE_CHANGED = "engine-changed";
const SEARCH_ENGINE_LOADED = "engine-loaded";
const SEARCH_ENGINE_CURRENT = "engine-current";
const SEARCH_ENGINE_DEFAULT = "engine-default";
// The following constants are left undocumented in nsIBrowserSearchService.idl
// For the moment, they are meant for testing/debugging purposes only.
@ -3464,22 +3463,15 @@ SearchService.prototype = {
FAIL("no engine passed to removeEngine!");
var engineToRemove = null;
for (var e in this._engines) {
for (var e in this._engines)
if (aEngine.wrappedJSObject == this._engines[e])
engineToRemove = this._engines[e];
}
if (!engineToRemove)
FAIL("removeEngine: Can't find engine to remove!", Cr.NS_ERROR_FILE_NOT_FOUND);
if (engineToRemove == this.currentEngine) {
if (engineToRemove == this.currentEngine)
this._currentEngine = null;
}
if (engineToRemove == this.defaultEngine) {
this._defaultEngine = null;
Services.prefs.clearUserPref(BROWSER_SEARCH_PREF + "defaultenginename");
}
if (engineToRemove._readOnly) {
// Just hide it (the "hidden" setter will notify) and remove its alias to
@ -3572,36 +3564,18 @@ SearchService.prototype = {
}
},
get defaultEngine() {
get originalDefaultEngine() {
this._ensureInitialized();
if (!this._defaultEngine || this._defaultEngine.hidden) {
let defPref = BROWSER_SEARCH_PREF + "defaultenginename";
let defaultEngine = this.getEngineByName(getLocalizedPref(defPref, ""))
if (!defaultEngine || defaultEngine.hidden)
defaultEngine = this._getSortedEngines(false)[0] || null;
this._defaultEngine = defaultEngine;
}
return this._defaultEngine;
const defPref = BROWSER_SEARCH_PREF + "defaultenginename";
return this.getEngineByName(getLocalizedPref(defPref, ""));
},
set defaultEngine(val) {
get defaultEngine() {
this._ensureInitialized();
if (!(val instanceof Ci.nsISearchEngine))
FAIL("Invalid argument passed to defaultEngine setter");
let newDefaultEngine = this.getEngineByName(val.name);
if (!newDefaultEngine)
FAIL("Can't find engine in store!", Cr.NS_ERROR_UNEXPECTED);
if (newDefaultEngine == this._defaultEngine)
return;
this._defaultEngine = newDefaultEngine;
let defPref = BROWSER_SEARCH_PREF + "defaultenginename";
setLocalizedPref(defPref, this._defaultEngine.name);
notifyAction(this._defaultEngine, SEARCH_ENGINE_DEFAULT);
let defaultEngine = this.originalDefaultEngine;
if (!defaultEngine || defaultEngine.hidden)
defaultEngine = this._getSortedEngines(false)[0] || null;
return defaultEngine;
},
get currentEngine() {
@ -3616,7 +3590,6 @@ SearchService.prototype = {
this._currentEngine = this.defaultEngine;
return this._currentEngine;
},
set currentEngine(val) {
this._ensureInitialized();
if (!(val instanceof Ci.nsISearchEngine))
@ -3626,9 +3599,6 @@ SearchService.prototype = {
if (!newCurrentEngine)
FAIL("Can't find engine in store!", Cr.NS_ERROR_UNEXPECTED);
if (newCurrentEngine == this._currentEngine)
return;
this._currentEngine = newCurrentEngine;
var currentEnginePref = BROWSER_SEARCH_PREF + "selectedEngine";

File diff suppressed because one or more lines are too long

View File

@ -1,83 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/*
* Test that currentEngine and defaultEngine properties can be set and yield the
* proper events and behavior (search results)
*/
"use strict";
const Ci = Components.interfaces;
Components.utils.import("resource://testing-common/httpd.js");
function search_observer(aSubject, aTopic, aData) {
let engine = aSubject.QueryInterface(Ci.nsISearchEngine);
do_print("Observer: " + aData + " for " + engine.name);
if (aData != "engine-added")
return;
if (engine.name != "A second test engine")
return;
let search = Services.search;
let engine1 = search.getEngineByName("Test search engine");
let engine2 = search.getEngineByName("A second test engine");
search.defaultEngine = engine1;
do_check_eq(search.defaultEngine.name, "Test search engine");
do_check_eq(search.defaultEngine.searchForm, "http://www.google.com/");
// Tests search defaultEngine when it changes
search.defaultEngine = engine2
do_check_eq(search.defaultEngine.name, "A second test engine");
do_check_eq(search.defaultEngine.searchForm, "https://duckduckgo.com");
// Test search defaultEngine again when we change back
search.defaultEngine = engine1;
do_check_eq(search.defaultEngine.name, "Test search engine");
do_check_eq(search.defaultEngine.searchForm, "http://www.google.com/");
// Test search defaultEngine when the current default is hidden
search.moveEngine(engine2, 0)
engine1.hidden = true;
do_check_eq(search.defaultEngine.name, "A second test engine");
do_check_eq(search.defaultEngine.searchForm, "https://duckduckgo.com");
// Test search defaultEngine when it is set to a hidden engine
search.defaultEngine = engine1;
do_check_eq(search.defaultEngine.name, "A second test engine");
do_check_eq(search.defaultEngine.searchForm, "https://duckduckgo.com");
do_test_finished();
}
function run_test() {
removeMetadata();
updateAppInfo();
let httpServer = new HttpServer();
httpServer.start(4444);
httpServer.registerDirectory("/", do_get_cwd());
let search = Services.search; // Cause service initialization
do_register_cleanup(function cleanup() {
httpServer.stop(function() {});
Services.obs.removeObserver(search_observer, "browser-search-engine-modified");
});
do_test_pending();
Services.obs.addObserver(search_observer, "browser-search-engine-modified", false);
search.addEngine("http://localhost:4444/data/engine.xml",
Ci.nsISearchEngine.DATA_XML,
null, false);
search.addEngine("http://localhost:4444/data/engine2.xml",
Ci.nsISearchEngine.DATA_XML,
null, false);
}

View File

@ -15,5 +15,4 @@ skip-if = debug && os == "linux"
[test_nodb.js]
[test_nodb_pluschanges.js]
[test_purpose.js]
[test_engineselect.js]

View File

@ -2356,6 +2356,10 @@
"n_buckets": 20,
"description": "Firefox: Time in ms spent on switching tabs in response to a tab click"
},
"FX_KEYWORD_URL_USERSET": {
"kind": "boolean",
"description": "Firefox: keyword.URL has a user-set value"
},
"FX_IDENTITY_POPUP_OPEN_MS": {
"kind": "exponential",
"high": "1000",

View File

@ -0,0 +1,7 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
buttonLabel = Know your rights…
buttonAccessKey = K
notifyRightsText = %S is free and open source software from the non-profit Mozilla Foundation.

View File

@ -9,6 +9,7 @@
locale/@AB_CD@/global/about.dtd (%chrome/global/about.dtd)
locale/@AB_CD@/global/aboutAbout.dtd (%chrome/global/aboutAbout.dtd)
locale/@AB_CD@/global/aboutRights.dtd (%chrome/global/aboutRights.dtd)
locale/@AB_CD@/global/aboutRights.properties (%chrome/global/aboutRights.properties)
locale/@AB_CD@/global/aboutSupport.dtd (%chrome/global/aboutSupport.dtd)
locale/@AB_CD@/global/aboutSupport.properties (%chrome/global/aboutSupport.properties)
locale/@AB_CD@/global/aboutTelemetry.dtd (%chrome/global/aboutTelemetry.dtd)