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

Unified Diff: chrome/browser/search_engines/util.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: Change according to pkasting comments. Created 7 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 | « chrome/browser/search_engines/util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search_engines/util.cc
diff --git a/chrome/browser/search_engines/util.cc b/chrome/browser/search_engines/util.cc
index 5329bc40a1c8e8d687d5664bd1b4a08ace8722b5..1fb4f9ab31ea66d85fe9718e64ddac93d0dd794e 100644
--- a/chrome/browser/search_engines/util.cc
+++ b/chrome/browser/search_engines/util.cc
@@ -135,6 +135,20 @@ TemplateURL* GetTemplateURLByID(
return NULL;
}
+void MergeIntoPrepopulatedEngineData(TemplateURLData* prepopulated_url,
+ const TemplateURL* original_turl) {
+ DCHECK_EQ(original_turl->prepopulate_id(), prepopulated_url->prepopulate_id);
+ if (!original_turl->safe_for_autoreplace()) {
+ prepopulated_url->safe_for_autoreplace = false;
+ prepopulated_url->SetKeyword(original_turl->keyword());
+ prepopulated_url->short_name = original_turl->short_name();
+ }
+ prepopulated_url->id = original_turl->id();
+ prepopulated_url->sync_guid = original_turl->sync_guid();
+ prepopulated_url->date_created = original_turl->date_created();
+ prepopulated_url->last_modified = original_turl->last_modified();
+}
+
// Loads engines from prepopulate data and merges them in with the existing
// engines. This is invoked when the version of the prepopulate data changes.
// If |removed_keyword_guids| is not NULL, the Sync GUID of each item removed
@@ -183,17 +197,11 @@ void MergeEnginesFromPrepopulateData(
TemplateURLData data(prepopulated_url->data());
scoped_ptr<TemplateURL> existing_url(existing_url_iter->second);
id_to_turl.erase(existing_url_iter);
- if (!existing_url->safe_for_autoreplace()) {
- data.safe_for_autoreplace = false;
- data.SetKeyword(existing_url->keyword());
- data.short_name = existing_url->short_name();
- }
- data.id = existing_url->id();
+ MergeIntoPrepopulatedEngineData(&data, existing_url.get());
// Update last_modified to ensure that if this entry is later merged with
// entries from Sync, the conflict resolution logic knows that this was
// updated and propagates the new values to the server.
data.last_modified = base::Time::Now();
- data.sync_guid = existing_url->sync_guid();
if (service)
service->UpdateKeyword(data);
« no previous file with comments | « chrome/browser/search_engines/util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698