summaryrefslogtreecommitdiff
path: root/chromium/components/search_engines/template_url_service.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/components/search_engines/template_url_service.cc')
-rw-r--r--chromium/components/search_engines/template_url_service.cc21
1 files changed, 16 insertions, 5 deletions
diff --git a/chromium/components/search_engines/template_url_service.cc b/chromium/components/search_engines/template_url_service.cc
index 6ad8d799d05..646d44aa3da 100644
--- a/chromium/components/search_engines/template_url_service.cc
+++ b/chromium/components/search_engines/template_url_service.cc
@@ -2232,11 +2232,22 @@ void TemplateURLService::MergeInSyncTemplateURL(
false)) {
std::string guid = conflicting_prepopulated_turl->sync_guid();
if (conflicting_prepopulated_turl == default_search_provider_) {
- // ApplyDefaultSearchChange() may change something that requires a
- // notification, but if so, it will send out that notification, and we
- // are not involved, thus we do not update |should_notify| here.
- ApplyDefaultSearchChange(&sync_turl->data(),
- DefaultSearchManager::FROM_USER);
+ bool pref_matched =
+ prefs_->GetString(prefs::kSyncedDefaultSearchProviderGUID) ==
+ default_search_provider_->sync_guid();
+ // Update the existing engine in-place.
+ Update(default_search_provider_, TemplateURL(sync_turl->data()));
+ // If prefs::kSyncedDefaultSearchProviderGUID matched
+ // |default_search_provider_|'s GUID before, then update it to match its
+ // new GUID. If the pref didn't match before, then it probably refers to
+ // a new search engine from Sync which just hasn't been added locally
+ // yet, so leave it alone in that case.
+ if (pref_matched) {
+ prefs_->SetString(prefs::kSyncedDefaultSearchProviderGUID,
+ default_search_provider_->sync_guid());
+ }
+
+ should_add_sync_turl = false;
merge_result->set_num_items_modified(
merge_result->num_items_modified() + 1);
} else {