Chromium Code Reviews| 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 ab0ba5766fbc705618980ded02603c0ab076ef00..e5a374b7b1ce753d310c5c8d547e0e8c90bfa892 100644 |
| --- a/components/search_engines/template_url_service.cc |
| +++ b/components/search_engines/template_url_service.cc |
| @@ -367,12 +367,12 @@ bool TemplateURLService::CanAddAutogeneratedKeyword( |
| } |
| bool TemplateURLService::IsPrepopulatedOrCreatedByPolicy( |
| - const TemplateURL* t_url) { |
| + const TemplateURL* t_url) const { |
| return (t_url->prepopulate_id() > 0 || t_url->created_by_policy()) && |
| t_url->SupportsReplacement(search_terms_data()); |
| } |
| -bool TemplateURLService::ShowInDefaultList(const TemplateURL* t_url) { |
| +bool TemplateURLService::ShowInDefaultList(const TemplateURL* t_url) const { |
| return t_url == default_search_provider_ || |
| IsPrepopulatedOrCreatedByPolicy(t_url); |
| } |
| @@ -570,7 +570,7 @@ void TemplateURLService::ResetTemplateURL(TemplateURL* url, |
| NotifyObservers(); |
| } |
| -bool TemplateURLService::CanMakeDefault(const TemplateURL* url) { |
| +bool TemplateURLService::CanMakeDefault(const TemplateURL* url) const { |
| return |
| ((default_search_provider_source_ == DefaultSearchManager::FROM_USER) || |
| (default_search_provider_source_ == |
| @@ -621,7 +621,7 @@ bool TemplateURLService::IsSearchResultsPageFromDefaultSearchProvider( |
| default_provider->IsSearchURL(url, search_terms_data()); |
| } |
| -bool TemplateURLService::IsExtensionControlledDefaultSearch() { |
| +bool TemplateURLService::IsExtensionControlledDefaultSearch() const { |
| return default_search_provider_source_ == |
| DefaultSearchManager::FROM_EXTENSION; |
| } |
| @@ -850,8 +850,9 @@ void TemplateURLService::OnWebDataServiceRequestDone( |
| base::string16 TemplateURLService::GetKeywordShortName( |
| const base::string16& keyword, |
| - bool* is_omnibox_api_extension_keyword) { |
| - const TemplateURL* template_url = GetTemplateURLForKeyword(keyword); |
| + bool* is_omnibox_api_extension_keyword) const { |
| + const TemplateURL* template_url = |
| + const_cast<TemplateURLService*>(this)->GetTemplateURLForKeyword(keyword); |
|
Peter Kasting
2017/04/13 22:42:52
If you're 100% sure you'll be able to convert thes
|
| // TODO(sky): Once LocationBarView adds a listener to the TemplateURLService |
| // to track changes to the model, this should become a DCHECK. |
| @@ -1629,7 +1630,7 @@ void TemplateURLService::ChangeToLoadedState() { |
| } |
| bool TemplateURLService::CanAddAutogeneratedKeywordForHost( |
| - const std::string& host) { |
| + const std::string& host) const { |
| const TemplateURLSet* urls = provider_map_->GetURLsForHost(host); |
| if (!urls) |
| return true; |
| @@ -1640,7 +1641,7 @@ bool TemplateURLService::CanAddAutogeneratedKeywordForHost( |
| return true; |
| } |
| -bool TemplateURLService::CanReplace(const TemplateURL* t_url) { |
| +bool TemplateURLService::CanReplace(const TemplateURL* t_url) const { |
| return !ShowInDefaultList(t_url) && t_url->safe_for_autoreplace(); |
| } |
| @@ -2230,10 +2231,14 @@ base::string16 TemplateURLService::UniquifyKeyword(const TemplateURL& turl, |
| return keyword_candidate; |
| } |
| -bool TemplateURLService::IsLocalTemplateURLBetter(const TemplateURL* local_turl, |
| - const TemplateURL* sync_turl, |
| - bool prefer_local_default) { |
| - DCHECK(GetTemplateURLForGUID(local_turl->sync_guid())); |
| +bool TemplateURLService::IsLocalTemplateURLBetter( |
| + const TemplateURL* local_turl, |
| + const TemplateURL* sync_turl, |
| + bool prefer_local_default) const { |
| + const TemplateURL* templateURL = |
|
Peter Kasting
2017/04/13 22:42:52
Nit: C++ variable names are lowercase, with unders
|
| + const_cast<TemplateURLService*>(this)->GetTemplateURLForGUID( |
| + local_turl->sync_guid()); |
| + DCHECK(templateURL); |
|
Peter Kasting
2017/04/13 22:42:52
Nit: While I'm normally fine with pulling temps ou
|
| return local_turl->last_modified() > sync_turl->last_modified() || |
| local_turl->created_by_policy() || |
| (prefer_local_default && local_turl == GetDefaultSearchProvider()); |