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

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

Issue 15572002: Implemented 'Reset Search engines' feature. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressed Dominic's comments Created 7 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
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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // This will assert if the default search is managed; the UI should not be 209 // This will assert if the default search is managed; the UI should not be
210 // invoking this method in that situation. 210 // invoking this method in that situation.
211 void SetDefaultSearchProvider(TemplateURL* url); 211 void SetDefaultSearchProvider(TemplateURL* url);
212 212
213 // Returns the default search provider. If the TemplateURLService hasn't been 213 // Returns the default search provider. If the TemplateURLService hasn't been
214 // loaded, the default search provider is pulled from preferences. 214 // loaded, the default search provider is pulled from preferences.
215 // 215 //
216 // NOTE: At least in unittest mode, this may return NULL. 216 // NOTE: At least in unittest mode, this may return NULL.
217 TemplateURL* GetDefaultSearchProvider(); 217 TemplateURL* GetDefaultSearchProvider();
218 218
219 // Clears user preferences describing the default search engine.
220 void ClearDefaultProviderFromPrefs();
Peter Kasting 2013/05/22 21:22:57 If these two methods get called one after the othe
vasilii 2013/05/23 17:03:42 Done.
221
222 // Clears non-extension URLs and reloads again prepopulated engines.
223 // Resets the default engine unless it's managed.
Peter Kasting 2013/05/22 21:22:57 Nit: Grammar. How about: Resets the search provi
vasilii 2013/05/23 17:03:42 Done.
224 bool ResetNonExtensionURLs();
225
219 // Returns true if the default search is managed through group policy. 226 // Returns true if the default search is managed through group policy.
220 bool is_default_search_managed() const { return is_default_search_managed_; } 227 bool is_default_search_managed() const { return is_default_search_managed_; }
221 228
222 // Returns the default search specified in the prepopulated data, if it 229 // 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 230 // 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 231 // empty. The returned object is owned by TemplateURLService and can be
225 // destroyed at any time so should be used right after the call. 232 // destroyed at any time so should be used right after the call.
226 TemplateURL* FindNewDefaultSearchProvider(); 233 TemplateURL* FindNewDefaultSearchProvider();
227 234
228 // Observers used to listen for changes to the model. 235 // Observers used to listen for changes to the model.
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 // NULL if there was no pending search provider from Sync. 582 // NULL if there was no pending search provider from Sync.
576 TemplateURL* GetPendingSyncedDefaultSearchProvider(); 583 TemplateURL* GetPendingSyncedDefaultSearchProvider();
577 584
578 // Goes through a vector of TemplateURLs and ensure that both the in-memory 585 // 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, 586 // 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. 587 // where old entries were being pushed to Sync without a sync_guid.
581 void PatchMissingSyncGUIDs(TemplateURLVector* template_urls); 588 void PatchMissingSyncGUIDs(TemplateURLVector* template_urls);
582 589
583 void OnSyncedDefaultSearchProviderGUIDChanged(); 590 void OnSyncedDefaultSearchProviderGUIDChanged();
584 591
592 // Adds |*template_urls| to |template_urls_| and sets up default search
593 // provider according to the internal logic.
594 // |template_urls| comes from database. The method takes ownership of
595 // |template_urls| and its elements.
596 // |default_search_provider| specifies URL inside |*template_urls|.
Peter Kasting 2013/05/22 21:22:57 Nit: How about just: Adds |template_urls| to |tem
vasilii 2013/05/23 17:03:42 Done. Actually we set the default even if it's not
597 void AddTemplateURLsAndSetupDefaultEngine(
598 TemplateURLVector* template_urls,
599 TemplateURL* default_search_provider);
600
601 // This sets the default search engine to FindNewDefaultSearchProvider(),
602 // if it's unmanaged and NULL.
Peter Kasting 2013/05/22 21:22:57 Nit: How about: If there is no current default se
vasilii 2013/05/23 17:03:42 Done.
603 void EnsureDefaultSearchProviderExists();
604
585 content::NotificationRegistrar notification_registrar_; 605 content::NotificationRegistrar notification_registrar_;
586 PrefChangeRegistrar pref_change_registrar_; 606 PrefChangeRegistrar pref_change_registrar_;
587 607
588 // Mapping from keyword to the TemplateURL. 608 // Mapping from keyword to the TemplateURL.
589 KeywordToTemplateMap keyword_to_template_map_; 609 KeywordToTemplateMap keyword_to_template_map_;
590 610
591 // Mapping from Sync GUIDs to the TemplateURL. 611 // Mapping from Sync GUIDs to the TemplateURL.
592 GUIDToTemplateMap guid_to_template_map_; 612 GUIDToTemplateMap guid_to_template_map_;
593 613
594 TemplateURLVector template_urls_; 614 TemplateURLVector template_urls_;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 690
671 // This is used to log the origin of changes to the default search provider. 691 // 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 692 // We set this value to increasingly specific values when we know what is the
673 // cause/origin of a default search change. 693 // cause/origin of a default search change.
674 DefaultSearchChangeOrigin dsp_change_origin_; 694 DefaultSearchChangeOrigin dsp_change_origin_;
675 695
676 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); 696 DISALLOW_COPY_AND_ASSIGN(TemplateURLService);
677 }; 697 };
678 698
679 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ 699 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698