diff --git a/chrome/browser/profile_resetter/profile_resetter.cc b/chrome/browser/profile_resetter/profile_resetter.cc index d9ef5a1e58e2bc..b23f2d40c82b3a 100644 --- a/chrome/browser/profile_resetter/profile_resetter.cc +++ b/chrome/browser/profile_resetter/profile_resetter.cc @@ -18,7 +18,6 @@ #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" #include "chrome/browser/content_settings/host_content_settings_map_factory.h" #include "chrome/browser/extensions/extension_service.h" -#include "chrome/browser/google/google_url_tracker_factory.h" #include "chrome/browser/profile_resetter/brandcoded_default_settings.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/search_engines/template_url_service_factory.h" @@ -32,7 +31,6 @@ #include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/content_settings/core/browser/website_settings_info.h" #include "components/content_settings/core/browser/website_settings_registry.h" -#include "components/google/core/browser/google_url_tracker.h" #include "components/prefs/pref_service.h" #include "components/prefs/scoped_user_pref_update.h" #include "components/search_engines/search_engines_pref_names.h" @@ -183,18 +181,6 @@ void ProfileResetter::ResetDefaultSearchEngine() { template_url_service_->RepairPrepopulatedSearchEngines(); - // Reset Google search URL. - const TemplateURL* default_search_provider = - template_url_service_->GetDefaultSearchProvider(); - if (default_search_provider && - default_search_provider->HasGoogleBaseURLs( - template_url_service_->search_terms_data())) { - GoogleURLTracker* tracker = - GoogleURLTrackerFactory::GetForProfile(profile_); - if (tracker) - tracker->RequestServerCheck(true); - } - MarkAsDone(DEFAULT_SEARCH_ENGINE); } else { template_url_service_sub_ = diff --git a/chrome/browser/ui/navigation_correction_tab_observer.cc b/chrome/browser/ui/navigation_correction_tab_observer.cc index ad27f82cb8e28f..96adf845352cda 100644 --- a/chrome/browser/ui/navigation_correction_tab_observer.cc +++ b/chrome/browser/ui/navigation_correction_tab_observer.cc @@ -42,7 +42,7 @@ NavigationCorrectionTabObserver::NavigationCorrectionTabObserver( if (google_util::IsGoogleDomainUrl(GetNavigationCorrectionURL(), google_util::ALLOW_SUBDOMAIN, google_util::ALLOW_NON_STANDARD_PORTS)) - google_url_tracker->RequestServerCheck(false); + google_url_tracker->RequestServerCheck(); google_url_updated_subscription_ = google_url_tracker->RegisterCallback( base::Bind(&NavigationCorrectionTabObserver::OnGoogleURLUpdated, base::Unretained(this))); diff --git a/components/google/core/browser/google_url_tracker.cc b/components/google/core/browser/google_url_tracker.cc index 4f4a9a4411e63a..e16f3277604992 100644 --- a/components/google/core/browser/google_url_tracker.cc +++ b/components/google/core/browser/google_url_tracker.cc @@ -74,14 +74,9 @@ void GoogleURLTracker::RegisterProfilePrefs( registry->RegisterStringPref(prefs::kLastPromptedGoogleURL, std::string()); } -void GoogleURLTracker::RequestServerCheck(bool force) { - // If this instance already has a fetcher, SetNeedToFetch() is unnecessary, - // and changing |already_fetched_| is wrong. - if (!fetcher_) { - if (force) - already_fetched_ = false; +void GoogleURLTracker::RequestServerCheck() { + if (!fetcher_) SetNeedToFetch(); - } } std::unique_ptr diff --git a/components/google/core/browser/google_url_tracker.h b/components/google/core/browser/google_url_tracker.h index 27496a6af7901d..5d0ba62a4e3744 100644 --- a/components/google/core/browser/google_url_tracker.h +++ b/components/google/core/browser/google_url_tracker.h @@ -65,13 +65,11 @@ class GoogleURLTracker const GURL& google_url() const { return google_url_; } // Requests that the tracker perform a server check to update the Google URL - // as necessary. If |force| is false, this will happen at most once per - // network change, not sooner than five seconds after startup (checks - // requested before that time will occur then; checks requested afterwards - // will occur immediately, if no other checks have been made during this run). - // If |force| is true, and the tracker has already performed any requested - // check, it will check again. - void RequestServerCheck(bool force); + // as necessary. This will happen at most once per network change, not sooner + // than five seconds after startup (checks requested before that time will + // occur then; checks requested afterwards will occur immediately, if no other + // checks have been made during this run). + void RequestServerCheck(); std::unique_ptr RegisterCallback( const OnGoogleURLUpdatedCallback& cb); diff --git a/components/search_engines/template_url_service.cc b/components/search_engines/template_url_service.cc index 0a8eceda680385..02bfb5ef463b22 100644 --- a/components/search_engines/template_url_service.cc +++ b/components/search_engines/template_url_service.cc @@ -671,18 +671,7 @@ void TemplateURLService::RepairPrepopulatedSearchEngines() { default_search_manager_.ClearUserSelectedDefaultSearchEngine(); - if (!default_search_provider_) { - // If the default search provider came from a user pref we would have been - // notified of the new (fallback-provided) value in - // ClearUserSelectedDefaultSearchEngine() above. Since we are here, the - // value was presumably originally a fallback value (which may have been - // repaired). - DefaultSearchManager::Source source; - const TemplateURLData* new_dse = - default_search_manager_.GetDefaultSearchEngine(&source); - // ApplyDefaultSearchChange will notify observers once it is done. - ApplyDefaultSearchChange(new_dse, source); - } else { + if (default_search_provider_) { // Set fallback engine as user selected, because repair is considered a user // action and we are expected to sync new fallback engine to other devices. const TemplateURLData* fallback_engine_data = @@ -701,6 +690,18 @@ void TemplateURLService::RepairPrepopulatedSearchEngines() { fallback_engine->sync_guid()); } NotifyObservers(); + RequestGoogleURLTrackerServerCheckIfNecessary(); + } else { + // If the default search provider came from a user pref we would have been + // notified of the new (fallback-provided) value in + // ClearUserSelectedDefaultSearchEngine() above. Since we are here, the + // value was presumably originally a fallback value (which may have been + // repaired). + DefaultSearchManager::Source source; + const TemplateURLData* new_dse = + default_search_manager_.GetDefaultSearchEngine(&source); + // ApplyDefaultSearchChange will notify observers once it is done. + ApplyDefaultSearchChange(new_dse, source); } } @@ -1829,7 +1830,7 @@ void TemplateURLService::RequestGoogleURLTrackerServerCheckIfNecessary() { if (default_search_provider_ && default_search_provider_->HasGoogleBaseURLs(search_terms_data()) && google_url_tracker_) - google_url_tracker_->RequestServerCheck(false); + google_url_tracker_->RequestServerCheck(); } void TemplateURLService::GoogleBaseURLChanged() {