Skip to content

Commit

Permalink
Replace manual GoogleURLTracker update request with call to utility f…
Browse files Browse the repository at this point in the history
…unction.

This removes the forced Google URL re-check on a profile reset.  The old behavior was added to correct cases where users said "no" to a server request to use a new TLD.  Nowadays we don't prompt about this, so users can't be stuck on "the wrong" server.

BUG=244291
TEST=none

Review-Url: https://codereview.chromium.org/2799083003
Cr-Commit-Position: refs/heads/master@{#462944}
  • Loading branch information
pkasting authored and Commit bot committed Apr 7, 2017
1 parent 381d77e commit a078dc8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 42 deletions.
14 changes: 0 additions & 14 deletions chrome/browser/profile_resetter/profile_resetter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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_ =
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/navigation_correction_tab_observer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down
9 changes: 2 additions & 7 deletions components/google/core/browser/google_url_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<GoogleURLTracker::Subscription>
Expand Down
12 changes: 5 additions & 7 deletions components/google/core/browser/google_url_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Subscription> RegisterCallback(
const OnGoogleURLUpdatedCallback& cb);
Expand Down
27 changes: 14 additions & 13 deletions components/search_engines/template_url_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit a078dc8

Please sign in to comment.