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 530c6d8930e1792618664a7fd55a7878f823e72d..474c5566a2acf63cb47f4a00805502a998215a50 100644 |
--- a/chrome/browser/search_engines/template_url_service.cc |
+++ b/chrome/browser/search_engines/template_url_service.cc |
@@ -591,7 +591,8 @@ void TemplateURLService::OnWebDataServiceRequestDone( |
TemplateURL* default_search_provider = NULL; |
int new_resource_keyword_version = 0; |
GetSearchProvidersUsingKeywordResult(*result, service_.get(), profile_, |
- &template_urls, &default_search_provider, &new_resource_keyword_version); |
+ &template_urls, &default_search_provider, &new_resource_keyword_version, |
+ &pre_sync_deletes_); |
bool database_specified_a_default = (default_search_provider != NULL); |
@@ -958,6 +959,16 @@ SyncError TemplateURLService::MergeDataAndStartSyncing( |
if (!sync_turl.get()) |
continue; |
+ if (pre_sync_deletes_.find(sync_turl->sync_guid()) != |
+ pre_sync_deletes_.end()) { |
+ // This entry was deleted before the initial sync began (possibly through |
+ // preprocessing in TemplateURLService's loading code). Ignore it and send |
+ // an ACTION_DELETE up to the server. |
+ new_changes.push_back(SyncChange(SyncChange::ACTION_DELETE, |
+ iter->second)); |
+ continue; |
+ } |
+ |
if (local_turl) { |
// This local search engine is already synced. If the timestamp differs |
// from Sync, we need to update locally or to the cloud. Note that if the |
@@ -1025,6 +1036,10 @@ SyncError TemplateURLService::MergeDataAndStartSyncing( |
if (error.IsSet()) |
return error; |
+ // The ACTION_DELETEs from this set are processed. Empty it so we don't try to |
+ // reuse them on the next call to MergeDataAndStartSyncing. |
+ pre_sync_deletes_.clear(); |
+ |
models_associated_ = true; |
return SyncError(); |
} |
@@ -2210,3 +2225,8 @@ void TemplateURLService::PatchMissingSyncGUIDs( |
} |
} |
} |
+ |
+void TemplateURLService::AddPreSyncDeletedGUIDForTesting( |
+ const std::string& guid) { |
+ pre_sync_deletes_.insert(guid); |
Peter Kasting
2012/05/15 21:28:10
Why not just do this directly in the test? It has
SteveT
2012/05/16 13:26:43
True. Removed this method.
|
+} |