Bug 351817 - implement pref-based search parameters, r=gavin

This commit is contained in:
benjamin%smedbergs.us 2006-09-08 19:27:29 +00:00
Родитель e7ea8ecdd3
Коммит 21ed85e1f3
3 изменённых файлов: 42 добавлений и 30 удалений

Просмотреть файл

@ -223,6 +223,9 @@ pref("browser.search.order.Yahoo.1", "chrome://branding/content/searchc
pref("browser.search.order.Yahoo.2", "chrome://branding/content/searchconfig.properties");
pref("browser.search.order.Yahoo", "chrome://branding/content/searchconfig.properties");
pref("browser.search.param.yahoo-fr", "moz2");
pref("browser.search.param.yahoo-fr-cjkt", "fx2-moz-1");
// search bar results always open in a new tab
pref("browser.search.openintab", false);

Просмотреть файл

@ -1421,24 +1421,35 @@ Engine.prototype = {
// We only support MozParams for appdir-shipped search engines
this._isInAppDir) {
var value;
// For now, we only support the "defaultEngine" condition.
if (param.getAttribute("condition") == "defaultEngine") {
const defPref = BROWSER_SEARCH_PREF + "defaultenginename";
var defaultPrefB = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefService).
getDefaultBranch(null);
const nsIPLS = Ci.nsIPrefLocalizedString;
var defaultName;
try {
defaultName = defaultPrefB.getComplexValue(defPref, nsIPLS).data;
} catch (ex) {}
switch (param.getAttribute("condition")) {
case "defaultEngine":
const defPref = BROWSER_SEARCH_PREF + "defaultenginename";
var defaultPrefB = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefService).
getDefaultBranch(null);
const nsIPLS = Ci.nsIPrefLocalizedString;
var defaultName;
try {
defaultName = defaultPrefB.getComplexValue(defPref, nsIPLS).data;
} catch (ex) {}
// If this engine was the default search engine, use the true value
if (this.name == defaultName)
value = param.getAttribute("trueValue");
else
value = param.getAttribute("falseValue");
url.addParam(param.getAttribute("name"), value);
// If this engine was the default search engine, use the true value
if (this.name == defaultName)
value = param.getAttribute("trueValue");
else
value = param.getAttribute("falseValue");
url.addParam(param.getAttribute("name"), value);
break;
case "pref":
try {
var prefB = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
value = prefB.getCharPref(BROWSER_SEARCH_PREF + "param." +
param.getAttribute("pref"));
url.addParam(param.getAttribute("name"), value);
} catch (e) { }
break;
}
}
}

Просмотреть файл

@ -1,14 +1,12 @@
<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/">
<ShortName>Yahoo</ShortName>
<Description>Yahoo Search</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16">data:image/x-icon;base64,R0lGODlhEAAQAJECAP8AAAAAAP///wAAACH5BAEAAAIALAAAAAAQABAAAAIplI+py+0NogQuyBDEnEd2kHkfFWUamEzmpZSfmaIHPHrRguUm/fT+UwAAOw==</Image>
<Url type="application/x-suggestions+json" method="GET"
template="http://ff.search.yahoo.com/gossip?output=fxjson&amp;command={searchTerms}" />
<Url type="text/html" method="GET" template="http://search.yahoo.com/search">
<Param name="p" value="{searchTerms}"/>
<Param name="ei" value="UTF-8"/>
<Param name="fr" value="moz2"/>
</Url>
<SearchForm>http://search.yahoo.com/</SearchForm>
<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/" xmlns:os="http://a9.com/-/spec/opensearchdescription/1.1/">
<os:ShortName>Yahoo</os:ShortName>
<os:Description>Yahoo Search</os:Description>
<os:InputEncoding>UTF-8</os:InputEncoding>
<SuggestionURL>http://ff.search.yahoo.com/gossip?output=fxjson&amp;command=</SuggestionURL>
<os:Image width="16" height="16">data:image/x-icon;base64,R0lGODlhEAAQAJECAP8AAAAAAP///wAAACH5BAEAAAIALAAAAAAQABAAAAIplI+py+0NogQuyBDEnEd2kHkfFWUamEzmpZSfmaIHPHrRguUm/fT+UwAAOw==</os:Image>
<os:Url type="text/html" method="GET" template="http://search.yahoo.com/search">
<os:Param name="p" value="{searchTerms}"/>
<os:Param name="ei" value="UTF-8"/>
<MozParam name="fr" condition="pref" pref="yahoo-fr" />
</os:Url>
</SearchPlugin>