зеркало из https://github.com/mozilla/gecko-dev.git
Bug 738818 part 3: Make changing currentEngine also change defaultEngine, including for about:home. r=fryn ui-r=limi sr=gavin
This commit is contained in:
Родитель
f76da1286d
Коммит
12f5f98da7
|
@ -256,19 +256,6 @@ 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.
|
||||
|
@ -277,6 +264,26 @@ 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ browser.jar:
|
|||
content/browser/aboutDialog.css (content/aboutDialog.css)
|
||||
content/browser/aboutRobots.xhtml (content/aboutRobots.xhtml)
|
||||
content/browser/abouthome/aboutHome.xhtml (content/abouthome/aboutHome.xhtml)
|
||||
content/browser/abouthome/aboutHome.js (content/abouthome/aboutHome.js)
|
||||
* content/browser/abouthome/aboutHome.js (content/abouthome/aboutHome.js)
|
||||
* content/browser/abouthome/aboutHome.css (content/abouthome/aboutHome.css)
|
||||
content/browser/abouthome/noise.png (content/abouthome/noise.png)
|
||||
content/browser/abouthome/snippet1.png (content/abouthome/snippet1.png)
|
||||
|
|
|
@ -45,6 +45,7 @@ var gEngineManagerDialog = {
|
|||
break;
|
||||
case "engine-removed":
|
||||
case "engine-current":
|
||||
case "engine-default":
|
||||
// Not relevant
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -121,8 +121,12 @@
|
|||
<field name="searchButton">document.getAnonymousElementByAttribute(this,
|
||||
"anonid", "searchbar-engine-button");</field>
|
||||
|
||||
<property name="currentEngine"
|
||||
onset="this.searchService.currentEngine = val; return val;">
|
||||
<property name="currentEngine">
|
||||
<setter><![CDATA[
|
||||
let ss = this.searchService;
|
||||
ss.defaultEngine = ss.currentEngine = val;
|
||||
return val;
|
||||
]]></setter>
|
||||
<getter><![CDATA[
|
||||
var currentEngine = this.searchService.currentEngine;
|
||||
// Return a dummy engine if there is no currentEngine
|
||||
|
@ -422,8 +426,9 @@
|
|||
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();
|
||||
|
|
|
@ -16,25 +16,25 @@ const SNIPPETS_URL_PREF = "browser.aboutHomeSnippets.updateUrl";
|
|||
const STARTPAGE_VERSION = 4;
|
||||
|
||||
this.AboutHomeUtils = {
|
||||
get snippetsVersion() STARTPAGE_VERSION
|
||||
};
|
||||
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.defaultEngine;
|
||||
let submission = defaultEngine.getSubmission("_searchTerms_", null, "homepage");
|
||||
if (submission.postData) {
|
||||
throw new Error("Home page does not support POST search engines.");
|
||||
/**
|
||||
* 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
|
||||
});
|
||||
}
|
||||
|
||||
return Object.freeze({
|
||||
name: defaultEngine.name,
|
||||
searchURL: submission.uri.spec
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the URL to fetch snippets from, in the urlFormatter service format.
|
||||
|
|
Загрузка…
Ссылка в новой задаче