diff options
| author | hashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-08 02:40:32 +0000 | 
|---|---|---|
| committer | hashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-08 02:40:32 +0000 | 
| commit | 26580af76617018859cdf0ed0cedc25a86ba3829 (patch) | |
| tree | 132e7f928eb8ee55eaf7e31f70bf9c8f51e6f1f8 | |
| parent | ed2f7cc17513aa39e5e69abc18a985eff7b36dd9 (diff) | |
| download | chromium_src-26580af76617018859cdf0ed0cedc25a86ba3829.zip chromium_src-26580af76617018859cdf0ed0cedc25a86ba3829.tar.gz chromium_src-26580af76617018859cdf0ed0cedc25a86ba3829.tar.bz2 | |
Remove arguments from GoogleURLTracker::OnGoogleURLUpdatedCallback
BUG=389705
TEST=git cl try
TBR=kmadhusu@chromium.org for argument removal in chrome/browser/search/instant_unittest_base.cc
Review URL: https://codereview.chromium.org/370993002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281640 0039d316-1c4b-4281-b951-d872f2087c98
10 files changed, 39 insertions, 46 deletions
| diff --git a/chrome/browser/google/google_url_tracker_unittest.cc b/chrome/browser/google/google_url_tracker_unittest.cc index fa7efb7..06bb385 100644 --- a/chrome/browser/google/google_url_tracker_unittest.cc +++ b/chrome/browser/google/google_url_tracker_unittest.cc @@ -39,7 +39,7 @@ class TestCallbackListener {    void clear_notified() { notified_ = false; }   private: -  void OnGoogleURLUpdated(GURL old_url, GURL new_url); +  void OnGoogleURLUpdated();    bool notified_;    scoped_ptr<GoogleURLTracker::Subscription> google_url_updated_subscription_; @@ -51,7 +51,7 @@ TestCallbackListener::TestCallbackListener() : notified_(false) {  TestCallbackListener::~TestCallbackListener() {  } -void TestCallbackListener::OnGoogleURLUpdated(GURL old_url, GURL new_url) { +void TestCallbackListener::OnGoogleURLUpdated() {    notified_ = true;  } @@ -71,7 +71,7 @@ void TestCallbackListener::RegisterCallback(  class TestGoogleURLTrackerClient : public GoogleURLTrackerClient {   public: -  TestGoogleURLTrackerClient(Profile* profile_); +  explicit TestGoogleURLTrackerClient(Profile* profile_);    virtual ~TestGoogleURLTrackerClient();    virtual void SetListeningForNavigationStart(bool listen) OVERRIDE; diff --git a/chrome/browser/search/instant_unittest_base.cc b/chrome/browser/search/instant_unittest_base.cc index 00c0fed..23aa5ed 100644 --- a/chrome/browser/search/instant_unittest_base.cc +++ b/chrome/browser/search/instant_unittest_base.cc @@ -74,8 +74,7 @@ void InstantUnitTestBase::NotifyGoogleBaseURLUpdate(    // UIThreadSearchTermsData::GoogleBaseURLValue()    // For simulating test behavior, this is overridden below.    UIThreadSearchTermsData::SetGoogleBaseURL(new_google_base_url); -  TemplateURLServiceFactory::GetForProfile(profile())->OnGoogleURLUpdated( -      GURL("https://www.google.com"), GURL(new_google_base_url)); +  TemplateURLServiceFactory::GetForProfile(profile())->GoogleBaseURLChanged();  }  bool InstantUnitTestBase::IsInstantServiceObserver( diff --git a/chrome/browser/search_engines/search_provider_install_data.cc b/chrome/browser/search_engines/search_provider_install_data.cc index 4c0c91c..69920d2 100644 --- a/chrome/browser/search_engines/search_provider_install_data.cc +++ b/chrome/browser/search_engines/search_provider_install_data.cc @@ -118,7 +118,7 @@ void GoogleURLChangeNotifier::OnChange(const std::string& google_base_url) {  // to the SearchProviderInstallData on the I/O thread.  class GoogleURLObserver : public content::RenderProcessHostObserver {   public: -  GoogleURLObserver(Profile* profile, +  GoogleURLObserver(GoogleURLTracker* google_url_tracker,                      GoogleURLChangeNotifier* change_notifier,                      content::RenderProcessHost* host); @@ -130,8 +130,9 @@ class GoogleURLObserver : public content::RenderProcessHostObserver {    virtual ~GoogleURLObserver() {}    // Callback that is called when the Google URL is updated. -  void OnGoogleURLUpdated(GURL old_url, GURL new_url); +  void OnGoogleURLUpdated(); +  GoogleURLTracker* google_url_tracker_;    scoped_refptr<GoogleURLChangeNotifier> change_notifier_;    scoped_ptr<GoogleURLTracker::Subscription> google_url_updated_subscription_; @@ -140,29 +141,24 @@ class GoogleURLObserver : public content::RenderProcessHostObserver {  };  GoogleURLObserver::GoogleURLObserver( -    Profile* profile, +    GoogleURLTracker* google_url_tracker,      GoogleURLChangeNotifier* change_notifier,      content::RenderProcessHost* host) -    : change_notifier_(change_notifier) { +    : google_url_tracker_(google_url_tracker), +      change_notifier_(change_notifier) {    DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); -  GoogleURLTracker* google_url_tracker = -      GoogleURLTrackerFactory::GetForProfile(profile); - -  // GoogleURLTracker is not created in tests. -  if (google_url_tracker) { -    google_url_updated_subscription_ = -        google_url_tracker->RegisterCallback(base::Bind( -            &GoogleURLObserver::OnGoogleURLUpdated, base::Unretained(this))); -  } +  google_url_updated_subscription_ = +      google_url_tracker_->RegisterCallback(base::Bind( +          &GoogleURLObserver::OnGoogleURLUpdated, base::Unretained(this)));    host->AddObserver(this);  } -void GoogleURLObserver::OnGoogleURLUpdated(GURL old_url, GURL new_url) { +void GoogleURLObserver::OnGoogleURLUpdated() {    BrowserThread::PostTask(BrowserThread::IO,                            FROM_HERE,                            base::Bind(&GoogleURLChangeNotifier::OnChange,                                       change_notifier_.get(), -                                     new_url.spec())); +                                     google_url_tracker_->google_url().spec()));  }  void GoogleURLObserver::RenderProcessHostDestroyed( @@ -190,11 +186,17 @@ SearchProviderInstallData::SearchProviderInstallData(      : template_url_service_(TemplateURLServiceFactory::GetForProfile(profile)),        google_base_url_(UIThreadSearchTermsData(profile).GoogleBaseURLValue()),        weak_factory_(this) { -  // GoogleURLObserver is responsible for killing itself when -  // the given notification occurs. -  new GoogleURLObserver(profile, -                        new GoogleURLChangeNotifier(weak_factory_.GetWeakPtr()), -                        host); +  // GoogleURLTracker is not created in tests. +  GoogleURLTracker* google_url_tracker = +      GoogleURLTrackerFactory::GetForProfile(profile); +  if (google_url_tracker) { +    // GoogleURLObserver is responsible for killing itself when +    // the given notification occurs. +    new GoogleURLObserver( +        google_url_tracker, +        new GoogleURLChangeNotifier(weak_factory_.GetWeakPtr()), +        host); +  }  }  SearchProviderInstallData::~SearchProviderInstallData() { diff --git a/chrome/browser/search_engines/template_url_service_test_util.cc b/chrome/browser/search_engines/template_url_service_test_util.cc index 011e0eb..73b412a 100644 --- a/chrome/browser/search_engines/template_url_service_test_util.cc +++ b/chrome/browser/search_engines/template_url_service_test_util.cc @@ -134,10 +134,8 @@ void TemplateURLServiceTestUtilBase::SetGoogleBaseURL(      const GURL& base_url) const {    DCHECK(base_url.is_valid());    UIThreadSearchTermsData data(profile()); -  GURL old_url = GURL(data.GoogleBaseURLValue());    UIThreadSearchTermsData::SetGoogleBaseURL(base_url.spec()); -  TemplateURLServiceFactory::GetForProfile(profile()) -      ->OnGoogleURLUpdated(old_url, base_url); +  TemplateURLServiceFactory::GetForProfile(profile())->GoogleBaseURLChanged();  }  void TemplateURLServiceTestUtilBase::SetManagedDefaultSearchPreferences( diff --git a/chrome/browser/ui/navigation_correction_tab_observer.cc b/chrome/browser/ui/navigation_correction_tab_observer.cc index f1382f8..53c4326 100644 --- a/chrome/browser/ui/navigation_correction_tab_observer.cc +++ b/chrome/browser/ui/navigation_correction_tab_observer.cc @@ -69,8 +69,7 @@ void NavigationCorrectionTabObserver::RenderViewCreated(  ////////////////////////////////////////////////////////////////////////////////  // Internal helpers -void NavigationCorrectionTabObserver::OnGoogleURLUpdated(GURL old_url, -                                                         GURL new_url) { +void NavigationCorrectionTabObserver::OnGoogleURLUpdated() {    UpdateNavigationCorrectionInfo(web_contents()->GetRenderViewHost());  } diff --git a/chrome/browser/ui/navigation_correction_tab_observer.h b/chrome/browser/ui/navigation_correction_tab_observer.h index 1b0a9bf..a0f44d9 100644 --- a/chrome/browser/ui/navigation_correction_tab_observer.h +++ b/chrome/browser/ui/navigation_correction_tab_observer.h @@ -36,7 +36,7 @@ class NavigationCorrectionTabObserver    // Internal helpers ----------------------------------------------------------    // Callback that is called when the Google URL is updated. -  void OnGoogleURLUpdated(GURL old_url, GURL new_url); +  void OnGoogleURLUpdated();    // Returns the URL for the correction service.  If the returned URL    // is empty, the default error pages will be used. diff --git a/components/google/core/browser/google_url_tracker.cc b/components/google/core/browser/google_url_tracker.cc index 1210f90..0864f6a 100644 --- a/components/google/core/browser/google_url_tracker.cc +++ b/components/google/core/browser/google_url_tracker.cc @@ -92,7 +92,7 @@ void GoogleURLTracker::AcceptGoogleURL(bool redo_searches) {    PrefService* prefs = client_->GetPrefs();    prefs->SetString(prefs::kLastKnownGoogleURL, google_url_.spec());    prefs->SetString(prefs::kLastPromptedGoogleURL, google_url_.spec()); -  NotifyGoogleURLUpdated(old_google_url, google_url_); +  NotifyGoogleURLUpdated();    need_to_prompt_ = false;    CloseAllEntries(redo_searches); @@ -398,6 +398,6 @@ void GoogleURLTracker::UnregisterForEntrySpecificNotifications(    }  } -void GoogleURLTracker::NotifyGoogleURLUpdated(GURL old_url, GURL new_url) { -  callback_list_.Notify(old_url, new_url); +void GoogleURLTracker::NotifyGoogleURLUpdated() { +  callback_list_.Notify();  } diff --git a/components/google/core/browser/google_url_tracker.h b/components/google/core/browser/google_url_tracker.h index dc9f13d..644555d 100644 --- a/components/google/core/browser/google_url_tracker.h +++ b/components/google/core/browser/google_url_tracker.h @@ -46,8 +46,8 @@ class GoogleURLTracker : public net::URLFetcherDelegate,   public:    // Callback that is called when the Google URL is updated. The arguments are    // the old and new URLs. -  typedef base::Callback<void(GURL, GURL)> OnGoogleURLUpdatedCallback; -  typedef base::CallbackList<void(GURL, GURL)> CallbackList; +  typedef base::Callback<void()> OnGoogleURLUpdatedCallback; +  typedef base::CallbackList<void()> CallbackList;    typedef CallbackList::Subscription Subscription;    // The constructor does different things depending on which of these values @@ -163,7 +163,7 @@ class GoogleURLTracker : public net::URLFetcherDelegate,        GoogleURLTrackerMapEntry* map_entry,        bool must_be_listening_for_commit); -  void NotifyGoogleURLUpdated(GURL old_url, GURL new_url); +  void NotifyGoogleURLUpdated();    CallbackList callback_list_; diff --git a/components/search_engines/template_url_service.cc b/components/search_engines/template_url_service.cc index 3eb3334..205eea7 100644 --- a/components/search_engines/template_url_service.cc +++ b/components/search_engines/template_url_service.cc @@ -1417,7 +1417,7 @@ void TemplateURLService::Init(const Initializer* initializers,    if (google_url_tracker_) {      google_url_updated_subscription_ =          google_url_tracker_->RegisterCallback(base::Bind( -            &TemplateURLService::OnGoogleURLUpdated, base::Unretained(this))); +            &TemplateURLService::GoogleBaseURLChanged, base::Unretained(this)));    }    if (prefs_) { @@ -1773,6 +1773,9 @@ void TemplateURLService::RequestGoogleURLTrackerServerCheckIfNecessary() {  }  void TemplateURLService::GoogleBaseURLChanged() { +  if (!loaded_) +    return; +    KeywordWebDataService::BatchModeScoper scoper(web_data_service_.get());    bool something_changed = false;    for (TemplateURLVector::iterator i(template_urls_.begin()); @@ -1807,11 +1810,6 @@ void TemplateURLService::GoogleBaseURLChanged() {      NotifyObservers();  } -void TemplateURLService::OnGoogleURLUpdated(GURL old_url, GURL new_url) { -  if (loaded_) -    GoogleBaseURLChanged(); -} -  void TemplateURLService::OnDefaultSearchChange(      const TemplateURLData* data,      DefaultSearchManager::Source source) { diff --git a/components/search_engines/template_url_service.h b/components/search_engines/template_url_service.h index 9e1ed61..da49772 100644 --- a/components/search_engines/template_url_service.h +++ b/components/search_engines/template_url_service.h @@ -454,9 +454,6 @@ class TemplateURLService : public WebDataServiceConsumer,    // Transitions to the loaded state.    void ChangeToLoadedState(); -  // Callback that is called when the Google URL is updated. -  void OnGoogleURLUpdated(GURL old_url, GURL new_url); -    // Called by DefaultSearchManager when the effective default search engine has    // changed.    void OnDefaultSearchChange(const TemplateURLData* new_dse_data, | 
