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

Unified Diff: components/search_engines/template_url_service.cc

Issue 2347973002: Enable Chrome to tweak search engines for some locales (Closed)
Patch Set: comments Created 4 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: components/search_engines/template_url_service.cc
diff --git a/components/search_engines/template_url_service.cc b/components/search_engines/template_url_service.cc
index 18f5d5585c522b8d9e45da6c5214531c89da3dc4..ecbe946c6ce75e0ff1c3bf88ef84fbfed8a4616c 100644
--- a/components/search_engines/template_url_service.cc
+++ b/components/search_engines/template_url_service.cc
@@ -189,6 +189,12 @@ bool Contains(TemplateURLService::OwnedTemplateURLVector* template_urls,
return FindTemplateURL(template_urls, turl) != template_urls->end();
}
+bool IsCreatedByExtension(TemplateURL* template_url) {
+ return template_url->GetType() ==
+ TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION ||
+ template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION;
+}
+
} // namespace
// TemplateURLService::LessWithPrefix -----------------------------------------
@@ -610,7 +616,7 @@ void TemplateURLService::SetUserSelectedDefaultSearchProvider(
// Omnibox keywords cannot be made default. Extension-controlled search
// engines can be made default only by the extension itself because they
// aren't persisted.
- DCHECK(!url || (url->GetType() == TemplateURL::NORMAL));
+ DCHECK(!url || (!IsCreatedByExtension(url)));
Peter Kasting 2016/09/19 21:06:24 Nit: Extra parens
Ian Wen 2016/09/20 04:48:04 Done.
if (load_failed_) {
// Skip the DefaultSearchManager, which will persist to user preferences.
if ((default_search_provider_source_ == DefaultSearchManager::FROM_USER) ||
@@ -2021,8 +2027,8 @@ TemplateURL* TemplateURLService::AddNoNotify(
DCHECK_NE(existing_keyword_turl, template_url.get());
// Only replace one of the TemplateURLs if they are either both extensions,
// or both not extensions.
- bool are_same_type = existing_keyword_turl->GetType() ==
- template_url->GetType();
+ bool are_same_type = IsCreatedByExtension(existing_keyword_turl) ==
+ IsCreatedByExtension(template_url.get());
if (CanReplace(existing_keyword_turl) && are_same_type) {
RemoveNoNotify(existing_keyword_turl);
} else if (CanReplace(template_url.get()) && are_same_type) {

Powered by Google App Engine
This is Rietveld 408576698