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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 136 |
137 // Returns the first TemplateURL found with a URL using the specified |host|, | 137 // Returns the first TemplateURL found with a URL using the specified |host|, |
138 // or NULL if there are no such TemplateURLs | 138 // or NULL if there are no such TemplateURLs |
139 const TemplateURL* GetTemplateURLForHost(const std::string& host) const; | 139 const TemplateURL* GetTemplateURLForHost(const std::string& host) const; |
140 | 140 |
141 // Takes ownership of |template_url| and adds it to this model. | 141 // Takes ownership of |template_url| and adds it to this model. |
142 void Add(TemplateURL* template_url); | 142 void Add(TemplateURL* template_url); |
143 | 143 |
144 // Like Add(), but overwrites the |template_url|'s values with the provided | 144 // Like Add(), but overwrites the |template_url|'s values with the provided |
145 // ones. | 145 // ones. |
| 146 void AddAndSetProfile(TemplateURL* template_url, Profile* profile); |
146 void AddWithOverrides(const TemplateURL* template_url, | 147 void AddWithOverrides(const TemplateURL* template_url, |
147 const string16& short_name, | 148 const string16& short_name, |
148 const string16& keyword, | 149 const string16& keyword, |
149 const std::string& url); | 150 const std::string& url); |
150 | 151 |
151 // Removes the keyword from the model. This deletes the supplied TemplateURL. | 152 // Removes the keyword from the model. This deletes the supplied TemplateURL. |
152 // This fails if the supplied template_url is the default search provider. | 153 // This fails if the supplied template_url is the default search provider. |
153 void Remove(const TemplateURL* template_url); | 154 void Remove(const TemplateURL* template_url); |
154 | 155 |
155 // Removes all auto-generated keywords that were created on or after the | 156 // Removes all auto-generated keywords that were created on or after the |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 | 300 |
300 // Creates a new heap-allocated TemplateURL* which is populated by overlaying | 301 // Creates a new heap-allocated TemplateURL* which is populated by overlaying |
301 // |sync_data| atop |existing_turl|. |existing_turl| may be NULL; if not it | 302 // |sync_data| atop |existing_turl|. |existing_turl| may be NULL; if not it |
302 // remains unmodified. The caller owns the returned TemplateURL*. | 303 // remains unmodified. The caller owns the returned TemplateURL*. |
303 // | 304 // |
304 // If the created TemplateURL is migrated in some way from out-of-date sync | 305 // If the created TemplateURL is migrated in some way from out-of-date sync |
305 // data, an appropriate SyncChange is added to |change_list|. If the sync | 306 // data, an appropriate SyncChange is added to |change_list|. If the sync |
306 // data is bad for some reason, an ACTION_DELETE change is added and the | 307 // data is bad for some reason, an ACTION_DELETE change is added and the |
307 // function returns NULL. | 308 // function returns NULL. |
308 static TemplateURL* CreateTemplateURLFromTemplateURLAndSyncData( | 309 static TemplateURL* CreateTemplateURLFromTemplateURLAndSyncData( |
| 310 Profile* profile, |
309 const TemplateURL* existing_turl, | 311 const TemplateURL* existing_turl, |
310 const SyncData& sync_data, | 312 const SyncData& sync_data, |
311 SyncChangeList* change_list); | 313 SyncChangeList* change_list); |
312 | 314 |
313 // Returns a map mapping Sync GUIDs to pointers to SyncData. | 315 // Returns a map mapping Sync GUIDs to pointers to SyncData. |
314 static SyncDataMap CreateGUIDToSyncDataMap(const SyncDataList& sync_data); | 316 static SyncDataMap CreateGUIDToSyncDataMap(const SyncDataList& sync_data); |
315 | 317 |
316 #if defined(UNIT_TEST) | 318 #if defined(UNIT_TEST) |
317 // Set a different time provider function, such as | 319 // Set a different time provider function, such as |
318 // base::MockTimeProvider::StaticNow, when testing calls to base::Time::Now. | 320 // base::MockTimeProvider::StaticNow, when testing calls to base::Time::Now. |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 // from Sync. This is to facilitate the fact that changes to the value of | 604 // from Sync. This is to facilitate the fact that changes to the value of |
603 // prefs::kSyncedDefaultSearchProviderGUID do not always come before the | 605 // prefs::kSyncedDefaultSearchProviderGUID do not always come before the |
604 // TemplateURL entry it refers to, and to handle the case when we want to use | 606 // TemplateURL entry it refers to, and to handle the case when we want to use |
605 // the Synced default when the default search provider becomes unmanaged. | 607 // the Synced default when the default search provider becomes unmanaged. |
606 bool pending_synced_default_search_; | 608 bool pending_synced_default_search_; |
607 | 609 |
608 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); | 610 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); |
609 }; | 611 }; |
610 | 612 |
611 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 613 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
OLD | NEW |