Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(402)

Side by Side Diff: chrome/browser/search_engines/template_url_service.h

Issue 274323002: Revert of Some refactorings to facilitate a larger change to TemplateURLService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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); 159 TemplateURLVector* matches) const;
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
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 engines are 279 // user-edited names or keywords), and any new prepopulated anegines 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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 void AddTemplateURLsAndSetupDefaultEngine( 663 void AddTemplateURLsAndSetupDefaultEngine(
664 TemplateURLVector* template_urls, 664 TemplateURLVector* template_urls,
665 TemplateURL* default_search_provider); 665 TemplateURL* default_search_provider);
666 666
667 // If there is no current default search provider, sets the default to the 667 // If there is no current default search provider, sets the default to the
668 // result of calling FindNewDefaultSearchProvider(). 668 // result of calling FindNewDefaultSearchProvider().
669 void EnsureDefaultSearchProviderExists(); 669 void EnsureDefaultSearchProviderExists();
670 670
671 // Returns a new TemplateURL for the given extension. 671 // Returns a new TemplateURL for the given extension.
672 TemplateURL* CreateTemplateURLForExtension( 672 TemplateURL* CreateTemplateURLForExtension(
673 const ExtensionKeyword& extension_keyword); 673 const ExtensionKeyword& extension_keyword) const;
674 674
675 // Returns the TemplateURL associated with |extension_id|, if any. 675 // Returns the TemplateURL associated with |extension_id|, if any.
676 TemplateURL* FindTemplateURLForExtension(const std::string& extension_id, 676 TemplateURL* FindTemplateURLForExtension(const std::string& extension_id,
677 TemplateURL::Type type); 677 TemplateURL::Type type) const;
678 678
679 // Finds the most recently-installed NORMAL_CONTROLLED_BY_EXTENSION engine 679 // Finds the most recently-installed NORMAL_CONTROLLED_BY_EXTENSION engine
680 // that supports replacement and wants to be default, if any. 680 // that supports replacement and wants to be default, if any.
681 TemplateURL* FindExtensionDefaultSearchEngine() const; 681 TemplateURL* FindExtensionDefaultSearchEngine() const;
682 682
683 // Sets the default search provider to: 683 // Sets the default search provider to:
684 // (1) BestDefaultExtensionControlledTURL(), if any; or, 684 // (1) BestDefaultExtensionControlledTURL(), if any; or,
685 // (2) LoadDefaultSearchProviderFromPrefs(), if we have a TURL with that ID; 685 // (2) LoadDefaultSearchProviderFromPrefs(), if we have a TURL with that ID;
686 // or, 686 // or,
687 // (3) FindNewDefaultSearchProvider(). 687 // (3) FindNewDefaultSearchProvider().
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 WebDataService::Handle load_handle_; 720 WebDataService::Handle load_handle_;
721 721
722 // Service used to store entries. 722 // Service used to store entries.
723 scoped_refptr<WebDataService> service_; 723 scoped_refptr<WebDataService> service_;
724 724
725 // All visits that occurred before we finished loading. Once loaded 725 // All visits that occurred before we finished loading. Once loaded
726 // UpdateKeywordSearchTermsForURL is invoked for each element of the vector. 726 // UpdateKeywordSearchTermsForURL is invoked for each element of the vector.
727 std::vector<history::URLVisitedDetails> visits_to_add_; 727 std::vector<history::URLVisitedDetails> visits_to_add_;
728 728
729 // Once loaded, the default search provider. This is a pointer to a 729 // Once loaded, the default search provider. This is a pointer to a
730 // TemplateURL owned by |template_urls_|. 730 // TemplateURL owned by template_urls_.
731 TemplateURL* default_search_provider_; 731 TemplateURL* default_search_provider_;
732 732
733 // The initial search provider extracted from preferences. This is only valid 733 // The initial search provider extracted from preferences. This is only valid
734 // if we haven't been loaded or loading failed. 734 // if we haven't been loaded or loading failed.
735 scoped_ptr<TemplateURL> initial_default_search_provider_; 735 scoped_ptr<TemplateURL> initial_default_search_provider_;
736 736
737 // Whether the default search is managed via policy. 737 // Whether the default search is managed via policy.
738 bool is_default_search_managed_; 738 bool is_default_search_managed_;
739 739
740 // ID assigned to next TemplateURL added to this model. This is an ever 740 // 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
774 std::set<std::string> pre_sync_deletes_; 774 std::set<std::string> pre_sync_deletes_;
775 775
776 // This is used to log the origin of changes to the default search provider. 776 // This is used to log the origin of changes to the default search provider.
777 // We set this value to increasingly specific values when we know what is the 777 // We set this value to increasingly specific values when we know what is the
778 // cause/origin of a default search change. 778 // cause/origin of a default search change.
779 DefaultSearchChangeOrigin dsp_change_origin_; 779 DefaultSearchChangeOrigin dsp_change_origin_;
780 780
781 // Stores a list of callbacks to be run after TemplateURLService has loaded. 781 // Stores a list of callbacks to be run after TemplateURLService has loaded.
782 base::CallbackList<void(void)> on_loaded_callbacks_; 782 base::CallbackList<void(void)> on_loaded_callbacks_;
783 783
784 // Helper class to manage the default search engine. 784 // Helper class to manage the default search engine. This will be NULL when
785 DefaultSearchManager default_search_manager_; 785 // using the testing-specific constructor.
786 scoped_ptr<DefaultSearchManager> default_search_manager_;
786 787
787 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); 788 DISALLOW_COPY_AND_ASSIGN(TemplateURLService);
788 }; 789 };
789 790
790 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ 791 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/default_search_pref_migration.cc ('k') | chrome/browser/search_engines/template_url_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698