summaryrefslogtreecommitdiffstats
path: root/chrome/browser/search_engines
diff options
context:
space:
mode:
authormirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-20 22:08:50 +0000
committermirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-20 22:08:50 +0000
commit163cf4a0682a5e32f9db5e413dab296f17027015 (patch)
treea07752ade09851fb7aeb38e1b11fb0d84ac954da /chrome/browser/search_engines
parent541b8ce2a4aa437fb73b805ec7c351cfad7a6050 (diff)
downloadchromium_src-163cf4a0682a5e32f9db5e413dab296f17027015.zip
chromium_src-163cf4a0682a5e32f9db5e413dab296f17027015.tar.gz
chromium_src-163cf4a0682a5e32f9db5e413dab296f17027015.tar.bz2
1. Add more search engine types.
2. Change "GetSearchEngineType" function to use the short name to get the search engine type if we can't choose by prepopulate_id. 3. Disable the close button. (Next CL will remove it, if possible, but this requires adding a method to window_delegate.h). 4. Close the search engine view immediately if the user launches the keyword editor view. Pass the SearchEngineViewObserver object (the FirstRunView) to the keyword editor, who will call back to the waiting observer when closed. BUG= none TEST= none Review URL: http://codereview.chromium.org/1539044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45092 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/search_engines')
-rw-r--r--chrome/browser/search_engines/template_url_model.cc12
-rw-r--r--chrome/browser/search_engines/template_url_prepopulate_data.cc12
-rw-r--r--chrome/browser/search_engines/template_url_prepopulate_data.h8
3 files changed, 26 insertions, 6 deletions
diff --git a/chrome/browser/search_engines/template_url_model.cc b/chrome/browser/search_engines/template_url_model.cc
index 0f3b6f3..d6a8171 100644
--- a/chrome/browser/search_engines/template_url_model.cc
+++ b/chrome/browser/search_engines/template_url_model.cc
@@ -801,6 +801,10 @@ void TemplateURLModel::SaveDefaultSearchProviderToPrefs(
t_url ? Int64ToWString(t_url->id()) : std::wstring();
prefs->SetString(prefs::kDefaultSearchProviderID, id_string);
+ const std::wstring prepopulate_id =
+ t_url ? Int64ToWString(t_url->prepopulate_id()) : std::wstring();
+ prefs->SetString(prefs::kDefaultSearchProviderPrepopulateID, prepopulate_id);
+
prefs->ScheduleSavePersistentPrefs();
}
@@ -830,12 +834,18 @@ bool TemplateURLModel::LoadDefaultSearchProviderFromPrefs(
std::wstring id_string = prefs->GetString(prefs::kDefaultSearchProviderID);
+ std::wstring prepopulate_id =
+ prefs->GetString(prefs::kDefaultSearchProviderPrepopulateID);
+
*default_provider = new TemplateURL();
(*default_provider)->set_short_name(name);
(*default_provider)->SetURL(search_url, 0, 0);
(*default_provider)->SetSuggestionsURL(suggest_url, 0, 0);
if (!id_string.empty())
(*default_provider)->set_id(StringToInt64(WideToUTF16Hack(id_string)));
+ if (!prepopulate_id.empty())
+ (*default_provider)->set_prepopulate_id(StringToInt(WideToUTF16Hack(
+ prepopulate_id)));
return true;
}
@@ -847,6 +857,8 @@ void TemplateURLModel::RegisterPrefs(PrefService* prefs) {
prefs->RegisterStringPref(
prefs::kDefaultSearchProviderID, std::wstring());
prefs->RegisterStringPref(
+ prefs::kDefaultSearchProviderPrepopulateID, std::wstring());
+ prefs->RegisterStringPref(
prefs::kDefaultSearchProviderSuggestURL, std::wstring());
prefs->RegisterStringPref(
prefs::kDefaultSearchProviderSearchURL, std::wstring());
diff --git a/chrome/browser/search_engines/template_url_prepopulate_data.cc b/chrome/browser/search_engines/template_url_prepopulate_data.cc
index 7688150..445381a 100644
--- a/chrome/browser/search_engines/template_url_prepopulate_data.cc
+++ b/chrome/browser/search_engines/template_url_prepopulate_data.cc
@@ -2284,7 +2284,7 @@ int CountryCharsToCountryIDWithUpdate(char c1, char c2) {
#if defined(OS_WIN)
// For reference, a list of GeoIDs can be found at
-// http://msdn.microsoft.com/en-us/library/ms776390.aspx .
+// http://msdn.microsoft.com/en-us/library/dd374073.aspx .
int GeoIDToCountryID(GEOID geo_id) {
const int kISOBufferSize = 3; // Two plus one for the terminator.
wchar_t isobuf[kISOBufferSize] = { 0 };
@@ -2829,12 +2829,14 @@ void GetPrepopulatedEngines(PrefService* prefs,
}
}
-UMASearchEngineType GetSearchEngineType(const TemplateURL* search_engine) {
+SearchEngineType GetSearchEngineType(const TemplateURL* search_engine) {
switch (search_engine->prepopulate_id()) {
case 1:
return SEARCH_ENGINE_GOOGLE;
case 2:
- return SEARCH_ENGINE_YAHOO;
+ // Construction of country id = 'J' << 8 | 'P' = 19024
+ return (GetCountryIDFromPrefs(NULL) == 19024) ? SEARCH_ENGINE_YAHOOJP :
+ SEARCH_ENGINE_YAHOO;
case 3:
return SEARCH_ENGINE_BING;
case 4:
@@ -2845,6 +2847,8 @@ UMASearchEngineType GetSearchEngineType(const TemplateURL* search_engine) {
return SEARCH_ENGINE_SEZNAM;
case 26:
return SEARCH_ENGINE_CENTRUM;
+ case 30:
+ return SEARCH_ENGINE_NETSPRINT;
case 62:
return SEARCH_ENGINE_VIRGILIO;
case 83:
@@ -2854,4 +2858,6 @@ UMASearchEngineType GetSearchEngineType(const TemplateURL* search_engine) {
}
}
+
+
} // namespace TemplateURLPrepopulateData
diff --git a/chrome/browser/search_engines/template_url_prepopulate_data.h b/chrome/browser/search_engines/template_url_prepopulate_data.h
index d53934b..c0a7adb 100644
--- a/chrome/browser/search_engines/template_url_prepopulate_data.h
+++ b/chrome/browser/search_engines/template_url_prepopulate_data.h
@@ -13,17 +13,19 @@ class TemplateURL;
namespace TemplateURLPrepopulateData {
// Enum to record the user's default search engine choice in UMA:
-enum UMASearchEngineType {
+enum SearchEngineType {
SEARCH_ENGINE_OTHER = 0, // At the top in case of future list changes.
SEARCH_ENGINE_GOOGLE,
SEARCH_ENGINE_YAHOO,
+ SEARCH_ENGINE_YAHOOJP,
SEARCH_ENGINE_BING,
SEARCH_ENGINE_ASK,
SEARCH_ENGINE_YANDEX,
- SEARCH_ENGINE_MAILRU,
SEARCH_ENGINE_SEZNAM,
SEARCH_ENGINE_CENTRUM,
+ SEARCH_ENGINE_NETSPRINT,
SEARCH_ENGINE_VIRGILIO,
+ SEARCH_ENGINE_MAILRU,
SEARCH_ENGINE_MAX // Bounding max value needed for UMA histogram macro.
};
@@ -47,7 +49,7 @@ void GetPrepopulatedEngines(PrefService* prefs,
// for a small set of search engines, we use this simple switch statement
// instead of embedding a UMA type as part of the struct of every search
// engine.
-UMASearchEngineType GetSearchEngineType(const TemplateURL* search_engine);
+SearchEngineType GetSearchEngineType(const TemplateURL* search_engine);
} // namespace TemplateURLPrepopulateData