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

Unified Diff: chrome/browser/extensions/extension_sync_service.cc

Issue 1778923003: Fix extensions sync in cases where items change type (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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/extensions/extension_sync_service.cc
diff --git a/chrome/browser/extensions/extension_sync_service.cc b/chrome/browser/extensions/extension_sync_service.cc
index 6d6b3af16598872e5a2b952252dff120ab01499e..ce8ad0eaa9401f9f8b5752e5b149b18752679273 100644
--- a/chrome/browser/extensions/extension_sync_service.cc
+++ b/chrome/browser/extensions/extension_sync_service.cc
@@ -319,24 +319,16 @@ void ExtensionSyncService::ApplySyncData(
: syncer::EXTENSIONS;
const std::string& id = extension_sync_data.id();
SyncBundle* bundle = GetSyncBundle(type);
+ DCHECK(bundle->IsSyncing());
// Note: |extension| may be null if it hasn't been installed yet.
const Extension* extension =
ExtensionRegistry::Get(profile_)->GetInstalledExtension(id);
- // TODO(bolms): we should really handle this better. The particularly bad
- // case is where an app becomes an extension or vice versa, and we end up with
- // a zombie extension that won't go away.
- // TODO(treib): Is this still true?
if (extension && !IsCorrectSyncType(*extension, type)) {
- // Special hack: There was a bug where themes incorrectly ended up in the
- // syncer::EXTENSIONS type. If we get incoming sync data for a theme, clean
- // it up. crbug.com/558299
- // TODO(treib,devlin): Remove this after M52 or so.
- if (extension->is_theme()) {
- // First tell the bundle about the extension, so that it won't just ignore
- // the deletion.
- bundle->ApplySyncData(extension_sync_data);
- bundle->PushSyncDeletion(id, extension_sync_data.GetSyncData());
- }
+ // The installed item isn't the same type as the sync data item, so we need
+ // to remove the sync data item; otherwise it will be a zombie that will
+ // keep coming back even if the installed item with this id is uninstalled.
+ bundle->ApplySyncData(extension_sync_data);
+ bundle->PushSyncDeletion(id, extension_sync_data.GetSyncData());
asargent_no_longer_on_chrome 2016/03/09 23:28:07 treib/devlin: I noticed that we originally added t
Marc Treib 2016/03/10 10:36:34 It was meant as a temporary hack at that point, an
asargent_no_longer_on_chrome 2016/03/11 23:40:59 added comment back in
return;
}
@@ -602,8 +594,13 @@ void ExtensionSyncService::OnExtensionInstalled(
auto it = pending_updates_.find(extension->id());
if (it != pending_updates_.end()) {
int compare_result = extension->version()->CompareTo(it->second.version);
- if (compare_result == 0 && it->second.grant_permissions_and_reenable)
+ if (compare_result == 0 && it->second.grant_permissions_and_reenable) {
+ // The call to SyncExtensionChangeIfNeeded below will take care of syncing
+ // changes to this extension, so we don't want to trigger sync activity
+ // from the call to GrantPermissionsAndEnableExtension.
Marc Treib 2016/03/10 10:36:34 Ooh, nice catch!
+ base::AutoReset<bool> ignore_updates(&ignore_updates_, true);
extension_service()->GrantPermissionsAndEnableExtension(extension);
+ }
if (compare_result >= 0)
pending_updates_.erase(it);
}

Powered by Google App Engine
This is Rietveld 408576698