| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 // a TemplateURL for an existing TemplateURL that shares the same host. | 149 // a TemplateURL for an existing TemplateURL that shares the same host. |
| 150 bool CanReplaceKeyword(const base::string16& keyword, | 150 bool CanReplaceKeyword(const base::string16& keyword, |
| 151 const GURL& url, | 151 const GURL& url, |
| 152 TemplateURL** template_url_to_replace); | 152 TemplateURL** template_url_to_replace); |
| 153 | 153 |
| 154 // Returns (in |matches|) all TemplateURLs whose keywords begin with |prefix|, | 154 // Returns (in |matches|) all TemplateURLs whose keywords begin with |prefix|, |
| 155 // sorted shortest keyword-first. If |support_replacement_only| is true, only | 155 // sorted shortest keyword-first. If |support_replacement_only| is true, only |
| 156 // TemplateURLs that support replacement are returned. | 156 // TemplateURLs that support replacement are returned. |
| 157 void FindMatchingKeywords(const base::string16& prefix, | 157 void FindMatchingKeywords(const base::string16& prefix, |
| 158 bool support_replacement_only, | 158 bool support_replacement_only, |
| 159 TemplateURLVector* matches) const; | 159 TemplateURLVector* matches); |
| 160 | 160 |
| 161 // Looks up |keyword| and returns the element it maps to. Returns NULL if | 161 // Looks up |keyword| and returns the element it maps to. Returns NULL if |
| 162 // the keyword was not found. | 162 // the keyword was not found. |
| 163 // The caller should not try to delete the returned pointer; the data store | 163 // The caller should not try to delete the returned pointer; the data store |
| 164 // retains ownership of it. | 164 // retains ownership of it. |
| 165 TemplateURL* GetTemplateURLForKeyword(const base::string16& keyword); | 165 TemplateURL* GetTemplateURLForKeyword(const base::string16& keyword); |
| 166 | 166 |
| 167 // Returns that TemplateURL with the specified GUID, or NULL if not found. | 167 // Returns that TemplateURL with the specified GUID, or NULL if not found. |
| 168 // The caller should not try to delete the returned pointer; the data store | 168 // The caller should not try to delete the returned pointer; the data store |
| 169 // retains ownership of it. | 169 // retains ownership of it. |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 // Returns the default search specified in the prepopulated data, if it | 269 // Returns the default search specified in the prepopulated data, if it |
| 270 // exists. If not, returns first URL in |template_urls_|, or NULL if that's | 270 // exists. If not, returns first URL in |template_urls_|, or NULL if that's |
| 271 // empty. The returned object is owned by TemplateURLService and can be | 271 // empty. The returned object is owned by TemplateURLService and can be |
| 272 // destroyed at any time so should be used right after the call. | 272 // destroyed at any time so should be used right after the call. |
| 273 TemplateURL* FindNewDefaultSearchProvider(); | 273 TemplateURL* FindNewDefaultSearchProvider(); |
| 274 | 274 |
| 275 // Performs the same actions that happen when the prepopulate data version is | 275 // Performs the same actions that happen when the prepopulate data version is |
| 276 // revved: all existing prepopulated entries are checked against the current | 276 // revved: all existing prepopulated entries are checked against the current |
| 277 // prepopulate data, any now-extraneous safe_for_autoreplace() entries are | 277 // prepopulate data, any now-extraneous safe_for_autoreplace() entries are |
| 278 // removed, any existing engines are reset to the provided data (except for | 278 // removed, any existing engines are reset to the provided data (except for |
| 279 // user-edited names or keywords), and any new prepopulated anegines are | 279 // user-edited names or keywords), and any new prepopulated engines are |
| 280 // added. | 280 // added. |
| 281 // | 281 // |
| 282 // After this, the default search engine is reset to the default entry in the | 282 // After this, the default search engine is reset to the default entry in the |
| 283 // prepopulate data. | 283 // prepopulate data. |
| 284 void RepairPrepopulatedSearchEngines(); | 284 void RepairPrepopulatedSearchEngines(); |
| 285 | 285 |
| 286 // Observers used to listen for changes to the model. | 286 // Observers used to listen for changes to the model. |
| 287 // TemplateURLService does NOT delete the observers when deleted. | 287 // TemplateURLService does NOT delete the observers when deleted. |
| 288 void AddObserver(TemplateURLServiceObserver* observer); | 288 void AddObserver(TemplateURLServiceObserver* observer); |
| 289 void RemoveObserver(TemplateURLServiceObserver* observer); | 289 void RemoveObserver(TemplateURLServiceObserver* observer); |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 void AddTemplateURLsAndSetupDefaultEngine( | 659 void AddTemplateURLsAndSetupDefaultEngine( |
| 660 TemplateURLVector* template_urls, | 660 TemplateURLVector* template_urls, |
| 661 TemplateURL* default_search_provider); | 661 TemplateURL* default_search_provider); |
| 662 | 662 |
| 663 // If there is no current default search provider, sets the default to the | 663 // If there is no current default search provider, sets the default to the |
| 664 // result of calling FindNewDefaultSearchProvider(). | 664 // result of calling FindNewDefaultSearchProvider(). |
| 665 void EnsureDefaultSearchProviderExists(); | 665 void EnsureDefaultSearchProviderExists(); |
| 666 | 666 |
| 667 // Returns a new TemplateURL for the given extension. | 667 // Returns a new TemplateURL for the given extension. |
| 668 TemplateURL* CreateTemplateURLForExtension( | 668 TemplateURL* CreateTemplateURLForExtension( |
| 669 const ExtensionKeyword& extension_keyword) const; | 669 const ExtensionKeyword& extension_keyword); |
| 670 | 670 |
| 671 // Returns the TemplateURL associated with |extension_id|, if any. | 671 // Returns the TemplateURL associated with |extension_id|, if any. |
| 672 TemplateURL* FindTemplateURLForExtension(const std::string& extension_id, | 672 TemplateURL* FindTemplateURLForExtension(const std::string& extension_id, |
| 673 TemplateURL::Type type) const; | 673 TemplateURL::Type type); |
| 674 | 674 |
| 675 // Finds the most recently-installed NORMAL_CONTROLLED_BY_EXTENSION engine | 675 // Finds the most recently-installed NORMAL_CONTROLLED_BY_EXTENSION engine |
| 676 // that supports replacement and wants to be default, if any. | 676 // that supports replacement and wants to be default, if any. |
| 677 TemplateURL* FindExtensionDefaultSearchEngine() const; | 677 TemplateURL* FindExtensionDefaultSearchEngine() const; |
| 678 | 678 |
| 679 // Sets the default search provider to: | 679 // Sets the default search provider to: |
| 680 // (1) BestDefaultExtensionControlledTURL(), if any; or, | 680 // (1) BestDefaultExtensionControlledTURL(), if any; or, |
| 681 // (2) LoadDefaultSearchProviderFromPrefs(), if we have a TURL with that ID; | 681 // (2) LoadDefaultSearchProviderFromPrefs(), if we have a TURL with that ID; |
| 682 // or, | 682 // or, |
| 683 // (3) FindNewDefaultSearchProvider(). | 683 // (3) FindNewDefaultSearchProvider(). |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 WebDataService::Handle load_handle_; | 718 WebDataService::Handle load_handle_; |
| 719 | 719 |
| 720 // Service used to store entries. | 720 // Service used to store entries. |
| 721 scoped_refptr<WebDataService> service_; | 721 scoped_refptr<WebDataService> service_; |
| 722 | 722 |
| 723 // All visits that occurred before we finished loading. Once loaded | 723 // All visits that occurred before we finished loading. Once loaded |
| 724 // UpdateKeywordSearchTermsForURL is invoked for each element of the vector. | 724 // UpdateKeywordSearchTermsForURL is invoked for each element of the vector. |
| 725 std::vector<history::URLVisitedDetails> visits_to_add_; | 725 std::vector<history::URLVisitedDetails> visits_to_add_; |
| 726 | 726 |
| 727 // Once loaded, the default search provider. This is a pointer to a | 727 // Once loaded, the default search provider. This is a pointer to a |
| 728 // TemplateURL owned by template_urls_. | 728 // TemplateURL owned by |template_urls_|. |
| 729 TemplateURL* default_search_provider_; | 729 TemplateURL* default_search_provider_; |
| 730 | 730 |
| 731 // The initial search provider extracted from preferences. This is only valid | 731 // The initial search provider extracted from preferences. This is only valid |
| 732 // if we haven't been loaded or loading failed. | 732 // if we haven't been loaded or loading failed. |
| 733 scoped_ptr<TemplateURL> initial_default_search_provider_; | 733 scoped_ptr<TemplateURL> initial_default_search_provider_; |
| 734 | 734 |
| 735 // Whether the default search is managed via policy. | 735 // Whether the default search is managed via policy. |
| 736 bool is_default_search_managed_; | 736 bool is_default_search_managed_; |
| 737 | 737 |
| 738 // ID assigned to next TemplateURL added to this model. This is an ever | 738 // ID assigned to next TemplateURL added to this model. This is an ever |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 std::set<std::string> pre_sync_deletes_; | 772 std::set<std::string> pre_sync_deletes_; |
| 773 | 773 |
| 774 // This is used to log the origin of changes to the default search provider. | 774 // This is used to log the origin of changes to the default search provider. |
| 775 // We set this value to increasingly specific values when we know what is the | 775 // We set this value to increasingly specific values when we know what is the |
| 776 // cause/origin of a default search change. | 776 // cause/origin of a default search change. |
| 777 DefaultSearchChangeOrigin dsp_change_origin_; | 777 DefaultSearchChangeOrigin dsp_change_origin_; |
| 778 | 778 |
| 779 // Stores a list of callbacks to be run after TemplateURLService has loaded. | 779 // Stores a list of callbacks to be run after TemplateURLService has loaded. |
| 780 base::CallbackList<void(void)> on_loaded_callbacks_; | 780 base::CallbackList<void(void)> on_loaded_callbacks_; |
| 781 | 781 |
| 782 // Helper class to manage the default search engine. This will be NULL when | 782 // Helper class to manage the default search engine. |
| 783 // using the testing-specific constructor. | 783 DefaultSearchManager default_search_manager_; |
| 784 scoped_ptr<DefaultSearchManager> default_search_manager_; | |
| 785 | 784 |
| 786 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); | 785 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); |
| 787 }; | 786 }; |
| 788 | 787 |
| 789 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 788 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
| OLD | NEW |