| 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..a4db5e184d0ef54d3414597f5e1c4564a867d66e 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,11 @@ 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 {
|
| + // TODO(jeffschiller): Make GetTemplateURLForKeyword const and remove the
|
| + // const_cast.
|
| + const TemplateURL* template_url =
|
| + const_cast<TemplateURLService*>(this)->GetTemplateURLForKeyword(keyword);
|
|
|
| // TODO(sky): Once LocationBarView adds a listener to the TemplateURLService
|
| // to track changes to the model, this should become a DCHECK.
|
| @@ -1629,7 +1632,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 +1643,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 +2233,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 {
|
| + // TODO(jeffschiller): Make GetTemplateURLForKeyword const and remove the
|
| + // const_cast.
|
| + DCHECK(const_cast<TemplateURLService*>(this)->GetTemplateURLForGUID(
|
| + local_turl->sync_guid()));
|
| return local_turl->last_modified() > sync_turl->last_modified() ||
|
| local_turl->created_by_policy() ||
|
| (prefer_local_default && local_turl == GetDefaultSearchProvider());
|
|
|