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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 218 |
219 // Returns true if the default search is managed through group policy. | 219 // Returns true if the default search is managed through group policy. |
220 bool is_default_search_managed() const { return is_default_search_managed_; } | 220 bool is_default_search_managed() const { return is_default_search_managed_; } |
221 | 221 |
222 // Returns the default search specified in the prepopulated data, if it | 222 // Returns the default search specified in the prepopulated data, if it |
223 // exists. If not, returns first URL in |template_urls_|, or NULL if that's | 223 // exists. If not, returns first URL in |template_urls_|, or NULL if that's |
224 // empty. The returned object is owned by TemplateURLService and can be | 224 // empty. The returned object is owned by TemplateURLService and can be |
225 // destroyed at any time so should be used right after the call. | 225 // destroyed at any time so should be used right after the call. |
226 TemplateURL* FindNewDefaultSearchProvider(); | 226 TemplateURL* FindNewDefaultSearchProvider(); |
227 | 227 |
| 228 // Resets the search providers to the prepopulated engines plus any |
| 229 // extension-supplied engines. Also resets the default search engine unless |
| 230 // it's managed. |
| 231 void ResetNonExtensionURLs(); |
| 232 |
228 // Observers used to listen for changes to the model. | 233 // Observers used to listen for changes to the model. |
229 // TemplateURLService does NOT delete the observers when deleted. | 234 // TemplateURLService does NOT delete the observers when deleted. |
230 void AddObserver(TemplateURLServiceObserver* observer); | 235 void AddObserver(TemplateURLServiceObserver* observer); |
231 void RemoveObserver(TemplateURLServiceObserver* observer); | 236 void RemoveObserver(TemplateURLServiceObserver* observer); |
232 | 237 |
233 // Loads the keywords. This has no effect if the keywords have already been | 238 // Loads the keywords. This has no effect if the keywords have already been |
234 // loaded. | 239 // loaded. |
235 // Observers are notified when loading completes via the method | 240 // Observers are notified when loading completes via the method |
236 // OnTemplateURLServiceChanged. | 241 // OnTemplateURLServiceChanged. |
237 void Load(); | 242 void Load(); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 // Creates a TemplateURL that was previously saved to prefs via | 419 // Creates a TemplateURL that was previously saved to prefs via |
415 // SaveDefaultSearchProviderToPrefs or set via policy. | 420 // SaveDefaultSearchProviderToPrefs or set via policy. |
416 // Returns true if successful, false otherwise. | 421 // Returns true if successful, false otherwise. |
417 // If the user or the policy has opted for no default search, this | 422 // If the user or the policy has opted for no default search, this |
418 // returns true but default_provider is set to NULL. | 423 // returns true but default_provider is set to NULL. |
419 // |*is_managed| specifies whether the default is managed via policy. | 424 // |*is_managed| specifies whether the default is managed via policy. |
420 bool LoadDefaultSearchProviderFromPrefs( | 425 bool LoadDefaultSearchProviderFromPrefs( |
421 scoped_ptr<TemplateURL>* default_provider, | 426 scoped_ptr<TemplateURL>* default_provider, |
422 bool* is_managed); | 427 bool* is_managed); |
423 | 428 |
| 429 // Clears user preferences describing the default search engine. |
| 430 void ClearDefaultProviderFromPrefs(); |
| 431 |
424 // Returns true if there is no TemplateURL that has a search url with the | 432 // Returns true if there is no TemplateURL that has a search url with the |
425 // specified host, or the only TemplateURLs matching the specified host can | 433 // specified host, or the only TemplateURLs matching the specified host can |
426 // be replaced. | 434 // be replaced. |
427 bool CanReplaceKeywordForHost(const std::string& host, | 435 bool CanReplaceKeywordForHost(const std::string& host, |
428 TemplateURL** to_replace); | 436 TemplateURL** to_replace); |
429 | 437 |
430 // Returns true if the TemplateURL is replaceable. This doesn't look at the | 438 // Returns true if the TemplateURL is replaceable. This doesn't look at the |
431 // uniqueness of the keyword or host and is intended to be called after those | 439 // uniqueness of the keyword or host and is intended to be called after those |
432 // checks have been done. This returns true if the TemplateURL doesn't appear | 440 // checks have been done. This returns true if the TemplateURL doesn't appear |
433 // in the default list and is marked as safe_for_autoreplace. | 441 // in the default list and is marked as safe_for_autoreplace. |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 // NULL if there was no pending search provider from Sync. | 583 // NULL if there was no pending search provider from Sync. |
576 TemplateURL* GetPendingSyncedDefaultSearchProvider(); | 584 TemplateURL* GetPendingSyncedDefaultSearchProvider(); |
577 | 585 |
578 // Goes through a vector of TemplateURLs and ensure that both the in-memory | 586 // Goes through a vector of TemplateURLs and ensure that both the in-memory |
579 // and database copies have valid sync_guids. This is to fix crbug.com/102038, | 587 // and database copies have valid sync_guids. This is to fix crbug.com/102038, |
580 // where old entries were being pushed to Sync without a sync_guid. | 588 // where old entries were being pushed to Sync without a sync_guid. |
581 void PatchMissingSyncGUIDs(TemplateURLVector* template_urls); | 589 void PatchMissingSyncGUIDs(TemplateURLVector* template_urls); |
582 | 590 |
583 void OnSyncedDefaultSearchProviderGUIDChanged(); | 591 void OnSyncedDefaultSearchProviderGUIDChanged(); |
584 | 592 |
| 593 // Adds |template_urls| to |template_urls_| and sets up the default search |
| 594 // provider. If |default_search_provider| is non-NULL, it must refer to one |
| 595 // of the |template_urls|, and will be used as the new default. |
| 596 void AddTemplateURLsAndSetupDefaultEngine( |
| 597 TemplateURLVector* template_urls, |
| 598 TemplateURL* default_search_provider); |
| 599 |
| 600 // If there is no current default search provider, sets the default to the |
| 601 // result of calling FindNewDefaultSearchProvider(). |
| 602 void EnsureDefaultSearchProviderExists(); |
| 603 |
585 content::NotificationRegistrar notification_registrar_; | 604 content::NotificationRegistrar notification_registrar_; |
586 PrefChangeRegistrar pref_change_registrar_; | 605 PrefChangeRegistrar pref_change_registrar_; |
587 | 606 |
588 // Mapping from keyword to the TemplateURL. | 607 // Mapping from keyword to the TemplateURL. |
589 KeywordToTemplateMap keyword_to_template_map_; | 608 KeywordToTemplateMap keyword_to_template_map_; |
590 | 609 |
591 // Mapping from Sync GUIDs to the TemplateURL. | 610 // Mapping from Sync GUIDs to the TemplateURL. |
592 GUIDToTemplateMap guid_to_template_map_; | 611 GUIDToTemplateMap guid_to_template_map_; |
593 | 612 |
594 TemplateURLVector template_urls_; | 613 TemplateURLVector template_urls_; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 | 689 |
671 // This is used to log the origin of changes to the default search provider. | 690 // This is used to log the origin of changes to the default search provider. |
672 // We set this value to increasingly specific values when we know what is the | 691 // We set this value to increasingly specific values when we know what is the |
673 // cause/origin of a default search change. | 692 // cause/origin of a default search change. |
674 DefaultSearchChangeOrigin dsp_change_origin_; | 693 DefaultSearchChangeOrigin dsp_change_origin_; |
675 | 694 |
676 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); | 695 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); |
677 }; | 696 }; |
678 | 697 |
679 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ | 698 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ |
OLD | NEW |