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))); |
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) { |