Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6178)

Unified Diff: chrome/browser/search_engines/template_url_prepopulate_data.cc

Issue 10828401: Add a getter for search provider logos. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix bad merge. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/search_engines/template_url_prepopulate_data.cc
diff --git a/chrome/browser/search_engines/template_url_prepopulate_data.cc b/chrome/browser/search_engines/template_url_prepopulate_data.cc
index c3985ca0504766143d8b951741331b9b9bc2bd9f..2acfab305541bc3e42e121edd3acf5c97495a804 100644
--- a/chrome/browser/search_engines/template_url_prepopulate_data.cc
+++ b/chrome/browser/search_engines/template_url_prepopulate_data.cc
@@ -3285,6 +3285,22 @@ void GetPrepopulationSetFromCountryID(PrefService* prefs,
}
}
+
+// Logo URLs ///////////////////////////////////////////////////////////////////
+
+struct LogoURLs {
+ const char* const logo_100_percent_url;
+ const char* const logo_200_percent_url;
+};
+
+const LogoURLs google_logos = {
+ "https://www.google.com/images/chrome_search/google_logo.png",
+ "https://www.google.com/images/chrome_search/google_logo_2x.png",
+};
+
+
+////////////////////////////////////////////////////////////////////////////////
+
} // namespace
namespace TemplateURLPrepopulateData {
@@ -3364,17 +3380,16 @@ void GetPrepopulatedTemplateFromPrefs(Profile* profile,
size_t num_engines = list->GetSize();
for (size_t i = 0; i != num_engines; ++i) {
- const Value* val;
const DictionaryValue* engine;
if (list->GetDictionary(i, &engine) &&
- engine->Get("name", &val) && val->GetAsString(&name) &&
- engine->Get("keyword", &val) && val->GetAsString(&keyword) &&
- engine->Get("search_url", &val) && val->GetAsString(&search_url) &&
- engine->Get("suggest_url", &val) && val->GetAsString(&suggest_url) &&
- engine->Get("instant_url", &val) && val->GetAsString(&instant_url) &&
- engine->Get("favicon_url", &val) && val->GetAsString(&favicon_url) &&
- engine->Get("encoding", &val) && val->GetAsString(&encoding) &&
- engine->Get("id", &val) && val->GetAsInteger(&id)) {
+ engine->GetString("name", &name) &&
+ engine->GetString("keyword", &keyword) &&
+ engine->GetString("search_url", &search_url) &&
+ engine->GetString("suggest_url", &suggest_url) &&
+ engine->GetString("instant_url", &instant_url) &&
+ engine->GetString("favicon_url", &favicon_url) &&
+ engine->GetString("encoding", &encoding) &&
+ engine->GetInteger("id", &id)) {
// These next fields are not allowed to be empty.
if (name.empty() || keyword.empty() || search_url.empty() ||
favicon_url.empty() || encoding.empty())
@@ -3471,6 +3486,15 @@ SearchEngineType GetEngineType(const std::string& url) {
return SEARCH_ENGINE_OTHER;
}
+GURL GetLogoURL(const TemplateURL& template_url, LogoSize size) {
+ if (GetEngineType(template_url.url()) == SEARCH_ENGINE_GOOGLE) {
+ return GURL((size == LOGO_200_PERCENT) ?
+ google_logos.logo_200_percent_url :
+ google_logos.logo_100_percent_url);
+ }
+ return GURL();
+}
+
#if defined(OS_ANDROID)
void InitCountryCode(const std::string& country_code) {

Powered by Google App Engine
This is Rietveld 408576698