Chromium Code Reviews| Index: components/search_engines/template_url_service.h |
| diff --git a/components/search_engines/template_url_service.h b/components/search_engines/template_url_service.h |
| index b6bb73ba756d105b27c0ee507d6200176a40e3f3..09c36f1a3b034c1b8af1c695e348751ba4a7bf83 100644 |
| --- a/components/search_engines/template_url_service.h |
| +++ b/components/search_engines/template_url_service.h |
| @@ -131,18 +131,18 @@ class TemplateURLService : public WebDataServiceConsumer, |
| // a keyword for hosts already associated with a manually-edited keyword. |
| bool CanAddAutogeneratedKeyword(const base::string16& keyword, |
| const GURL& url, |
| - TemplateURL** template_url_to_replace); |
| + TemplateURL** template_url_to_replace) const; |
| // Returns whether the engine is a "pre-existing" engine, either from the |
| // prepopulate list or created by policy. |
| - bool IsPrepopulatedOrCreatedByPolicy(const TemplateURL* template_url); |
| + bool IsPrepopulatedOrCreatedByPolicy(const TemplateURL* template_url) const; |
| // Returns whether |template_url| should be shown in the list of engines |
| // most likely to be selected as a default engine. This is meant to highlight |
| // the current default, as well as the other most likely choices of default |
| // engine, separately from a full list of all TemplateURLs (which might be |
| // very long). |
| - bool ShowInDefaultList(const TemplateURL* template_url); |
| + bool ShowInDefaultList(const TemplateURL* template_url) const; |
| // Adds to |matches| all TemplateURLs whose keywords begin with |prefix|, |
| // sorted shortest-keyword-first. If |supports_replacement_only| is true, only |
| @@ -166,16 +166,16 @@ class TemplateURLService : public WebDataServiceConsumer, |
| // the keyword was not found. |
| // The caller should not try to delete the returned pointer; the data store |
| // retains ownership of it. |
| - TemplateURL* GetTemplateURLForKeyword(const base::string16& keyword); |
| + TemplateURL* GetTemplateURLForKeyword(const base::string16& keyword) const; |
|
Peter Kasting
2017/04/13 04:04:52
Const methods shouldn't return non-const pointers,
|
| // Returns that TemplateURL with the specified GUID, or NULL if not found. |
| // The caller should not try to delete the returned pointer; the data store |
| // retains ownership of it. |
| - TemplateURL* GetTemplateURLForGUID(const std::string& sync_guid); |
| + TemplateURL* GetTemplateURLForGUID(const std::string& sync_guid) const; |
| // Returns the first TemplateURL found with a URL using the specified |host|, |
| // or NULL if there are no such TemplateURLs |
| - TemplateURL* GetTemplateURLForHost(const std::string& host); |
| + TemplateURL* GetTemplateURLForHost(const std::string& host) const; |
| // Adds |template_url| to this model. Returns a raw pointer to |template_url| |
| // if the addition succeeded, or null on failure. (Many callers need still |
| @@ -248,7 +248,7 @@ class TemplateURLService : public WebDataServiceConsumer, |
| // Return true if the given |url| can be made the default. This returns false |
| // regardless of |url| if the default search provider is managed by policy or |
| // controlled by an extension. |
| - bool CanMakeDefault(const TemplateURL* url); |
| + bool CanMakeDefault(const TemplateURL* url) const; |
| // Set the default search provider. |url| may be null. |
| // This will assert if the default search is managed; the UI should not be |
| @@ -274,7 +274,7 @@ class TemplateURLService : public WebDataServiceConsumer, |
| } |
| // Returns true if the default search provider is controlled by an extension. |
| - bool IsExtensionControlledDefaultSearch(); |
| + bool IsExtensionControlledDefaultSearch() const; |
| // Returns the default search specified in the prepopulated data, if it |
| // exists. If not, returns first URL in |template_urls_|, or NULL if that's |
| @@ -330,8 +330,9 @@ class TemplateURLService : public WebDataServiceConsumer, |
| // Returns the locale-direction-adjusted short name for the given keyword. |
| // Also sets the out param to indicate whether the keyword belongs to an |
| // Omnibox extension. |
| - base::string16 GetKeywordShortName(const base::string16& keyword, |
| - bool* is_omnibox_api_extension_keyword); |
| + base::string16 GetKeywordShortName( |
| + const base::string16& keyword, |
| + bool* is_omnibox_api_extension_keyword) const; |
| // Called by the history service when a URL is visited. |
| void OnHistoryURLVisited(const URLVisitedDetails& details); |
| @@ -493,7 +494,8 @@ class TemplateURLService : public WebDataServiceConsumer, |
| // override extension-controlled engines, which override normal engines; if |
| // there is still a conflict after this, the most recently-added extension |
| // wins. |
| - TemplateURL* BestEngineForKeyword(TemplateURL* engine1, TemplateURL* engine2); |
| + TemplateURL* BestEngineForKeyword(TemplateURL* engine1, |
| + TemplateURL* engine2) const; |
| // Removes |template_url| from various internal maps |
| // (|keyword_to_turl_and_length_|, |keyword_domain_to_turl_and_length_|, |
| @@ -543,17 +545,17 @@ class TemplateURLService : public WebDataServiceConsumer, |
| // Returns false if there is a TemplateURL that has a search url with the |
| // specified host and that TemplateURL has been manually modified. |
| - bool CanAddAutogeneratedKeywordForHost(const std::string& host); |
| + bool CanAddAutogeneratedKeywordForHost(const std::string& host) const; |
| // Returns true if the TemplateURL is replaceable. This doesn't look at the |
| // uniqueness of the keyword or host and is intended to be called after those |
| // checks have been done. This returns true if the TemplateURL doesn't appear |
| // in the default list and is marked as safe_for_autoreplace. |
| - bool CanReplace(const TemplateURL* t_url); |
| + bool CanReplace(const TemplateURL* t_url) const; |
| // Like GetTemplateURLForKeyword(), but ignores extension-provided keywords. |
| TemplateURL* FindNonExtensionTemplateURLForKeyword( |
| - const base::string16& keyword); |
| + const base::string16& keyword) const; |
| // Updates the information in |existing_turl| using the information from |
| // |new_values|, but the ID for |existing_turl| is retained. Notifying |
| @@ -661,7 +663,7 @@ class TemplateURLService : public WebDataServiceConsumer, |
| // search provider |
| bool IsLocalTemplateURLBetter(const TemplateURL* local_turl, |
| const TemplateURL* sync_turl, |
| - bool prefer_local_default = true); |
| + bool prefer_local_default = true) const; |
| // Given two synced TemplateURLs with a conflicting keyword, one of which |
| // needs to be added to or updated in the local model (|unapplied_sync_turl|) |
| @@ -714,16 +716,16 @@ class TemplateURLService : public WebDataServiceConsumer, |
| TURLsAndMeaningfulLengths* matches); |
| // Returns the TemplateURL corresponding to |prepopulated_id|, if any. |
| - TemplateURL* FindPrepopulatedTemplateURL(int prepopulated_id); |
| + TemplateURL* FindPrepopulatedTemplateURL(int prepopulated_id) const; |
| // Returns the TemplateURL associated with |extension_id|, if any. |
| TemplateURL* FindTemplateURLForExtension(const std::string& extension_id, |
| - TemplateURL::Type type); |
| + TemplateURL::Type type) const; |
| // Finds any NORMAL_CONTROLLED_BY_EXTENSION engine that matches |data| and |
| // wants to be default. Returns nullptr if not found. |
| TemplateURL* FindMatchingDefaultExtensionTemplateURL( |
| - const TemplateURLData& data); |
| + const TemplateURLData& data) const; |
| // Returns whether |template_urls_| contains more than one normal engine with |
| // same keyword. Used to validate state after search engines are |