Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/extension_sync_service.h" | 5 #include "chrome/browser/extensions/extension_sync_service.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
| 10 #include "chrome/browser/extensions/bookmark_app_helper.h" | 10 #include "chrome/browser/extensions/bookmark_app_helper.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 } | 105 } |
| 106 | 106 |
| 107 ExtensionSyncService::~ExtensionSyncService() {} | 107 ExtensionSyncService::~ExtensionSyncService() {} |
| 108 | 108 |
| 109 // static | 109 // static |
| 110 ExtensionSyncService* ExtensionSyncService::Get( | 110 ExtensionSyncService* ExtensionSyncService::Get( |
| 111 content::BrowserContext* context) { | 111 content::BrowserContext* context) { |
| 112 return ExtensionSyncServiceFactory::GetForBrowserContext(context); | 112 return ExtensionSyncServiceFactory::GetForBrowserContext(context); |
| 113 } | 113 } |
| 114 | 114 |
| 115 syncer::SyncData ExtensionSyncService::PrepareToSyncUninstallExtension( | 115 void ExtensionSyncService::SyncUninstallExtension( |
| 116 const Extension& extension) { | 116 const extensions::Extension& extension) { |
| 117 // Extract the data we need for sync now, but don't actually sync until we've | 117 if (!extensions::util::ShouldSync(&extension, profile_)) |
| 118 // completed the uninstallation. | 118 return; |
| 119 | |
| 119 // TODO(tim): If we get here and IsSyncing is false, this will cause | 120 // TODO(tim): If we get here and IsSyncing is false, this will cause |
| 120 // "back from the dead" style bugs, because sync will add-back the extension | 121 // "back from the dead" style bugs, because sync will add-back the extension |
| 121 // that was uninstalled here when MergeDataAndStartSyncing is called. | 122 // that was uninstalled here when MergeDataAndStartSyncing is called. |
| 122 // See crbug.com/256795. | 123 // See crbug.com/256795. |
| 123 syncer::ModelType type = | 124 syncer::ModelType type = |
| 124 extension.is_app() ? syncer::APPS : syncer::EXTENSIONS; | 125 extension.is_app() ? syncer::APPS : syncer::EXTENSIONS; |
| 125 const SyncBundle* bundle = GetSyncBundle(type); | 126 SyncBundle* bundle = GetSyncBundle(type); |
| 126 if (extensions::util::ShouldSync(&extension, profile_)) { | 127 if (!bundle->IsSyncing()) { |
| 127 if (bundle->IsSyncing()) | |
| 128 return CreateSyncData(extension).GetSyncData(); | |
| 129 if (extension_service_->is_ready() && !flare_.is_null()) | 128 if (extension_service_->is_ready() && !flare_.is_null()) |
| 130 flare_.Run(type); // Tell sync to start ASAP. | 129 flare_.Run(type); // Tell sync to start ASAP. |
| 130 return; | |
| 131 } | 131 } |
| 132 | 132 const std::string& id = extension.id(); |
| 133 return syncer::SyncData(); | 133 if (bundle->HasExtensionId(id)) |
| 134 } | 134 bundle->PushSyncDeletion(id, CreateSyncData(extension).GetSyncData()); |
|
not at google - send to devlin
2015/07/15 17:49:13
Btw it would be nice if this function could mostly
Marc Treib
2015/07/16 08:12:29
Yup, the other CL does just that :)
It's not (easi
| |
| 135 | |
| 136 void ExtensionSyncService::ProcessSyncUninstallExtension( | |
| 137 const std::string& extension_id, | |
| 138 const syncer::SyncData& sync_data) { | |
| 139 SyncBundle* bundle = GetSyncBundle(sync_data.GetDataType()); | |
| 140 if (bundle->HasExtensionId(extension_id)) | |
| 141 bundle->PushSyncDeletion(extension_id, sync_data); | |
| 142 } | 135 } |
| 143 | 136 |
| 144 void ExtensionSyncService::SyncEnableExtension(const Extension& extension) { | 137 void ExtensionSyncService::SyncEnableExtension(const Extension& extension) { |
| 145 // Syncing may not have started yet, so handle pending enables. | 138 // Syncing may not have started yet, so handle pending enables. |
| 146 if (extensions::util::ShouldSync(&extension, profile_)) | 139 if (extensions::util::ShouldSync(&extension, profile_)) |
| 147 GetPendingEnables(extension.is_app())->Add(extension.id()); | 140 GetPendingEnables(extension.is_app())->Add(extension.id()); |
| 148 | 141 |
| 149 SyncExtensionChangeIfNeeded(extension); | 142 SyncExtensionChangeIfNeeded(extension); |
| 150 } | 143 } |
| 151 | 144 |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 520 // non-INTERNAL location. Add to pending_sync_data, even though it will | 513 // non-INTERNAL location. Add to pending_sync_data, even though it will |
| 521 // never be removed (we'll never install a syncable version of the | 514 // never be removed (we'll never install a syncable version of the |
| 522 // extension), so that GetAllSyncData() continues to send it. | 515 // extension), so that GetAllSyncData() continues to send it. |
| 523 } | 516 } |
| 524 // Track pending extensions so that we can return them in GetAllSyncData(). | 517 // Track pending extensions so that we can return them in GetAllSyncData(). |
| 525 return false; | 518 return false; |
| 526 } | 519 } |
| 527 | 520 |
| 528 return true; | 521 return true; |
| 529 } | 522 } |
| OLD | NEW |