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> |
| 8 |
7 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
8 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/extensions/bookmark_app_helper.h" | 11 #include "chrome/browser/extensions/bookmark_app_helper.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/extensions/extension_sync_data.h" | 13 #include "chrome/browser/extensions/extension_sync_data.h" |
12 #include "chrome/browser/extensions/extension_sync_service_factory.h" | 14 #include "chrome/browser/extensions/extension_sync_service_factory.h" |
13 #include "chrome/browser/extensions/extension_util.h" | 15 #include "chrome/browser/extensions/extension_util.h" |
14 #include "chrome/browser/extensions/launch_util.h" | 16 #include "chrome/browser/extensions/launch_util.h" |
15 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/sync/glue/sync_start_util.h" | 18 #include "chrome/browser/sync/glue/sync_start_util.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 syncer::SyncMergeResult ExtensionSyncService::MergeDataAndStartSyncing( | 185 syncer::SyncMergeResult ExtensionSyncService::MergeDataAndStartSyncing( |
184 syncer::ModelType type, | 186 syncer::ModelType type, |
185 const syncer::SyncDataList& initial_sync_data, | 187 const syncer::SyncDataList& initial_sync_data, |
186 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 188 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
187 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) { | 189 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) { |
188 CHECK(sync_processor.get()); | 190 CHECK(sync_processor.get()); |
189 LOG_IF(FATAL, type != syncer::EXTENSIONS && type != syncer::APPS) | 191 LOG_IF(FATAL, type != syncer::EXTENSIONS && type != syncer::APPS) |
190 << "Got " << type << " ModelType"; | 192 << "Got " << type << " ModelType"; |
191 | 193 |
192 SyncBundle* bundle = GetSyncBundle(type); | 194 SyncBundle* bundle = GetSyncBundle(type); |
193 bundle->StartSyncing(sync_processor.Pass()); | 195 bundle->StartSyncing(std::move(sync_processor)); |
194 | 196 |
195 // 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 |
196 // recent local changes. Also tell the SyncBundle the extension IDs. | 198 // recent local changes. Also tell the SyncBundle the extension IDs. |
197 for (const syncer::SyncData& sync_data : initial_sync_data) { | 199 for (const syncer::SyncData& sync_data : initial_sync_data) { |
198 scoped_ptr<ExtensionSyncData> extension_sync_data( | 200 scoped_ptr<ExtensionSyncData> extension_sync_data( |
199 ExtensionSyncData::CreateFromSyncData(sync_data)); | 201 ExtensionSyncData::CreateFromSyncData(sync_data)); |
200 // 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 |
201 // change (we assume the local state is more recent). | 203 // change (we assume the local state is more recent). |
202 if (extension_sync_data && | 204 if (extension_sync_data && |
203 !ExtensionPrefs::Get(profile_)->NeedsSync(extension_sync_data->id())) { | 205 !ExtensionPrefs::Get(profile_)->NeedsSync(extension_sync_data->id())) { |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 sync_data_list->push_back(CreateSyncData(*extension)); | 710 sync_data_list->push_back(CreateSyncData(*extension)); |
709 } | 711 } |
710 } | 712 } |
711 } | 713 } |
712 | 714 |
713 bool ExtensionSyncService::ShouldSync(const Extension& extension) const { | 715 bool ExtensionSyncService::ShouldSync(const Extension& extension) const { |
714 // Themes are handled by the ThemeSyncableService. | 716 // Themes are handled by the ThemeSyncableService. |
715 return extensions::util::ShouldSync(&extension, profile_) && | 717 return extensions::util::ShouldSync(&extension, profile_) && |
716 !extension.is_theme(); | 718 !extension.is_theme(); |
717 } | 719 } |
OLD | NEW |