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

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: Rebase and switch to a simple getter. Created 8 years, 4 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 acd3089701c70accc981e12cdad80915b2971c9b..7b42bd7b040eebf21f17db15b580b9df9bcea104 100644
--- a/chrome/browser/search_engines/template_url_prepopulate_data.cc
+++ b/chrome/browser/search_engines/template_url_prepopulate_data.cc
@@ -3285,6 +3285,18 @@ void GetPrepopulationSetFromCountryID(PrefService* prefs,
}
}
Peter Kasting 2012/08/28 00:04:07 Nit: Two blank lines above these section dividers
samarth 2012/08/28 16:18:15 Done.
+// 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
Peter Kasting 2012/08/28 00:04:07 Nit: Can you add a ////////// nameless divider her
samarth 2012/08/28 16:18:15 Done.
namespace TemplateURLPrepopulateData {
@@ -3364,17 +3376,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 +3482,34 @@ SearchEngineType GetEngineType(const std::string& url) {
return SEARCH_ENGINE_OTHER;
}
+GURL GetLogoURL(const std::string& url) {
+ // Restricted to UI thread because GetEngineType() is so restricted.
msw 2012/08/27 21:57:26 nit: There doesn't seem to be much value in DCHECK
samarth 2012/08/28 16:18:15 Done.
+ using content::BrowserThread;
+ DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) ||
+ BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ switch (GetEngineType(url)) {
Peter Kasting 2012/08/28 00:04:07 Nit: For now, use "if (GetEngineType(url) == SEARC
samarth 2012/08/28 16:18:15 Done.
+ case SEARCH_ENGINE_GOOGLE:
+ return GURL(google_logos.logo_100_percent_url);
+ default:
+ return GURL("");
msw 2012/08/27 21:57:26 nit: remove empty string literal.
samarth 2012/08/28 16:18:15 Done.
+ }
+}
msw 2012/08/27 21:57:26 nit: some compilers may complain about not all pat
samarth 2012/08/28 16:18:15 Done.
+
+GURL GetLogo200PercentURL(const std::string& url) {
+ // Restricted to UI thread because GetEngineType() is so restricted.
msw 2012/08/27 21:57:26 ditto: (nit: remove DCHECKs)
samarth 2012/08/28 16:18:15 Done.
+ using content::BrowserThread;
+ DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) ||
+ BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ switch (GetEngineType(url)) {
+ case SEARCH_ENGINE_GOOGLE:
+ return GURL(google_logos.logo_200_percent_url);
+ default:
+ return GURL("");
msw 2012/08/27 21:57:26 ditto (nit: remove empty string literal)
samarth 2012/08/28 16:18:15 Done.
+ }
+}
msw 2012/08/27 21:57:26 ditto (nit: return GURL() here)
samarth 2012/08/28 16:18:15 Done.
+
#if defined(OS_ANDROID)
void InitCountryCode(const std::string& country_code) {

Powered by Google App Engine
This is Rietveld 408576698