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

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: Android compilation error 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();
221
222 // Clears non-extension URLs and reloads again prepopulated engines.
223 // Resets the default engine unless it's managed.
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.
595 // |default_search_provider| specifies URL inside |*template_urls|.
596 void AddTemplateURLsAndSetupDefaultEngine(
597 TemplateURLVector* template_urls,
battre 2013/05/22 14:03:37 pass as const-ref or indicate that this is an opti
vasilii 2013/05/22 18:54:08 The method consumes |template_urls| and modifies i
598 TemplateURL* default_search_provider);
599
600 // This sets the default search engine to FindNewDefaultSearchProvider(),
601 // if it's unmanaged and NULL.
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
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698