diff options
author | mirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-27 15:53:46 +0000 |
---|---|---|
committer | mirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-27 15:53:46 +0000 |
commit | 0339765bba60104c098aeacc02f10ae629f4a494 (patch) | |
tree | 4973928039ece8f4ba9f8a5631ced5559a7561cc /chrome/browser/search_engines | |
parent | e94f1860db455c3af9e8e245505b2335e5cf1be5 (diff) | |
download | chromium_src-0339765bba60104c098aeacc02f10ae629f4a494.zip chromium_src-0339765bba60104c098aeacc02f10ae629f4a494.tar.gz chromium_src-0339765bba60104c098aeacc02f10ae629f4a494.tar.bz2 |
Add logo display for fourth search engine in search engine selection dialog.
BUG=57993
TEST=Set the search engine on your (non-Chrome) default browser to be NOT in the top three for your region.
For USA, for example, you could use Baidu or Aol Search. Start Chrome with --first-run switch on an empty profile.
You should see the fourth search engine selection represented by a logo, not just text (if it's included in the list of logos for which we have images).
Review URL: http://codereview.chromium.org/4109001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64074 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/search_engines')
5 files changed, 65 insertions, 33 deletions
diff --git a/chrome/browser/search_engines/search_engine_type.h b/chrome/browser/search_engines/search_engine_type.h index 1f4b511..7e4dfd1 100644 --- a/chrome/browser/search_engines/search_engine_type.h +++ b/chrome/browser/search_engines/search_engine_type.h @@ -6,6 +6,9 @@ #define CHROME_BROWSER_SEARCH_ENGINES_SEARCH_ENGINE_TYPE_H_ #pragma once +// Fills logo slot for search engines with no logo available. +static const int kNoSearchEngineLogo = 0; + // Enum to record the user's default search engine choice in UMA. Add new // search engines at the bottom and do not delete from this list, so as not // to disrupt UMA data already recorded. diff --git a/chrome/browser/search_engines/template_url.cc b/chrome/browser/search_engines/template_url.cc index a4fe820..48f5d7d 100644 --- a/chrome/browser/search_engines/template_url.cc +++ b/chrome/browser/search_engines/template_url.cc @@ -10,6 +10,7 @@ #include "base/logging.h" #include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/search_engines/search_engine_type.h" #include "chrome/browser/search_engines/search_terms_data.h" #include "chrome/browser/search_engines/template_url_model.h" #include "chrome/common/url_constants.h" @@ -569,7 +570,7 @@ TemplateURL::TemplateURL() created_by_policy_(false), usage_count_(0), search_engine_type_(SEARCH_ENGINE_OTHER), - logo_id_(0), + logo_id_(kNoSearchEngineLogo), prepopulate_id_(0) { } diff --git a/chrome/browser/search_engines/template_url_prepopulate_data.cc b/chrome/browser/search_engines/template_url_prepopulate_data.cc index 13a01b2..2313d8a 100644 --- a/chrome/browser/search_engines/template_url_prepopulate_data.cc +++ b/chrome/browser/search_engines/template_url_prepopulate_data.cc @@ -143,7 +143,7 @@ const PrepopulatedEngine aol = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + IDR_SEARCH_ENGINE_LOGO_AOL, 35, }; @@ -156,7 +156,7 @@ const PrepopulatedEngine araby = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 12, }; @@ -247,7 +247,7 @@ const PrepopulatedEngine atlas_cz = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 27, }; @@ -260,7 +260,7 @@ const PrepopulatedEngine atlas_sk = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 27, }; @@ -1119,7 +1119,7 @@ const PrepopulatedEngine eniro_fi = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 29, }; @@ -1132,7 +1132,7 @@ const PrepopulatedEngine eniro_se = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 29, }; @@ -1145,7 +1145,7 @@ const PrepopulatedEngine fonecta_02_fi = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 46, }; @@ -1159,7 +1159,7 @@ const PrepopulatedEngine go = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 40, }; @@ -1201,7 +1201,7 @@ const PrepopulatedEngine guruji = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 38, }; @@ -1214,7 +1214,7 @@ const PrepopulatedEngine hispavista = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 18, }; @@ -1240,7 +1240,7 @@ const PrepopulatedEngine jabse = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 19, }; @@ -1253,7 +1253,7 @@ const PrepopulatedEngine jubii = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 28, }; @@ -1266,7 +1266,7 @@ const PrepopulatedEngine kvasir = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 73, }; @@ -1279,7 +1279,7 @@ const PrepopulatedEngine latne = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 71, }; @@ -1292,7 +1292,7 @@ const PrepopulatedEngine leit = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 59, }; @@ -1305,7 +1305,7 @@ const PrepopulatedEngine libero = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 63, }; @@ -1331,7 +1331,7 @@ const PrepopulatedEngine maktoob = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 13, }; @@ -1344,7 +1344,7 @@ const PrepopulatedEngine masrawy = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 14, }; @@ -1357,7 +1357,7 @@ const PrepopulatedEngine mynet = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 101, }; @@ -1383,7 +1383,7 @@ const PrepopulatedEngine nate = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 69, }; @@ -1437,7 +1437,7 @@ const PrepopulatedEngine nur_kz = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 20, }; @@ -1463,7 +1463,7 @@ const PrepopulatedEngine onet = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 75, }; @@ -1541,7 +1541,7 @@ const PrepopulatedEngine rediff = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 37, }; @@ -1554,7 +1554,7 @@ const PrepopulatedEngine rednano = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 41, }; @@ -1593,7 +1593,7 @@ const PrepopulatedEngine search_de_CH = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 51, }; @@ -1606,7 +1606,7 @@ const PrepopulatedEngine search_fr_CH = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 22, }; @@ -1633,7 +1633,7 @@ const PrepopulatedEngine spray = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 99, }; @@ -1646,7 +1646,7 @@ const PrepopulatedEngine terra_ar = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 90, }; @@ -1659,7 +1659,7 @@ const PrepopulatedEngine terra_es = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 90, }; @@ -1685,7 +1685,7 @@ const PrepopulatedEngine uol = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 82, }; @@ -1724,7 +1724,7 @@ const PrepopulatedEngine wp = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 76, }; @@ -2287,7 +2287,7 @@ const PrepopulatedEngine yamli = { NULL, NULL, SEARCH_ENGINE_OTHER, - IDR_SEARCH_ENGINE_LOGO_OTHER, + kNoSearchEngineLogo, 11, }; @@ -3559,4 +3559,15 @@ TemplateURL* GetEngineForOrigin(PrefService* prefs, const GURL& url_to_find) { return NULL; } +int GetSearchEngineLogo(const GURL& url_to_find) { + GURL origin_to_find = url_to_find.GetOrigin(); + for (size_t i = 0; i < arraysize(kAllEngines); ++i) { + std::string url_utf8_string(ToUTF8(kAllEngines[i]->search_url)); + GURL url(url_utf8_string); + if (origin_to_find == url.GetOrigin()) + return kAllEngines[i]->logo_id; + } + return kNoSearchEngineLogo; +} + } // 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 8b143fe8..f8b721a 100644 --- a/chrome/browser/search_engines/template_url_prepopulate_data.h +++ b/chrome/browser/search_engines/template_url_prepopulate_data.h @@ -38,6 +38,9 @@ TemplateURL* GetPrepopulatedDefaultSearch(PrefService* prefs); // TemplateURL. TemplateURL* GetEngineForOrigin(PrefService* prefs, const GURL& url_to_find); +// Returns search engine logo for URLs known to have a search engine logo. +int GetSearchEngineLogo(const GURL& url_to_find); + } // namespace TemplateURLPrepopulateData #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_PREPOPULATE_DATA_H_ diff --git a/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc b/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc index c584747..5275146 100644 --- a/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc +++ b/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc @@ -13,6 +13,7 @@ #include "chrome/browser/search_engines/template_url_model.h" #include "chrome/common/pref_names.h" #include "chrome/test/testing_profile.h" +#include "grit/theme_resources.h" #include "testing/gtest/include/gtest/gtest.h" typedef testing::Test TemplateURLPrepopulateDataTest; @@ -178,3 +179,16 @@ TEST_F(TemplateURLPrepopulateDataTest, SearchEngineFromOrigin) { profile.GetPrefs(), not_a_search_engine)); } + +TEST_F(TemplateURLPrepopulateDataTest, GetSearchEngineLogo) { + GURL bad_engine("http://example.com/"); + EXPECT_EQ(kNoSearchEngineLogo, + TemplateURLPrepopulateData::GetSearchEngineLogo(bad_engine)); + GURL engine_with_logo("http://www.ask.com/"); + EXPECT_EQ(IDR_SEARCH_ENGINE_LOGO_ASK, + TemplateURLPrepopulateData::GetSearchEngineLogo(engine_with_logo)); + GURL engine_no_logo("http://araby.com/"); + EXPECT_EQ(kNoSearchEngineLogo, + TemplateURLPrepopulateData::GetSearchEngineLogo(engine_no_logo)); + +} |