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

Unified Diff: components/search_engines/template_url_service.cc

Issue 2659353002: Fix TemplateUrl::MatchesData comparison of search_terms_replacement_key (reland) (Closed)
Patch Set: Fixed after review, remove redundant check Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/search_engines/template_url.cc ('k') | components/search_engines/template_url_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/search_engines/template_url_service.cc
diff --git a/components/search_engines/template_url_service.cc b/components/search_engines/template_url_service.cc
index 0e77d27379f265169564fc3bb4cf7eff964c7a4f..2a8c241361958d8248828a1f668dc00aae5cbb67 100644
--- a/components/search_engines/template_url_service.cc
+++ b/components/search_engines/template_url_service.cc
@@ -678,6 +678,7 @@ void TemplateURLService::RepairPrepopulatedSearchEngines() {
base::AutoReset<DefaultSearchChangeOrigin> change_origin(
&dsp_change_origin_, DSP_CHANGE_PROFILE_RESET);
+ DefaultSearchManager::Source old_source = default_search_provider_source_;
default_search_manager_.ClearUserSelectedDefaultSearchEngine();
if (!default_search_provider_) {
@@ -691,6 +692,15 @@ void TemplateURLService::RepairPrepopulatedSearchEngines() {
default_search_manager_.GetDefaultSearchEngine(&source);
// ApplyDefaultSearchChange will notify observers once it is done.
ApplyDefaultSearchChange(new_dse, source);
+ } else if (old_source == DefaultSearchManager::FROM_USER) {
vasilii 2017/02/07 17:12:56 Your reasoning sounds good. It seems that we shoul
+ // We expect that if old default source was FROM_USER we could only get to
+ // fallback engine source after ClearUserSelectedDefaultSearchEngine.
+ DCHECK(default_search_provider_source_ ==
+ DefaultSearchManager::FROM_FALLBACK);
+ // Set fallback engine as user selected, because repair is considered a user
+ // action and the new engine is expected to sync to other devices.
+ default_search_manager_.SetUserSelectedDefaultSearchEngine(
+ default_search_provider_->data());
} else {
NotifyObservers();
}
@@ -1937,6 +1947,11 @@ bool TemplateURLService::ApplyDefaultSearchChangeNoMetrics(
source == DefaultSearchManager::FROM_POLICY ? data : nullptr);
}
+ // |default_search_provider_source_| must be set before calling
+ // UpdateNoNotify(), since that function needs to know the source of the
+ // update in question.
+ default_search_provider_source_ = source;
+
if (!data) {
default_search_provider_ = nullptr;
} else if (source == DefaultSearchManager::FROM_EXTENSION) {
@@ -1987,11 +2002,8 @@ bool TemplateURLService::ApplyDefaultSearchChangeNoMetrics(
prefs_->SetString(prefs::kSyncedDefaultSearchProviderGUID,
default_search_provider_->sync_guid());
}
-
}
- default_search_provider_source_ = source;
-
bool changed = default_search_provider_ != previous_default_search_engine;
if (changed)
RequestGoogleURLTrackerServerCheckIfNecessary();
« no previous file with comments | « components/search_engines/template_url.cc ('k') | components/search_engines/template_url_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698