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

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, round 5 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..d88d2fc4425dc4d6bf8b4de5a4e67c2d1746d646 100644
--- a/components/search_engines/template_url_service.cc
+++ b/components/search_engines/template_url_service.cc
@@ -692,6 +692,21 @@ void TemplateURLService::RepairPrepopulatedSearchEngines() {
// ApplyDefaultSearchChange will notify observers once it is done.
ApplyDefaultSearchChange(new_dse, source);
} else {
+ // 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 =
+ default_search_manager_.GetFallbackSearchEngine();
+ if (fallback_engine_data) {
+ TemplateURL* fallback_engine =
+ FindPrepopulatedTemplateURL(fallback_engine_data->prepopulate_id);
+ // We expect that fallback engine always exists after repair.
Peter Kasting 2017/02/16 00:12:11 Nit: Maybe: "The fallback engine is created from b
Alexander Yashkin 2017/02/16 07:26:30 Thanks, done.
+ DCHECK(fallback_engine);
+ // Write fallback engine guid to sync pref. This will also set fallback
+ // engine as new user selected in
+ // OnSyncedDefaultSearchProviderGUIDChanged.
Peter Kasting 2017/02/16 00:12:11 Nit: Maybe: "Write the fallback engine's GUID to p
Alexander Yashkin 2017/02/16 07:26:30 Thanks done.
+ prefs_->SetString(prefs::kSyncedDefaultSearchProviderGUID,
+ fallback_engine->sync_guid());
+ }
NotifyObservers();
}
}
@@ -1391,7 +1406,7 @@ void TemplateURLService::Init(const Initializer* initializers,
}
DefaultSearchManager::Source source = DefaultSearchManager::FROM_USER;
- TemplateURLData* dse =
+ const TemplateURLData* dse =
default_search_manager_.GetDefaultSearchEngine(&source);
ApplyDefaultSearchChange(dse, source);
@@ -1937,6 +1952,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 +2007,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