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

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

Issue 287103002: Introduce ability to register callback with GoogleURLTracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Response to review Created 6 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 | Annotate | Revision Log
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>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/callback_list.h" 14 #include "base/callback_list.h"
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/observer_list.h" 17 #include "base/observer_list.h"
18 #include "base/prefs/pref_change_registrar.h" 18 #include "base/prefs/pref_change_registrar.h"
19 #include "chrome/browser/google/google_url_tracker.h"
19 #include "chrome/browser/search_engines/default_search_manager.h" 20 #include "chrome/browser/search_engines/default_search_manager.h"
20 #include "chrome/browser/search_engines/template_url_id.h" 21 #include "chrome/browser/search_engines/template_url_id.h"
21 #include "chrome/browser/webdata/web_data_service.h" 22 #include "chrome/browser/webdata/web_data_service.h"
22 #include "components/keyed_service/core/keyed_service.h" 23 #include "components/keyed_service/core/keyed_service.h"
23 #include "content/public/browser/notification_observer.h" 24 #include "content/public/browser/notification_observer.h"
24 #include "content/public/browser/notification_registrar.h" 25 #include "content/public/browser/notification_registrar.h"
25 #include "sync/api/sync_change.h" 26 #include "sync/api/sync_change.h"
26 #include "sync/api/syncable_service.h" 27 #include "sync/api/syncable_service.h"
27 28
28 class GURL; 29 class GURL;
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, ChangeGoogleBaseValue); 425 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, ChangeGoogleBaseValue);
425 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, MergeDeletesUnusedProviders); 426 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceTest, MergeDeletesUnusedProviders);
426 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, UniquifyKeyword); 427 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, UniquifyKeyword);
427 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, 428 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest,
428 IsLocalTemplateURLBetter); 429 IsLocalTemplateURLBetter);
429 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, 430 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest,
430 ResolveSyncKeywordConflict); 431 ResolveSyncKeywordConflict);
431 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, PreSyncDeletes); 432 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, PreSyncDeletes);
432 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, MergeInSyncTemplateURL); 433 FRIEND_TEST_ALL_PREFIXES(TemplateURLServiceSyncTest, MergeInSyncTemplateURL);
433 434
435 friend class InstantUnitTestBase;
434 friend class TemplateURLServiceTestUtilBase; 436 friend class TemplateURLServiceTestUtilBase;
435 437
436 typedef std::map<base::string16, TemplateURL*> KeywordToTemplateMap; 438 typedef std::map<base::string16, TemplateURL*> KeywordToTemplateMap;
437 typedef std::map<std::string, TemplateURL*> GUIDToTemplateMap; 439 typedef std::map<std::string, TemplateURL*> GUIDToTemplateMap;
438 440
439 // Declaration of values to be used in an enumerated histogram to tally 441 // Declaration of values to be used in an enumerated histogram to tally
440 // changes to the default search provider from various entry points. In 442 // changes to the default search provider from various entry points. In
441 // particular, we use this to see what proportion of changes are from Sync 443 // particular, we use this to see what proportion of changes are from Sync
442 // entry points, to help spot erroneous Sync activity. 444 // entry points, to help spot erroneous Sync activity.
443 enum DefaultSearchChangeOrigin { 445 enum DefaultSearchChangeOrigin {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 // This does NOT notify the delegate or the database. 481 // This does NOT notify the delegate or the database.
480 // 482 //
481 // This transfers ownership of the elements in |urls| to |this|, and may 483 // This transfers ownership of the elements in |urls| to |this|, and may
482 // delete some elements, so it's not safe for callers to access any elements 484 // delete some elements, so it's not safe for callers to access any elements
483 // after calling; to reinforce this, this function clears |urls| on exit. 485 // after calling; to reinforce this, this function clears |urls| on exit.
484 void SetTemplateURLs(TemplateURLVector* urls); 486 void SetTemplateURLs(TemplateURLVector* urls);
485 487
486 // Transitions to the loaded state. 488 // Transitions to the loaded state.
487 void ChangeToLoadedState(); 489 void ChangeToLoadedState();
488 490
491 // Callback that is called when the Google URL is updated.
492 void OnGoogleURLUpdated(GURL old_url, GURL new_url);
493
489 // Called by DefaultSearchManager when the effective default search engine has 494 // Called by DefaultSearchManager when the effective default search engine has
490 // changed. 495 // changed.
491 void OnDefaultSearchChange(const TemplateURLData* new_dse_data, 496 void OnDefaultSearchChange(const TemplateURLData* new_dse_data,
492 DefaultSearchManager::Source source); 497 DefaultSearchManager::Source source);
493 498
494 // Applies a DSE change. May be called at startup or after transitioning to 499 // Applies a DSE change. May be called at startup or after transitioning to
495 // the loaded state. 500 // the loaded state.
496 void ApplyDefaultSearchChange(const TemplateURLData* new_dse_data, 501 void ApplyDefaultSearchChange(const TemplateURLData* new_dse_data,
497 DefaultSearchManager::Source source); 502 DefaultSearchManager::Source source);
498 503
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 // We set this value to increasingly specific values when we know what is the 770 // We set this value to increasingly specific values when we know what is the
766 // cause/origin of a default search change. 771 // cause/origin of a default search change.
767 DefaultSearchChangeOrigin dsp_change_origin_; 772 DefaultSearchChangeOrigin dsp_change_origin_;
768 773
769 // Stores a list of callbacks to be run after TemplateURLService has loaded. 774 // Stores a list of callbacks to be run after TemplateURLService has loaded.
770 base::CallbackList<void(void)> on_loaded_callbacks_; 775 base::CallbackList<void(void)> on_loaded_callbacks_;
771 776
772 // Helper class to manage the default search engine. 777 // Helper class to manage the default search engine.
773 DefaultSearchManager default_search_manager_; 778 DefaultSearchManager default_search_manager_;
774 779
780 scoped_ptr<GoogleURLTracker::Subscription> google_url_updated_subscription_;
781
775 // Used to disable the prepopulated search engines in tests. 782 // Used to disable the prepopulated search engines in tests.
776 static bool g_fallback_search_engines_disabled; 783 static bool g_fallback_search_engines_disabled;
777 784
778 DISALLOW_COPY_AND_ASSIGN(TemplateURLService); 785 DISALLOW_COPY_AND_ASSIGN(TemplateURLService);
779 }; 786 };
780 787
781 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_ 788 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698