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

Unified Diff: chrome/browser/search_engines/template_url_service.cc

Issue 12084076: Ensure post-sync TemplateURL of prepopulated engines use built-in version. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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
Index: chrome/browser/search_engines/template_url_service.cc
diff --git a/chrome/browser/search_engines/template_url_service.cc b/chrome/browser/search_engines/template_url_service.cc
index 576bc50adf6d5b8b1b34e41a7a93f4ef512028d1..6a4eca49243017254b36d0824fe3aac6e5b78892 100644
--- a/chrome/browser/search_engines/template_url_service.cc
+++ b/chrome/browser/search_engines/template_url_service.cc
@@ -1756,6 +1756,8 @@ bool TemplateURLService::UpdateNoNotify(
TemplateURLID previous_id = existing_turl->id();
existing_turl->CopyFrom(new_values);
existing_turl->data_.id = previous_id;
+ UpdatePrepopulatedTemplateURL(existing_turl);
+
UIThreadSearchTermsData new_search_terms_data(profile_);
provider_map_->Add(existing_turl, new_search_terms_data);
@@ -1805,6 +1807,22 @@ bool TemplateURLService::UpdateNoNotify(
return true;
}
+void TemplateURLService::UpdatePrepopulatedTemplateURL(
+ TemplateURL* template_url) {
+ scoped_ptr<TemplateURL> prepopulated_turl(
+ TemplateURLPrepopulateData::MakeTemplateURLFromPrepopulateId(
+ template_url->profile(), template_url->prepopulate_id()));
+ if (prepopulated_turl.get() != NULL) {
Peter Kasting 2013/01/30 22:32:33 Nit: You can remove ".get() != NULL" at this point
+ TemplateURLID id = template_url->id();
+ string16 short_name = template_url->short_name();
+ string16 keyword = template_url->keyword();
+ template_url->CopyFrom(*prepopulated_turl.get());
+ template_url->data_.short_name = short_name;
+ template_url->data_.SetKeyword(keyword);
+ template_url->data_.id = id;
+ }
+}
+
PrefService* TemplateURLService::GetPrefs() {
return profile_ ? profile_->GetPrefs() : NULL;
}
@@ -2135,7 +2153,7 @@ bool TemplateURLService::SetDefaultSearchProviderNoNotify(TemplateURL* url) {
bool TemplateURLService::AddNoNotify(TemplateURL* template_url,
bool newly_adding) {
DCHECK(template_url);
-
+ UpdatePrepopulatedTemplateURL(template_url);
if (newly_adding) {
DCHECK_EQ(kInvalidTemplateURLID, template_url->id());
DCHECK(std::find(template_urls_.begin(), template_urls_.end(),

Powered by Google App Engine
This is Rietveld 408576698