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

Side by Side Diff: components/search_engines/template_url_service.h

Issue 2816353002: Make const versions GetTemplateURLForKeyword, GetTemplateURLForGUID, GetTemplateURLForHost (Closed)
Patch Set: Make definition and declaration order of new functions match Created 3 years, 8 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
OLDNEW
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
170 const TemplateURL* GetTemplateURLForKeyword(
171 const base::string16& keyword) const;
170 172
171 // Returns that TemplateURL with the specified GUID, or NULL if not found. 173 // 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 174 // The caller should not try to delete the returned pointer; the data store
173 // retains ownership of it. 175 // retains ownership of it.
174 TemplateURL* GetTemplateURLForGUID(const std::string& sync_guid); 176 TemplateURL* GetTemplateURLForGUID(const std::string& sync_guid);
177 const TemplateURL* GetTemplateURLForGUID(const std::string& sync_guid) const;
175 178
176 // Returns the first TemplateURL found with a URL using the specified |host|, 179 // Returns the first TemplateURL found with a URL using the specified |host|,
177 // or NULL if there are no such TemplateURLs 180 // or NULL if there are no such TemplateURLs
178 TemplateURL* GetTemplateURLForHost(const std::string& host); 181 TemplateURL* GetTemplateURLForHost(const std::string& host);
182 const TemplateURL* GetTemplateURLForHost(const std::string& host) const;
179 183
180 // Adds |template_url| to this model. Returns a raw pointer to |template_url| 184 // 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 185 // 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.) 186 // need a raw pointer to the TemplateURL so they can access it later.)
183 TemplateURL* Add(std::unique_ptr<TemplateURL> template_url); 187 TemplateURL* Add(std::unique_ptr<TemplateURL> template_url);
184 188
185 // Like Add(), but overwrites the |template_url|'s values with the provided 189 // Like Add(), but overwrites the |template_url|'s values with the provided
186 // ones. 190 // ones.
187 TemplateURL* AddWithOverrides(std::unique_ptr<TemplateURL> template_url, 191 TemplateURL* AddWithOverrides(std::unique_ptr<TemplateURL> template_url,
188 const base::string16& short_name, 192 const base::string16& short_name,
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 // 390 //
387 // If the created TemplateURL is migrated in some way from out-of-date sync 391 // If the created TemplateURL is migrated in some way from out-of-date sync
388 // data, an appropriate SyncChange is added to |change_list|. If the sync 392 // data, an appropriate SyncChange is added to |change_list|. If the sync
389 // data is bad for some reason, an ACTION_DELETE change is added and the 393 // data is bad for some reason, an ACTION_DELETE change is added and the
390 // function returns NULL. 394 // function returns NULL.
391 static std::unique_ptr<TemplateURL> 395 static std::unique_ptr<TemplateURL>
392 CreateTemplateURLFromTemplateURLAndSyncData( 396 CreateTemplateURLFromTemplateURLAndSyncData(
393 TemplateURLServiceClient* client, 397 TemplateURLServiceClient* client,
394 PrefService* prefs, 398 PrefService* prefs,
395 const SearchTermsData& search_terms_data, 399 const SearchTermsData& search_terms_data,
396 TemplateURL* existing_turl, 400 const TemplateURL* existing_turl,
397 const syncer::SyncData& sync_data, 401 const syncer::SyncData& sync_data,
398 syncer::SyncChangeList* change_list); 402 syncer::SyncChangeList* change_list);
399 403
400 // Returns a map mapping Sync GUIDs to pointers to syncer::SyncData. 404 // Returns a map mapping Sync GUIDs to pointers to syncer::SyncData.
401 static SyncDataMap CreateGUIDToSyncDataMap( 405 static SyncDataMap CreateGUIDToSyncDataMap(
402 const syncer::SyncDataList& sync_data); 406 const syncer::SyncDataList& sync_data);
403 407
404 #if defined(UNIT_TEST) 408 #if defined(UNIT_TEST)
405 void set_clock(std::unique_ptr<base::Clock> clock) { 409 void set_clock(std::unique_ptr<base::Clock> clock) {
406 clock_ = std::move(clock); 410 clock_ = std::move(clock);
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 // Helper class to manage the default search engine. 853 // Helper class to manage the default search engine.
850 DefaultSearchManager default_search_manager_; 854 DefaultSearchManager default_search_manager_;
851 855
852 std::unique_ptr<GoogleURLTracker::Subscription> 856 std::unique_ptr<GoogleURLTracker::Subscription>
853 google_url_updated_subscription_; 857 google_url_updated_subscription_;
854 858
855 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); 859 DISALLOW_COPY_AND_ASSIGN(TemplateURLService);
856 }; 860 };
857 861
858 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ 862 #endif // COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_
OLDNEW
« no previous file with comments | « components/omnibox/browser/omnibox_client.cc ('k') | components/search_engines/template_url_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698