Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 5 #ifndef COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
| 6 #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 6 #define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 | 124 |
| 125 // Returns true if there is no TemplateURL that conflicts with the | 125 // Returns true if there is no TemplateURL that conflicts with the |
| 126 // keyword/url pair, or there is one but it can be replaced. If there is an | 126 // keyword/url pair, or there is one but it can be replaced. If there is an |
| 127 // existing keyword that can be replaced and template_url_to_replace is | 127 // existing keyword that can be replaced and template_url_to_replace is |
| 128 // non-NULL, template_url_to_replace is set to the keyword to replace. | 128 // non-NULL, template_url_to_replace is set to the keyword to replace. |
| 129 // | 129 // |
| 130 // |url| is the URL of the search query. This is used to prevent auto-adding | 130 // |url| is the URL of the search query. This is used to prevent auto-adding |
| 131 // a keyword for hosts already associated with a manually-edited keyword. | 131 // a keyword for hosts already associated with a manually-edited keyword. |
| 132 bool CanAddAutogeneratedKeyword(const base::string16& keyword, | 132 bool CanAddAutogeneratedKeyword(const base::string16& keyword, |
| 133 const GURL& url, | 133 const GURL& url, |
| 134 TemplateURL** template_url_to_replace); | 134 TemplateURL** template_url_to_replace) const; |
| 135 | 135 |
| 136 // Returns whether the engine is a "pre-existing" engine, either from the | 136 // Returns whether the engine is a "pre-existing" engine, either from the |
| 137 // prepopulate list or created by policy. | 137 // prepopulate list or created by policy. |
| 138 bool IsPrepopulatedOrCreatedByPolicy(const TemplateURL* template_url); | 138 bool IsPrepopulatedOrCreatedByPolicy(const TemplateURL* template_url) const; |
| 139 | 139 |
| 140 // Returns whether |template_url| should be shown in the list of engines | 140 // Returns whether |template_url| should be shown in the list of engines |
| 141 // most likely to be selected as a default engine. This is meant to highlight | 141 // most likely to be selected as a default engine. This is meant to highlight |
| 142 // the current default, as well as the other most likely choices of default | 142 // the current default, as well as the other most likely choices of default |
| 143 // engine, separately from a full list of all TemplateURLs (which might be | 143 // engine, separately from a full list of all TemplateURLs (which might be |
| 144 // very long). | 144 // very long). |
| 145 bool ShowInDefaultList(const TemplateURL* template_url); | 145 bool ShowInDefaultList(const TemplateURL* template_url) const; |
| 146 | 146 |
| 147 // Adds to |matches| all TemplateURLs whose keywords begin with |prefix|, | 147 // Adds to |matches| all TemplateURLs whose keywords begin with |prefix|, |
| 148 // sorted shortest-keyword-first. If |supports_replacement_only| is true, only | 148 // sorted shortest-keyword-first. If |supports_replacement_only| is true, only |
| 149 // TemplateURLs that support replacement are returned. | 149 // TemplateURLs that support replacement are returned. |
| 150 void AddMatchingKeywords(const base::string16& prefix, | 150 void AddMatchingKeywords(const base::string16& prefix, |
| 151 bool supports_replacement_only, | 151 bool supports_replacement_only, |
| 152 TURLsAndMeaningfulLengths* matches); | 152 TURLsAndMeaningfulLengths* matches); |
| 153 | 153 |
| 154 // Adds to |matches| all TemplateURLs for search engines with the domain | 154 // Adds to |matches| all TemplateURLs for search engines with the domain |
| 155 // name part of the keyword starts with |prefix|, sorted | 155 // name part of the keyword starts with |prefix|, sorted |
| 156 // shortest-domain-name-first. If |supports_replacement_only| is true, only | 156 // shortest-domain-name-first. If |supports_replacement_only| is true, only |
| 157 // TemplateURLs that support replacement are returned. Does not bother | 157 // TemplateURLs that support replacement are returned. Does not bother |
| 158 // searching/returning keywords that would've been found with an identical | 158 // searching/returning keywords that would've been found with an identical |
| 159 // call to FindMatchingKeywords(); i.e., doesn't search keywords for which | 159 // call to FindMatchingKeywords(); i.e., doesn't search keywords for which |
| 160 // the domain name is the keyword. | 160 // the domain name is the keyword. |
| 161 void AddMatchingDomainKeywords(const base::string16& prefix, | 161 void AddMatchingDomainKeywords(const base::string16& prefix, |
| 162 bool supports_replacement_only, | 162 bool supports_replacement_only, |
| 163 TURLsAndMeaningfulLengths* matches); | 163 TURLsAndMeaningfulLengths* matches); |
| 164 | 164 |
| 165 // Looks up |keyword| and returns the element it maps to. Returns NULL if | 165 // Looks up |keyword| and returns the element it maps to. Returns NULL if |
| 166 // the keyword was not found. | 166 // the keyword was not found. |
| 167 // The caller should not try to delete the returned pointer; the data store | 167 // The caller should not try to delete the returned pointer; the data store |
| 168 // retains ownership of it. | 168 // retains ownership of it. |
| 169 TemplateURL* GetTemplateURLForKeyword(const base::string16& keyword); | 169 TemplateURL* GetTemplateURLForKeyword(const base::string16& keyword) const; |
|
Peter Kasting
2017/04/13 04:04:52
Const methods shouldn't return non-const pointers,
| |
| 170 | 170 |
| 171 // Returns that TemplateURL with the specified GUID, or NULL if not found. | 171 // Returns that TemplateURL with the specified GUID, or NULL if not found. |
| 172 // The caller should not try to delete the returned pointer; the data store | 172 // The caller should not try to delete the returned pointer; the data store |
| 173 // retains ownership of it. | 173 // retains ownership of it. |
| 174 TemplateURL* GetTemplateURLForGUID(const std::string& sync_guid); | 174 TemplateURL* GetTemplateURLForGUID(const std::string& sync_guid) const; |
| 175 | 175 |
| 176 // Returns the first TemplateURL found with a URL using the specified |host|, | 176 // Returns the first TemplateURL found with a URL using the specified |host|, |
| 177 // or NULL if there are no such TemplateURLs | 177 // or NULL if there are no such TemplateURLs |
| 178 TemplateURL* GetTemplateURLForHost(const std::string& host); | 178 TemplateURL* GetTemplateURLForHost(const std::string& host) const; |
| 179 | 179 |
| 180 // Adds |template_url| to this model. Returns a raw pointer to |template_url| | 180 // Adds |template_url| to this model. Returns a raw pointer to |template_url| |
| 181 // if the addition succeeded, or null on failure. (Many callers need still | 181 // if the addition succeeded, or null on failure. (Many callers need still |
| 182 // need a raw pointer to the TemplateURL so they can access it later.) | 182 // need a raw pointer to the TemplateURL so they can access it later.) |
| 183 TemplateURL* Add(std::unique_ptr<TemplateURL> template_url); | 183 TemplateURL* Add(std::unique_ptr<TemplateURL> template_url); |
| 184 | 184 |
| 185 // Like Add(), but overwrites the |template_url|'s values with the provided | 185 // Like Add(), but overwrites the |template_url|'s values with the provided |
| 186 // ones. | 186 // ones. |
| 187 TemplateURL* AddWithOverrides(std::unique_ptr<TemplateURL> template_url, | 187 TemplateURL* AddWithOverrides(std::unique_ptr<TemplateURL> template_url, |
| 188 const base::string16& short_name, | 188 const base::string16& short_name, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 // Resets the title, keyword and search url of the specified TemplateURL. | 241 // Resets the title, keyword and search url of the specified TemplateURL. |
| 242 // The TemplateURL is marked as not replaceable. | 242 // The TemplateURL is marked as not replaceable. |
| 243 void ResetTemplateURL(TemplateURL* url, | 243 void ResetTemplateURL(TemplateURL* url, |
| 244 const base::string16& title, | 244 const base::string16& title, |
| 245 const base::string16& keyword, | 245 const base::string16& keyword, |
| 246 const std::string& search_url); | 246 const std::string& search_url); |
| 247 | 247 |
| 248 // Return true if the given |url| can be made the default. This returns false | 248 // Return true if the given |url| can be made the default. This returns false |
| 249 // regardless of |url| if the default search provider is managed by policy or | 249 // regardless of |url| if the default search provider is managed by policy or |
| 250 // controlled by an extension. | 250 // controlled by an extension. |
| 251 bool CanMakeDefault(const TemplateURL* url); | 251 bool CanMakeDefault(const TemplateURL* url) const; |
| 252 | 252 |
| 253 // Set the default search provider. |url| may be null. | 253 // Set the default search provider. |url| may be null. |
| 254 // This will assert if the default search is managed; the UI should not be | 254 // This will assert if the default search is managed; the UI should not be |
| 255 // invoking this method in that situation. | 255 // invoking this method in that situation. |
| 256 void SetUserSelectedDefaultSearchProvider(TemplateURL* url); | 256 void SetUserSelectedDefaultSearchProvider(TemplateURL* url); |
| 257 | 257 |
| 258 // Returns the default search provider. If the TemplateURLService hasn't been | 258 // Returns the default search provider. If the TemplateURLService hasn't been |
| 259 // loaded, the default search provider is pulled from preferences. | 259 // loaded, the default search provider is pulled from preferences. |
| 260 // | 260 // |
| 261 // NOTE: At least in unittest mode, this may return NULL. | 261 // NOTE: At least in unittest mode, this may return NULL. |
| 262 // TODO(blundell): See if all callers can be converted to take in const | 262 // TODO(blundell): See if all callers can be converted to take in const |
| 263 // pointers and eliminate this version of the method. | 263 // pointers and eliminate this version of the method. |
| 264 TemplateURL* GetDefaultSearchProvider(); | 264 TemplateURL* GetDefaultSearchProvider(); |
| 265 const TemplateURL* GetDefaultSearchProvider() const; | 265 const TemplateURL* GetDefaultSearchProvider() const; |
| 266 | 266 |
| 267 // Returns true if the |url| is a search results page from the default search | 267 // Returns true if the |url| is a search results page from the default search |
| 268 // provider. | 268 // provider. |
| 269 bool IsSearchResultsPageFromDefaultSearchProvider(const GURL& url) const; | 269 bool IsSearchResultsPageFromDefaultSearchProvider(const GURL& url) const; |
| 270 | 270 |
| 271 // Returns true if the default search is managed through group policy. | 271 // Returns true if the default search is managed through group policy. |
| 272 bool is_default_search_managed() const { | 272 bool is_default_search_managed() const { |
| 273 return default_search_provider_source_ == DefaultSearchManager::FROM_POLICY; | 273 return default_search_provider_source_ == DefaultSearchManager::FROM_POLICY; |
| 274 } | 274 } |
| 275 | 275 |
| 276 // Returns true if the default search provider is controlled by an extension. | 276 // Returns true if the default search provider is controlled by an extension. |
| 277 bool IsExtensionControlledDefaultSearch(); | 277 bool IsExtensionControlledDefaultSearch() const; |
| 278 | 278 |
| 279 // Returns the default search specified in the prepopulated data, if it | 279 // Returns the default search specified in the prepopulated data, if it |
| 280 // exists. If not, returns first URL in |template_urls_|, or NULL if that's | 280 // exists. If not, returns first URL in |template_urls_|, or NULL if that's |
| 281 // empty. The returned object is owned by TemplateURLService and can be | 281 // empty. The returned object is owned by TemplateURLService and can be |
| 282 // destroyed at any time so should be used right after the call. | 282 // destroyed at any time so should be used right after the call. |
| 283 TemplateURL* FindNewDefaultSearchProvider(); | 283 TemplateURL* FindNewDefaultSearchProvider(); |
| 284 | 284 |
| 285 // Performs the same actions that happen when the prepopulate data version is | 285 // Performs the same actions that happen when the prepopulate data version is |
| 286 // revved: all existing prepopulated entries are checked against the current | 286 // revved: all existing prepopulated entries are checked against the current |
| 287 // prepopulate data, any now-extraneous safe_for_autoreplace() entries are | 287 // prepopulate data, any now-extraneous safe_for_autoreplace() entries are |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 323 // Notification that the keywords have been loaded. | 323 // Notification that the keywords have been loaded. |
| 324 // This is invoked from WebDataService, and should not be directly | 324 // This is invoked from WebDataService, and should not be directly |
| 325 // invoked. | 325 // invoked. |
| 326 void OnWebDataServiceRequestDone( | 326 void OnWebDataServiceRequestDone( |
| 327 KeywordWebDataService::Handle h, | 327 KeywordWebDataService::Handle h, |
| 328 std::unique_ptr<WDTypedResult> result) override; | 328 std::unique_ptr<WDTypedResult> result) override; |
| 329 | 329 |
| 330 // Returns the locale-direction-adjusted short name for the given keyword. | 330 // Returns the locale-direction-adjusted short name for the given keyword. |
| 331 // Also sets the out param to indicate whether the keyword belongs to an | 331 // Also sets the out param to indicate whether the keyword belongs to an |
| 332 // Omnibox extension. | 332 // Omnibox extension. |
| 333 base::string16 GetKeywordShortName(const base::string16& keyword, | 333 base::string16 GetKeywordShortName( |
| 334 bool* is_omnibox_api_extension_keyword); | 334 const base::string16& keyword, |
| 335 bool* is_omnibox_api_extension_keyword) const; | |
| 335 | 336 |
| 336 // Called by the history service when a URL is visited. | 337 // Called by the history service when a URL is visited. |
| 337 void OnHistoryURLVisited(const URLVisitedDetails& details); | 338 void OnHistoryURLVisited(const URLVisitedDetails& details); |
| 338 | 339 |
| 339 // KeyedService implementation. | 340 // KeyedService implementation. |
| 340 void Shutdown() override; | 341 void Shutdown() override; |
| 341 | 342 |
| 342 // syncer::SyncableService implementation. | 343 // syncer::SyncableService implementation. |
| 343 | 344 |
| 344 // Returns all syncable TemplateURLs from this model as SyncData. This should | 345 // Returns all syncable TemplateURLs from this model as SyncData. This should |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 486 | 487 |
| 487 void Init(const Initializer* initializers, int num_initializers); | 488 void Init(const Initializer* initializers, int num_initializers); |
| 488 | 489 |
| 489 // Given two engines with the same keyword, returns which should take | 490 // Given two engines with the same keyword, returns which should take |
| 490 // precedence. While normal engines must all have distinct keywords, | 491 // precedence. While normal engines must all have distinct keywords, |
| 491 // extension-controlled and omnibox API engines may have the same keywords as | 492 // extension-controlled and omnibox API engines may have the same keywords as |
| 492 // each other or as normal engines. In these cases, omnibox API engines | 493 // each other or as normal engines. In these cases, omnibox API engines |
| 493 // override extension-controlled engines, which override normal engines; if | 494 // override extension-controlled engines, which override normal engines; if |
| 494 // there is still a conflict after this, the most recently-added extension | 495 // there is still a conflict after this, the most recently-added extension |
| 495 // wins. | 496 // wins. |
| 496 TemplateURL* BestEngineForKeyword(TemplateURL* engine1, TemplateURL* engine2); | 497 TemplateURL* BestEngineForKeyword(TemplateURL* engine1, |
| 498 TemplateURL* engine2) const; | |
| 497 | 499 |
| 498 // Removes |template_url| from various internal maps | 500 // Removes |template_url| from various internal maps |
| 499 // (|keyword_to_turl_and_length_|, |keyword_domain_to_turl_and_length_|, | 501 // (|keyword_to_turl_and_length_|, |keyword_domain_to_turl_and_length_|, |
| 500 // |guid_to_turl_|, |provider_map_|). | 502 // |guid_to_turl_|, |provider_map_|). |
| 501 void RemoveFromMaps(TemplateURL* template_url); | 503 void RemoveFromMaps(TemplateURL* template_url); |
| 502 | 504 |
| 503 // Adds |template_url| to various internal maps | 505 // Adds |template_url| to various internal maps |
| 504 // (|keyword_to_turl_and_length_|, |keyword_domain_to_turl_and_length_|, | 506 // (|keyword_to_turl_and_length_|, |keyword_domain_to_turl_and_length_|, |
| 505 // |guid_to_turl_|, |provider_map_|) if appropriate. (It might not be | 507 // |guid_to_turl_|, |provider_map_|) if appropriate. (It might not be |
| 506 // appropriate if, for instance, |template_url|'s keyword conflicts with | 508 // appropriate if, for instance, |template_url|'s keyword conflicts with |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 536 DefaultSearchManager::Source source); | 538 DefaultSearchManager::Source source); |
| 537 | 539 |
| 538 | 540 |
| 539 // Applies a DSE change. May be called at startup or after transitioning to | 541 // Applies a DSE change. May be called at startup or after transitioning to |
| 540 // the loaded state. Returns true if a change actually occurred. | 542 // the loaded state. Returns true if a change actually occurred. |
| 541 bool ApplyDefaultSearchChangeNoMetrics(const TemplateURLData* new_dse_data, | 543 bool ApplyDefaultSearchChangeNoMetrics(const TemplateURLData* new_dse_data, |
| 542 DefaultSearchManager::Source source); | 544 DefaultSearchManager::Source source); |
| 543 | 545 |
| 544 // Returns false if there is a TemplateURL that has a search url with the | 546 // Returns false if there is a TemplateURL that has a search url with the |
| 545 // specified host and that TemplateURL has been manually modified. | 547 // specified host and that TemplateURL has been manually modified. |
| 546 bool CanAddAutogeneratedKeywordForHost(const std::string& host); | 548 bool CanAddAutogeneratedKeywordForHost(const std::string& host) const; |
| 547 | 549 |
| 548 // Returns true if the TemplateURL is replaceable. This doesn't look at the | 550 // Returns true if the TemplateURL is replaceable. This doesn't look at the |
| 549 // uniqueness of the keyword or host and is intended to be called after those | 551 // uniqueness of the keyword or host and is intended to be called after those |
| 550 // checks have been done. This returns true if the TemplateURL doesn't appear | 552 // checks have been done. This returns true if the TemplateURL doesn't appear |
| 551 // in the default list and is marked as safe_for_autoreplace. | 553 // in the default list and is marked as safe_for_autoreplace. |
| 552 bool CanReplace(const TemplateURL* t_url); | 554 bool CanReplace(const TemplateURL* t_url) const; |
| 553 | 555 |
| 554 // Like GetTemplateURLForKeyword(), but ignores extension-provided keywords. | 556 // Like GetTemplateURLForKeyword(), but ignores extension-provided keywords. |
| 555 TemplateURL* FindNonExtensionTemplateURLForKeyword( | 557 TemplateURL* FindNonExtensionTemplateURLForKeyword( |
| 556 const base::string16& keyword); | 558 const base::string16& keyword) const; |
| 557 | 559 |
| 558 // Updates the information in |existing_turl| using the information from | 560 // Updates the information in |existing_turl| using the information from |
| 559 // |new_values|, but the ID for |existing_turl| is retained. Notifying | 561 // |new_values|, but the ID for |existing_turl| is retained. Notifying |
| 560 // observers is the responsibility of the caller. Returns whether | 562 // observers is the responsibility of the caller. Returns whether |
| 561 // |existing_turl| was found in |template_urls_| and thus could be updated. | 563 // |existing_turl| was found in |template_urls_| and thus could be updated. |
| 562 // | 564 // |
| 563 // NOTE: This should not be called with an extension keyword as there are no | 565 // NOTE: This should not be called with an extension keyword as there are no |
| 564 // updates needed in that case. | 566 // updates needed in that case. |
| 565 bool UpdateNoNotify(TemplateURL* existing_turl, | 567 bool UpdateNoNotify(TemplateURL* existing_turl, |
| 566 const TemplateURL& new_values); | 568 const TemplateURL& new_values); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 654 // known to the local model (though it may already be synced), and |sync_turl| | 656 // known to the local model (though it may already be synced), and |sync_turl| |
| 655 // is a new TemplateURL known to Sync but not yet known to the local model. | 657 // is a new TemplateURL known to Sync but not yet known to the local model. |
| 656 // The criteria for if |local_turl| is better than |sync_turl| is whether any | 658 // The criteria for if |local_turl| is better than |sync_turl| is whether any |
| 657 // of the following are true: | 659 // of the following are true: |
| 658 // * |local_turl|'s last_modified timestamp is newer than sync_turl. | 660 // * |local_turl|'s last_modified timestamp is newer than sync_turl. |
| 659 // * |local_turl| is created by policy. | 661 // * |local_turl| is created by policy. |
| 660 // * |prefer_local_default| is true and |local_turl| is the local default | 662 // * |prefer_local_default| is true and |local_turl| is the local default |
| 661 // search provider | 663 // search provider |
| 662 bool IsLocalTemplateURLBetter(const TemplateURL* local_turl, | 664 bool IsLocalTemplateURLBetter(const TemplateURL* local_turl, |
| 663 const TemplateURL* sync_turl, | 665 const TemplateURL* sync_turl, |
| 664 bool prefer_local_default = true); | 666 bool prefer_local_default = true) const; |
| 665 | 667 |
| 666 // Given two synced TemplateURLs with a conflicting keyword, one of which | 668 // Given two synced TemplateURLs with a conflicting keyword, one of which |
| 667 // needs to be added to or updated in the local model (|unapplied_sync_turl|) | 669 // needs to be added to or updated in the local model (|unapplied_sync_turl|) |
| 668 // and one which is already known to the local model (|applied_sync_turl|), | 670 // and one which is already known to the local model (|applied_sync_turl|), |
| 669 // prepares the local model so that |unapplied_sync_turl| can be added to it, | 671 // prepares the local model so that |unapplied_sync_turl| can be added to it, |
| 670 // or applied as an update to an existing TemplateURL. | 672 // or applied as an update to an existing TemplateURL. |
| 671 // Since both entries are known to Sync and one of their keywords will change, | 673 // Since both entries are known to Sync and one of their keywords will change, |
| 672 // an ACTION_UPDATE will be appended to |change_list| to reflect this change. | 674 // an ACTION_UPDATE will be appended to |change_list| to reflect this change. |
| 673 // Note that |applied_sync_turl| must not be an extension keyword. | 675 // Note that |applied_sync_turl| must not be an extension keyword. |
| 674 void ResolveSyncKeywordConflict(TemplateURL* unapplied_sync_turl, | 676 void ResolveSyncKeywordConflict(TemplateURL* unapplied_sync_turl, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 707 // |supports_replacement_only| is true, only TemplateURLs that support | 709 // |supports_replacement_only| is true, only TemplateURLs that support |
| 708 // replacement are returned. | 710 // replacement are returned. |
| 709 template <typename Container> | 711 template <typename Container> |
| 710 void AddMatchingKeywordsHelper( | 712 void AddMatchingKeywordsHelper( |
| 711 const Container& keyword_to_turl_and_length, | 713 const Container& keyword_to_turl_and_length, |
| 712 const base::string16& prefix, | 714 const base::string16& prefix, |
| 713 bool supports_replacement_only, | 715 bool supports_replacement_only, |
| 714 TURLsAndMeaningfulLengths* matches); | 716 TURLsAndMeaningfulLengths* matches); |
| 715 | 717 |
| 716 // Returns the TemplateURL corresponding to |prepopulated_id|, if any. | 718 // Returns the TemplateURL corresponding to |prepopulated_id|, if any. |
| 717 TemplateURL* FindPrepopulatedTemplateURL(int prepopulated_id); | 719 TemplateURL* FindPrepopulatedTemplateURL(int prepopulated_id) const; |
| 718 | 720 |
| 719 // Returns the TemplateURL associated with |extension_id|, if any. | 721 // Returns the TemplateURL associated with |extension_id|, if any. |
| 720 TemplateURL* FindTemplateURLForExtension(const std::string& extension_id, | 722 TemplateURL* FindTemplateURLForExtension(const std::string& extension_id, |
| 721 TemplateURL::Type type); | 723 TemplateURL::Type type) const; |
| 722 | 724 |
| 723 // Finds any NORMAL_CONTROLLED_BY_EXTENSION engine that matches |data| and | 725 // Finds any NORMAL_CONTROLLED_BY_EXTENSION engine that matches |data| and |
| 724 // wants to be default. Returns nullptr if not found. | 726 // wants to be default. Returns nullptr if not found. |
| 725 TemplateURL* FindMatchingDefaultExtensionTemplateURL( | 727 TemplateURL* FindMatchingDefaultExtensionTemplateURL( |
| 726 const TemplateURLData& data); | 728 const TemplateURLData& data) const; |
| 727 | 729 |
| 728 // Returns whether |template_urls_| contains more than one normal engine with | 730 // Returns whether |template_urls_| contains more than one normal engine with |
| 729 // same keyword. Used to validate state after search engines are | 731 // same keyword. Used to validate state after search engines are |
| 730 // added/updated. | 732 // added/updated. |
| 731 bool HasDuplicateKeywords() const; | 733 bool HasDuplicateKeywords() const; |
| 732 | 734 |
| 733 // ---------- Browser state related members --------------------------------- | 735 // ---------- Browser state related members --------------------------------- |
| 734 PrefService* prefs_; | 736 PrefService* prefs_; |
| 735 | 737 |
| 736 std::unique_ptr<SearchTermsData> search_terms_data_; | 738 std::unique_ptr<SearchTermsData> search_terms_data_; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 848 // Helper class to manage the default search engine. | 850 // Helper class to manage the default search engine. |
| 849 DefaultSearchManager default_search_manager_; | 851 DefaultSearchManager default_search_manager_; |
| 850 | 852 |
| 851 std::unique_ptr<GoogleURLTracker::Subscription> | 853 std::unique_ptr<GoogleURLTracker::Subscription> |
| 852 google_url_updated_subscription_; | 854 google_url_updated_subscription_; |
| 853 | 855 |
| 854 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); | 856 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); |
| 855 }; | 857 }; |
| 856 | 858 |
| 857 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 859 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
| OLD | NEW |