| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 if (it == pending_updates_.end()) | 178 if (it == pending_updates_.end()) |
| 179 return false; | 179 return false; |
| 180 const PendingUpdate& pending = it->second; | 180 const PendingUpdate& pending = it->second; |
| 181 return pending.version == version && | 181 return pending.version == version && |
| 182 pending.grant_permissions_and_reenable; | 182 pending.grant_permissions_and_reenable; |
| 183 } | 183 } |
| 184 | 184 |
| 185 syncer::SyncMergeResult ExtensionSyncService::MergeDataAndStartSyncing( | 185 syncer::SyncMergeResult ExtensionSyncService::MergeDataAndStartSyncing( |
| 186 syncer::ModelType type, | 186 syncer::ModelType type, |
| 187 const syncer::SyncDataList& initial_sync_data, | 187 const syncer::SyncDataList& initial_sync_data, |
| 188 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 188 std::unique_ptr<syncer::SyncChangeProcessor> sync_processor, |
| 189 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) { | 189 std::unique_ptr<syncer::SyncErrorFactory> sync_error_factory) { |
| 190 CHECK(sync_processor.get()); | 190 CHECK(sync_processor.get()); |
| 191 LOG_IF(FATAL, type != syncer::EXTENSIONS && type != syncer::APPS) | 191 LOG_IF(FATAL, type != syncer::EXTENSIONS && type != syncer::APPS) |
| 192 << "Got " << type << " ModelType"; | 192 << "Got " << type << " ModelType"; |
| 193 | 193 |
| 194 SyncBundle* bundle = GetSyncBundle(type); | 194 SyncBundle* bundle = GetSyncBundle(type); |
| 195 bundle->StartSyncing(std::move(sync_processor)); | 195 bundle->StartSyncing(std::move(sync_processor)); |
| 196 | 196 |
| 197 // Apply the initial sync data, filtering out any items where we have more | 197 // Apply the initial sync data, filtering out any items where we have more |
| 198 // recent local changes. Also tell the SyncBundle the extension IDs. | 198 // recent local changes. Also tell the SyncBundle the extension IDs. |
| 199 for (const syncer::SyncData& sync_data : initial_sync_data) { | 199 for (const syncer::SyncData& sync_data : initial_sync_data) { |
| 200 scoped_ptr<ExtensionSyncData> extension_sync_data( | 200 std::unique_ptr<ExtensionSyncData> extension_sync_data( |
| 201 ExtensionSyncData::CreateFromSyncData(sync_data)); | 201 ExtensionSyncData::CreateFromSyncData(sync_data)); |
| 202 // If the extension has local state that needs to be synced, ignore this | 202 // If the extension has local state that needs to be synced, ignore this |
| 203 // change (we assume the local state is more recent). | 203 // change (we assume the local state is more recent). |
| 204 if (extension_sync_data && | 204 if (extension_sync_data && |
| 205 !ExtensionPrefs::Get(profile_)->NeedsSync(extension_sync_data->id())) { | 205 !ExtensionPrefs::Get(profile_)->NeedsSync(extension_sync_data->id())) { |
| 206 ApplySyncData(*extension_sync_data); | 206 ApplySyncData(*extension_sync_data); |
| 207 } | 207 } |
| 208 } | 208 } |
| 209 | 209 |
| 210 // Now push the local state to sync. | 210 // Now push the local state to sync. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 pending_extensions.begin(), | 244 pending_extensions.begin(), |
| 245 pending_extensions.end()); | 245 pending_extensions.end()); |
| 246 | 246 |
| 247 return ToSyncerSyncDataList(sync_data_list); | 247 return ToSyncerSyncDataList(sync_data_list); |
| 248 } | 248 } |
| 249 | 249 |
| 250 syncer::SyncError ExtensionSyncService::ProcessSyncChanges( | 250 syncer::SyncError ExtensionSyncService::ProcessSyncChanges( |
| 251 const tracked_objects::Location& from_here, | 251 const tracked_objects::Location& from_here, |
| 252 const syncer::SyncChangeList& change_list) { | 252 const syncer::SyncChangeList& change_list) { |
| 253 for (const syncer::SyncChange& sync_change : change_list) { | 253 for (const syncer::SyncChange& sync_change : change_list) { |
| 254 scoped_ptr<ExtensionSyncData> extension_sync_data( | 254 std::unique_ptr<ExtensionSyncData> extension_sync_data( |
| 255 ExtensionSyncData::CreateFromSyncChange(sync_change)); | 255 ExtensionSyncData::CreateFromSyncChange(sync_change)); |
| 256 if (extension_sync_data) | 256 if (extension_sync_data) |
| 257 ApplySyncData(*extension_sync_data); | 257 ApplySyncData(*extension_sync_data); |
| 258 } | 258 } |
| 259 | 259 |
| 260 ExtensionSystem::Get(profile_)->app_sorting()->FixNTPOrdinalCollisions(); | 260 ExtensionSystem::Get(profile_)->app_sorting()->FixNTPOrdinalCollisions(); |
| 261 | 261 |
| 262 return syncer::SyncError(); | 262 return syncer::SyncError(); |
| 263 } | 263 } |
| 264 | 264 |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 sync_data_list->push_back(CreateSyncData(*extension)); | 703 sync_data_list->push_back(CreateSyncData(*extension)); |
| 704 } | 704 } |
| 705 } | 705 } |
| 706 } | 706 } |
| 707 | 707 |
| 708 bool ExtensionSyncService::ShouldSync(const Extension& extension) const { | 708 bool ExtensionSyncService::ShouldSync(const Extension& extension) const { |
| 709 // Themes are handled by the ThemeSyncableService. | 709 // Themes are handled by the ThemeSyncableService. |
| 710 return extensions::util::ShouldSync(&extension, profile_) && | 710 return extensions::util::ShouldSync(&extension, profile_) && |
| 711 !extension.is_theme(); | 711 !extension.is_theme(); |
| 712 } | 712 } |
| OLD | NEW |