зеркало из https://github.com/mozilla/pjs.git
255394 - default search query parameter generation, r+sr=brendan@mozilla.org
This commit is contained in:
Родитель
d030ac5497
Коммит
c38f388c75
|
@ -102,7 +102,7 @@ pref("update.severity", 0);
|
|||
pref("update.extensions.count", 0);
|
||||
|
||||
pref("keyword.enabled", true);
|
||||
pref("keyword.URL", "http://www.google.com/search?btnI=I%27m+Feeling+Lucky&ie=UTF-8&oe=UTF-8&sourceid=mozilla-search&q=");
|
||||
pref("keyword.URL", "http://www.google.com/search?btnI=I%27m+Feeling+Lucky&ie=UTF-8&oe=UTF-8&q=");
|
||||
|
||||
pref("general.useragent.locale", "chrome://global/locale/intl.properties");
|
||||
pref("general.useragent.contentlocale", "chrome://browser-region/locale/region.properties");
|
||||
|
@ -154,6 +154,10 @@ pref("browser.search.defaultenginename", "chrome://browser-region/locale/region.
|
|||
// pointer to the Web Search url (content area context menu)
|
||||
pref("browser.search.defaulturl", "chrome://browser-region/locale/region.properties");
|
||||
|
||||
pref("browser.search.param.Google.1.name", "chrome://browser/content/searchconfig.properties");
|
||||
pref("browser.search.param.Google.1.custom", "chrome://browser/content/searchconfig.properties");
|
||||
pref("browser.search.param.Google.1.default", "chrome://browser/content/searchconfig.properties");
|
||||
|
||||
// basic search popup constraint: minimum sherlock plugin version displayed
|
||||
// (note: must be a string representation of a float or it'll default to 0.0)
|
||||
pref("browser.search.basic.min_ver", "0.0");
|
||||
|
|
|
@ -51,8 +51,8 @@ BEGIN
|
|||
ID_DDE_APPLICATION_NAME, "Firefox Debug"
|
||||
IDS_STARTMENU_APPNAME, "Firefox Debug"
|
||||
#else
|
||||
ID_DDE_APPLICATION_NAME, "Firefox"
|
||||
IDS_STARTMENU_APPNAME, "Firefox"
|
||||
ID_DDE_APPLICATION_NAME, "Firefox Debug"
|
||||
IDS_STARTMENU_APPNAME, "Firefox Debug"
|
||||
#endif
|
||||
END
|
||||
|
||||
|
|
|
@ -93,6 +93,17 @@
|
|||
var rEngine = this.RDF.GetResource(val);
|
||||
this.firstChild.setAttribute("src", this.readRDFString(rEngine, kNC_Icon));
|
||||
|
||||
const kNC_Name = this.RDF.GetResource("http://home.netscape.com/NC-rdf#Name");
|
||||
var pls = Components.classes["@mozilla.org/pref-localizedstring;1"]
|
||||
.createInstance(Components.interfaces.nsIPrefLocalizedString);
|
||||
pls.data = this.readRDFString(rEngine, kNC_Name);
|
||||
var PREF = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefService)
|
||||
.getBranch(null);
|
||||
PREF.setComplexValue("browser.search.selectedEngine",
|
||||
Components.interfaces.nsIPrefLocalizedString,
|
||||
pls);
|
||||
|
||||
]]></setter>
|
||||
</property>
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
# Do NOT localize or otherwise change these values
|
||||
browser.search.param.Google.1.name=client
|
||||
browser.search.param.Google.1.custom=firefox
|
||||
browser.search.param.Google.1.default=firefox
|
||||
browser.search.param.Google.release.name=rls
|
||||
browser.search.param.Google.release.value=org.mozilla:%S:unofficial
|
|
@ -24,6 +24,7 @@ browser.jar:
|
|||
* content/browser/pageReport.xul (content/pageReport.xul)
|
||||
* content/browser/pageReportFirstTime.xul (content/pageReportFirstTime.xul)
|
||||
* content/browser/search.xml (content/search.xml)
|
||||
* content/browser/searchconfig.properties (content/searchconfig.properties)
|
||||
* content/browser/setWallpaper.xul (content/setWallpaper.xul)
|
||||
* content/browser/utilityOverlay.js (content/utilityOverlay.js)
|
||||
* content/browser/web-panels.js (content/web-panels.js)
|
||||
|
|
|
@ -13,13 +13,13 @@ otherSearchURL=http://home.netscape.com/bookmark/6_0/tsearch.html
|
|||
# firefox.js
|
||||
browser.startup.homepage=http://www.mozilla.org/products/firefox/start/
|
||||
browser.throbber.url=http://www.mozilla.org/products/firefox/start/
|
||||
browser.search.defaulturl=http://www.google.com/search?lr=&sourceid=mozilla-search&ie=UTF-8&oe=UTF-8&q=
|
||||
browser.search.defaulturl=http://www.google.com/search?lr=&ie=UTF-8&oe=UTF-8&q=
|
||||
|
||||
#config.js
|
||||
startup.homepage_override_url=http://www.mozilla.org/products/firefox/start/
|
||||
|
||||
# search-panel.properties
|
||||
defaultSearchURL=http://www.google.com/search?hl=en&sourceid=mozilla-search&lr=&ie=UTF-8&oe=UTF-8&q=
|
||||
defaultSearchURL=http://www.google.com/search?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=
|
||||
browser.search.defaultenginename=Google
|
||||
|
||||
# update notifications: new update page
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
# XXXben todo: AB-CD substitution for language pack jar file!
|
||||
|
||||
browser.jar:
|
||||
+ content/browser/about.png (about.png)
|
||||
+ content/browser/aboutCredits.png (aboutCredits.png)
|
||||
+ content/browser/aboutFooter.png (aboutFooter.png)
|
||||
+ content/browser/searchconfig.properties (searchconfig.properties)
|
||||
|
||||
classic.jar:
|
||||
+ skin/classic/global/icons/alert-exclam.png (alert-exclam.png)
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
# Do NOT localize or otherwise change these values
|
||||
browser.search.param.Google.1.name=client
|
||||
browser.search.param.Google.1.custom=firefox
|
||||
browser.search.param.Google.1.default=firefox-a
|
||||
browser.search.param.Google.release.name=rls
|
||||
browser.search.param.Google.release.value=org.mozilla:%S:official
|
||||
|
|
@ -106,6 +106,9 @@ pref("browser.urlbar.clickSelectsAll", true);
|
|||
// when clickSelectsAll=true, does it also apply when the click is past end of text?
|
||||
pref("browser.urlbar.clickAtEndSelects", true);
|
||||
|
||||
pref("browser.search.param.Google.1.name", "chrome://navigator/content/searchconfig.properties");
|
||||
pref("browser.search.param.Google.1.custom", "chrome://navigator/content/searchconfig.properties");
|
||||
pref("browser.search.param.Google.1.default", "chrome://navigator/content/searchconfig.properties");
|
||||
|
||||
pref("browser.history.grouping", "day");
|
||||
pref("browser.sessionhistory.max_entries", 50);
|
||||
|
|
|
@ -28,6 +28,8 @@ comm.jar:
|
|||
content/navigator/viewPartialSource.js (resources/content/viewPartialSource.js)
|
||||
content/navigator/viewPartialSource.xul (resources/content/viewPartialSource.xul)
|
||||
content/navigator/mailNavigatorOverlay.xul (resources/content/mailNavigatorOverlay.xul)
|
||||
content/navigator/searchconfig.properties (resources/content/searchconfig.properties)
|
||||
|
||||
en-US.jar:
|
||||
* locale/en-US/navigator/contents.rdf (resources/locale/en-US/contents.rdf)
|
||||
locale/en-US/navigator/viewSource.dtd (resources/locale/en-US/viewSource.dtd)
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
# Do NOT localize or otherwise change these values
|
||||
browser.search.param.Google.1.name=client
|
||||
browser.search.param.Google.1.custom=mozilla
|
||||
browser.search.param.Google.1.default=mozilla
|
||||
browser.search.param.Google.release.name=rls
|
||||
browser.search.param.Google.release.value=org.mozilla:%S:unofficial
|
|
@ -1,29 +0,0 @@
|
|||
# Mozilla/Google plug-in by amitp+mozilla@google.com
|
||||
|
||||
<search
|
||||
name="Google"
|
||||
description="Google Search"
|
||||
method="GET"
|
||||
action="http://www.google.com/search"
|
||||
update="http://www.google.com/mozilla/google.src"
|
||||
updateCheckDays=1
|
||||
queryEncoding="utf-8"
|
||||
queryCharset="utf-8"
|
||||
>
|
||||
|
||||
<input name="q" user>
|
||||
<input name="sourceid" value="mozilla-search">
|
||||
<inputnext name="start" factor="10">
|
||||
<inputprev name="start" factor="10">
|
||||
<input name="ie" value="utf-8">
|
||||
<input name="oe" value="utf-8">
|
||||
|
||||
<interpret
|
||||
browserResultType="result"
|
||||
charset = "UTF-8"
|
||||
resultListStart="<!--a-->"
|
||||
resultListEnd="<!--z-->"
|
||||
resultItemStart="<!--m-->"
|
||||
resultItemEnd="<!--n-->"
|
||||
>
|
||||
</search>
|
|
@ -80,6 +80,7 @@
|
|||
#include "nsILocalFile.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIPrefLocalizedString.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
#include <Files.h>
|
||||
|
@ -102,8 +103,12 @@
|
|||
#define POSTHEADER_PREFIX "Content-type: application/x-www-form-urlencoded\r\nContent-Length: "
|
||||
#define POSTHEADER_SUFFIX "\r\n\r\n"
|
||||
#define SEARCH_PROPERTIES "chrome://communicator/locale/search/search-panel.properties"
|
||||
|
||||
|
||||
#ifdef MOZ_PHOENIX
|
||||
#define SEARCHCONFIG_PROPERTIES "chrome://browser/content/searchconfig.properties"
|
||||
#else
|
||||
#define SEARCHCONFIG_PROPERTIES "chrome://navigator/content/searchconfig.properties"
|
||||
#endif
|
||||
#define INTL_PROPERTIES "chrome://global/locale/intl.properties"
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kRDFContainerCID, NS_RDFCONTAINER_CID);
|
||||
|
@ -2616,12 +2621,14 @@ InternetSearchDataSource::GetInternetSearchURL(const char *searchEngineURI,
|
|||
}
|
||||
}
|
||||
|
||||
nsAutoString action, input, method, userVar;
|
||||
nsAutoString action, input, method, userVar, name;
|
||||
if (NS_FAILED(rv = GetData(dataUni, "search", 0, "action", action)))
|
||||
return(rv);
|
||||
if (NS_FAILED(rv = GetData(dataUni, "search", 0, "method", method)))
|
||||
return(rv);
|
||||
if (NS_FAILED(rv = GetInputs(dataUni, userVar, text, input, direction, pageNumber, whichButtons)))
|
||||
if (NS_FAILED(rv = GetData(dataUni, "search", 0, "name", name)))
|
||||
return(rv);
|
||||
if (NS_FAILED(rv = GetInputs(dataUni, name, userVar, text, input, direction, pageNumber, whichButtons)))
|
||||
return(rv);
|
||||
if (input.IsEmpty()) return(NS_ERROR_UNEXPECTED);
|
||||
|
||||
|
@ -2753,8 +2760,10 @@ InternetSearchDataSource::FindInternetSearchResults(const char *url, PRBool *sea
|
|||
searchURL.AssignWithConversion(url);
|
||||
|
||||
// look for query option which is the string the user is searching for
|
||||
nsAutoString userVar, inputUnused;
|
||||
if (NS_FAILED(rv = GetInputs(dataUni, userVar, EmptyString(), inputUnused, 0, 0, 0))) return(rv);
|
||||
nsAutoString userVar, inputUnused, engineNameStr;
|
||||
GetData(dataUni, "search", 0, "name", engineNameStr);
|
||||
|
||||
if (NS_FAILED(rv = GetInputs(dataUni, engineNameStr, userVar, nsAutoString(), inputUnused, 0, 0, 0))) return(rv);
|
||||
if (userVar.IsEmpty()) return(NS_RDF_NO_VALUE);
|
||||
|
||||
nsAutoString queryStr;
|
||||
|
@ -3894,7 +3903,10 @@ InternetSearchDataSource::DoSearch(nsIRDFResource *source, nsIRDFResource *engin
|
|||
|
||||
if (fullURL.IsEmpty() && methodStr.LowerCaseEqualsLiteral("get"))
|
||||
{
|
||||
if (NS_FAILED(rv = GetInputs(dataUni, userVar, textTemp, input, 0, 0, 0))) return(rv);
|
||||
nsAutoString engineNameStr;
|
||||
GetData(dataUni, "search", 0, "name", engineNameStr);
|
||||
|
||||
if (NS_FAILED(rv = GetInputs(dataUni, engineNameStr, userVar, textTemp, input, 0, 0, 0))) return(rv);
|
||||
if (input.IsEmpty()) return(NS_ERROR_UNEXPECTED);
|
||||
|
||||
// HTTP Get method support
|
||||
|
@ -4520,7 +4532,7 @@ InternetSearchDataSource::GetData(const PRUnichar *dataUni, const char *sectionT
|
|||
|
||||
|
||||
nsresult
|
||||
InternetSearchDataSource::GetInputs(const PRUnichar *dataUni, nsString &userVar,
|
||||
InternetSearchDataSource::GetInputs(const PRUnichar *dataUni, nsString &engineName, nsString &userVar,
|
||||
const nsString &text, nsString &input, PRInt16 direction, PRUint16 pageNumber, PRUint16 *whichButtons)
|
||||
{
|
||||
nsString buffer(dataUni);
|
||||
|
@ -4688,6 +4700,126 @@ InternetSearchDataSource::GetInputs(const PRUnichar *dataUni, nsString &userVar,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now add the default vs. non-default parameters, which come from
|
||||
// preferences and are part of the pre-configuration.
|
||||
nsCOMPtr<nsIPrefService> pserv(do_QueryInterface(prefs));
|
||||
if (pserv)
|
||||
{
|
||||
// If the pref "browser.search.defaultenginename" has a user value, that
|
||||
// means the user has changed the engine in the list. This implies that
|
||||
// the selected engine was _not_ configured as the default by the
|
||||
// distributor, because if the value of the pref matched, prefHasUserValue
|
||||
// would return false.
|
||||
PRBool engineIsNotDefault = PR_FALSE;
|
||||
nsCOMPtr<nsIPrefBranch> rootBranch(do_QueryInterface(pserv));
|
||||
nsCOMPtr<nsIPrefBranch> defaultBranch;
|
||||
pserv->GetDefaultBranch("", getter_AddRefs(defaultBranch));
|
||||
|
||||
if (defaultBranch)
|
||||
{
|
||||
nsXPIDLString defaultEngineNameStr;
|
||||
nsCOMPtr<nsIPrefLocalizedString> defaultEngineName;
|
||||
rv = defaultBranch->GetComplexValue("browser.search.defaultenginename",
|
||||
NS_GET_IID(nsIPrefLocalizedString),
|
||||
getter_AddRefs(defaultEngineName));
|
||||
defaultEngineName->GetData(getter_Copies(defaultEngineNameStr));
|
||||
|
||||
nsXPIDLString selectedEngineNameStr;
|
||||
nsCOMPtr<nsIPrefLocalizedString> selectedEngineName;
|
||||
rv = rootBranch->GetComplexValue("browser.search.selectedEngine",
|
||||
NS_GET_IID(nsIPrefLocalizedString),
|
||||
getter_AddRefs(selectedEngineName));
|
||||
selectedEngineName->GetData(getter_Copies(selectedEngineNameStr));
|
||||
|
||||
engineIsNotDefault = !defaultEngineNameStr.Equals(selectedEngineNameStr);
|
||||
}
|
||||
|
||||
PRInt32 i = 0;
|
||||
char prefNameBuf[1096];
|
||||
do
|
||||
{
|
||||
++i;
|
||||
sprintf(prefNameBuf, "browser.search.param.%s.%d.",
|
||||
NS_ConvertUCS2toUTF8(engineName).get(), i);
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> pb;
|
||||
rv = pserv->GetBranch(prefNameBuf, getter_AddRefs(pb));
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
nsCOMPtr<nsIPrefLocalizedString> parameterName;
|
||||
rv = pb->GetComplexValue("name",
|
||||
NS_GET_IID(nsIPrefLocalizedString),
|
||||
getter_AddRefs(parameterName));
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
nsXPIDLString parameterNameStr;
|
||||
parameterName->GetData(getter_Copies(parameterNameStr));
|
||||
|
||||
if (!parameterNameStr.IsEmpty())
|
||||
{
|
||||
if (!input.IsEmpty())
|
||||
input.Append(NS_LITERAL_STRING("&"));
|
||||
|
||||
input += parameterNameStr;
|
||||
|
||||
nsCOMPtr<nsIPrefLocalizedString> parameterValue;
|
||||
nsXPIDLString parameterValueStr;
|
||||
rv = pb->GetComplexValue(engineIsNotDefault ? "custom" : "default",
|
||||
NS_GET_IID(nsIPrefLocalizedString),
|
||||
getter_AddRefs(parameterValue));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
parameterValue->GetData(getter_Copies(parameterValueStr));
|
||||
|
||||
if (!parameterValueStr.IsEmpty())
|
||||
{
|
||||
input.Append(NS_LITERAL_STRING("="));
|
||||
input += parameterValueStr;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (1);
|
||||
|
||||
// Now add the release identifier
|
||||
nsCOMPtr<nsIStringBundleService> stringService(do_GetService(NS_STRINGBUNDLE_CONTRACTID));
|
||||
nsCOMPtr<nsIStringBundle> bundle;
|
||||
rv = stringService->CreateBundle(SEARCHCONFIG_PROPERTIES, getter_AddRefs(bundle));
|
||||
nsCOMPtr<nsIStringBundle> intlBundle;
|
||||
rv = stringService->CreateBundle(INTL_PROPERTIES, getter_AddRefs(intlBundle));
|
||||
|
||||
nsXPIDLString langName;
|
||||
intlBundle->GetStringFromName(NS_LITERAL_STRING("general.useragent.locale").get(),
|
||||
getter_Copies(langName));
|
||||
|
||||
nsAutoString keyTemplate(NS_LITERAL_STRING("browser.search.param."));
|
||||
keyTemplate += engineName;
|
||||
keyTemplate.Append(NS_LITERAL_STRING(".release."));
|
||||
|
||||
nsAutoString releaseNameKey = keyTemplate + NS_LITERAL_STRING("name");
|
||||
nsAutoString releaseValueKey = keyTemplate + NS_LITERAL_STRING("value");
|
||||
|
||||
nsXPIDLString releaseName, releaseValue;
|
||||
bundle->GetStringFromName(releaseNameKey.get(), getter_Copies(releaseName));
|
||||
const PRUnichar* strings[] = { langName.get() };
|
||||
bundle->FormatStringFromName(releaseValueKey.get(), strings, 1, getter_Copies(releaseValue));
|
||||
|
||||
if (!releaseName.IsEmpty())
|
||||
{
|
||||
if (!input.IsEmpty())
|
||||
input.Append(NS_LITERAL_STRING("&"));
|
||||
input += releaseName;
|
||||
|
||||
if (!releaseValue.IsEmpty())
|
||||
{
|
||||
input.Append(NS_LITERAL_STRING("="));
|
||||
input += releaseValue;
|
||||
}
|
||||
}
|
||||
rv = NS_OK;
|
||||
}
|
||||
|
||||
return(rv);
|
||||
}
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ friend int PR_CALLBACK searchModePrefCallback(const char *pref, void *aClosur
|
|||
nsresult DecodeData(const char *aCharset, const PRUnichar *aInString, PRUnichar **aOutString);
|
||||
nsresult GetData(const PRUnichar *data, const char *sectionToFind, PRUint32 sectionNum, const char *attribToFind, nsString &value);
|
||||
nsresult GetNumInterpretSections(const PRUnichar *data, PRUint32 &numInterpretSections);
|
||||
nsresult GetInputs(const PRUnichar *data, nsString &userVar, const nsString &text, nsString &input, PRInt16 direction, PRUint16 pageNumber, PRUint16 *whichButtons);
|
||||
nsresult GetInputs(const PRUnichar *data, nsString &engineName, nsString &userVar, const nsString &text, nsString &input, PRInt16 direction, PRUint16 pageNumber, PRUint16 *whichButtons);
|
||||
PRInt32 computeIndex(nsAutoString &factor, PRUint16 page, PRInt16 direction);
|
||||
nsresult GetURL(nsIRDFResource *source, nsIRDFLiteral** aResult);
|
||||
nsresult validateEngineNow(nsIRDFResource *engine);
|
||||
|
|
Загрузка…
Ссылка в новой задаче