| 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 0a8eceda68038529228c9528d0865793d0487c9a..75a761972aed69fb3aa286a3fc675291b637fe03 100644
|
| --- a/components/search_engines/template_url_service.cc
|
| +++ b/components/search_engines/template_url_service.cc
|
| @@ -343,7 +343,7 @@ base::string16 TemplateURLService::CleanUserInputKeyword(
|
| bool TemplateURLService::CanAddAutogeneratedKeyword(
|
| const base::string16& keyword,
|
| const GURL& url,
|
| - TemplateURL** template_url_to_replace) {
|
| + TemplateURL** template_url_to_replace) const {
|
| DCHECK(!keyword.empty()); // This should only be called for non-empty
|
| // keywords. If we need to support empty kewords
|
| // the code needs to change slightly.
|
| @@ -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);
|
| }
|
| @@ -395,7 +395,7 @@ void TemplateURLService::AddMatchingDomainKeywords(
|
| }
|
|
|
| TemplateURL* TemplateURLService::GetTemplateURLForKeyword(
|
| - const base::string16& keyword) {
|
| + const base::string16& keyword) const {
|
| KeywordToTURLAndMeaningfulLength::const_iterator elem(
|
| keyword_to_turl_and_length_.find(keyword));
|
| if (elem != keyword_to_turl_and_length_.end())
|
| @@ -407,7 +407,7 @@ TemplateURL* TemplateURLService::GetTemplateURLForKeyword(
|
| }
|
|
|
| TemplateURL* TemplateURLService::GetTemplateURLForGUID(
|
| - const std::string& sync_guid) {
|
| + const std::string& sync_guid) const {
|
| GUIDToTURL::const_iterator elem(guid_to_turl_.find(sync_guid));
|
| if (elem != guid_to_turl_.end())
|
| return elem->second;
|
| @@ -418,7 +418,7 @@ TemplateURL* TemplateURLService::GetTemplateURLForGUID(
|
| }
|
|
|
| TemplateURL* TemplateURLService::GetTemplateURLForHost(
|
| - const std::string& host) {
|
| + const std::string& host) const {
|
| if (loaded_)
|
| return provider_map_->GetTemplateURLForHost(host);
|
| TemplateURL* initial_dsp = initial_default_search_provider_.get();
|
| @@ -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;
|
| }
|
| @@ -849,7 +849,7 @@ void TemplateURLService::OnWebDataServiceRequestDone(
|
|
|
| base::string16 TemplateURLService::GetKeywordShortName(
|
| const base::string16& keyword,
|
| - bool* is_omnibox_api_extension_keyword) {
|
| + bool* is_omnibox_api_extension_keyword) const {
|
| const TemplateURL* template_url = GetTemplateURLForKeyword(keyword);
|
|
|
| // TODO(sky): Once LocationBarView adds a listener to the TemplateURLService
|
| @@ -1434,8 +1434,9 @@ void TemplateURLService::Init(const Initializer* initializers,
|
| RequestGoogleURLTrackerServerCheckIfNecessary();
|
| }
|
|
|
| -TemplateURL* TemplateURLService::BestEngineForKeyword(TemplateURL* engine1,
|
| - TemplateURL* engine2) {
|
| +TemplateURL* TemplateURLService::BestEngineForKeyword(
|
| + TemplateURL* engine1,
|
| + TemplateURL* engine2) const {
|
| DCHECK(engine1);
|
| DCHECK(engine2);
|
| CHECK_NE(engine1, engine2);
|
| @@ -1638,7 +1639,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;
|
| @@ -1649,12 +1650,12 @@ 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();
|
| }
|
|
|
| TemplateURL* TemplateURLService::FindNonExtensionTemplateURLForKeyword(
|
| - const base::string16& keyword) {
|
| + const base::string16& keyword) const {
|
| TemplateURL* keyword_turl = GetTemplateURLForKeyword(keyword);
|
| if (!keyword_turl || (keyword_turl->type() == TemplateURL::NORMAL))
|
| return keyword_turl;
|
| @@ -2288,9 +2289,10 @@ 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) {
|
| +bool TemplateURLService::IsLocalTemplateURLBetter(
|
| + const TemplateURL* local_turl,
|
| + const TemplateURL* sync_turl,
|
| + bool prefer_local_default) const {
|
| DCHECK(GetTemplateURLForGUID(local_turl->sync_guid()));
|
| return local_turl->last_modified() > sync_turl->last_modified() ||
|
| local_turl->created_by_policy() ||
|
| @@ -2504,7 +2506,7 @@ void TemplateURLService::AddMatchingKeywordsHelper(
|
| }
|
|
|
| TemplateURL* TemplateURLService::FindPrepopulatedTemplateURL(
|
| - int prepopulated_id) {
|
| + int prepopulated_id) const {
|
| for (const auto& turl : template_urls_) {
|
| if (turl->prepopulate_id() == prepopulated_id)
|
| return turl.get();
|
| @@ -2514,7 +2516,7 @@ TemplateURL* TemplateURLService::FindPrepopulatedTemplateURL(
|
|
|
| TemplateURL* TemplateURLService::FindTemplateURLForExtension(
|
| const std::string& extension_id,
|
| - TemplateURL::Type type) {
|
| + TemplateURL::Type type) const {
|
| DCHECK_NE(TemplateURL::NORMAL, type);
|
| for (const auto& turl : template_urls_) {
|
| if (turl->type() == type && turl->GetExtensionId() == extension_id)
|
| @@ -2524,7 +2526,7 @@ TemplateURL* TemplateURLService::FindTemplateURLForExtension(
|
| }
|
|
|
| TemplateURL* TemplateURLService::FindMatchingDefaultExtensionTemplateURL(
|
| - const TemplateURLData& data) {
|
| + const TemplateURLData& data) const {
|
| for (const auto& turl : template_urls_) {
|
| if (turl->type() == TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION &&
|
| turl->extension_info_->wants_to_be_default_engine &&
|
|
|