| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 extension.get(), error)) { | 699 extension.get(), error)) { |
| 700 content::NotificationService::current()->Notify( | 700 content::NotificationService::current()->Notify( |
| 701 chrome::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED, | 701 chrome::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED, |
| 702 content::Source<Profile>(profile_), | 702 content::Source<Profile>(profile_), |
| 703 content::Details<const Extension>(extension)); | 703 content::Details<const Extension>(extension)); |
| 704 return false; | 704 return false; |
| 705 } | 705 } |
| 706 | 706 |
| 707 // Extract the data we need for sync now, but don't actually sync until we've | 707 // Extract the data we need for sync now, but don't actually sync until we've |
| 708 // completed the uninstallation. | 708 // completed the uninstallation. |
| 709 csync::SyncChange sync_change; | 709 syncer::SyncChange sync_change; |
| 710 if (app_sync_bundle_.HandlesApp(*extension)) { | 710 if (app_sync_bundle_.HandlesApp(*extension)) { |
| 711 sync_change = app_sync_bundle_.CreateSyncChangeToDelete(extension); | 711 sync_change = app_sync_bundle_.CreateSyncChangeToDelete(extension); |
| 712 } else if (extension_sync_bundle_.HandlesExtension(*extension)) { | 712 } else if (extension_sync_bundle_.HandlesExtension(*extension)) { |
| 713 sync_change = extension_sync_bundle_.CreateSyncChangeToDelete(extension); | 713 sync_change = extension_sync_bundle_.CreateSyncChangeToDelete(extension); |
| 714 } | 714 } |
| 715 | 715 |
| 716 UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallType", | 716 UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallType", |
| 717 extension->GetType(), 100); | 717 extension->GetType(), 100); |
| 718 RecordPermissionMessagesHistogram( | 718 RecordPermissionMessagesHistogram( |
| 719 extension, "Extensions.Permissions_Uninstall"); | 719 extension, "Extensions.Permissions_Uninstall"); |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1184 // Sync can start updating before all the external providers are ready | 1184 // Sync can start updating before all the external providers are ready |
| 1185 // during startup. Start the update as soon as those providers are ready, | 1185 // during startup. Start the update as soon as those providers are ready, |
| 1186 // but not before. | 1186 // but not before. |
| 1187 update_once_all_providers_are_ready_ = true; | 1187 update_once_all_providers_are_ready_ = true; |
| 1188 } | 1188 } |
| 1189 } else { | 1189 } else { |
| 1190 LOG(WARNING) << "CheckForUpdatesSoon() called with auto-update turned off"; | 1190 LOG(WARNING) << "CheckForUpdatesSoon() called with auto-update turned off"; |
| 1191 } | 1191 } |
| 1192 } | 1192 } |
| 1193 | 1193 |
| 1194 csync::SyncError ExtensionService::MergeDataAndStartSyncing( | 1194 syncer::SyncError ExtensionService::MergeDataAndStartSyncing( |
| 1195 syncable::ModelType type, | 1195 syncable::ModelType type, |
| 1196 const csync::SyncDataList& initial_sync_data, | 1196 const syncer::SyncDataList& initial_sync_data, |
| 1197 scoped_ptr<csync::SyncChangeProcessor> sync_processor, | 1197 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
| 1198 scoped_ptr<csync::SyncErrorFactory> sync_error_factory) { | 1198 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) { |
| 1199 CHECK(sync_processor.get()); | 1199 CHECK(sync_processor.get()); |
| 1200 CHECK(sync_error_factory.get()); | 1200 CHECK(sync_error_factory.get()); |
| 1201 | 1201 |
| 1202 switch (type) { | 1202 switch (type) { |
| 1203 case syncable::EXTENSIONS: | 1203 case syncable::EXTENSIONS: |
| 1204 extension_sync_bundle_.SetupSync(sync_processor.release(), | 1204 extension_sync_bundle_.SetupSync(sync_processor.release(), |
| 1205 sync_error_factory.release(), | 1205 sync_error_factory.release(), |
| 1206 initial_sync_data); | 1206 initial_sync_data); |
| 1207 break; | 1207 break; |
| 1208 | 1208 |
| 1209 case syncable::APPS: | 1209 case syncable::APPS: |
| 1210 app_sync_bundle_.SetupSync(sync_processor.release(), | 1210 app_sync_bundle_.SetupSync(sync_processor.release(), |
| 1211 sync_error_factory.release(), | 1211 sync_error_factory.release(), |
| 1212 initial_sync_data); | 1212 initial_sync_data); |
| 1213 break; | 1213 break; |
| 1214 | 1214 |
| 1215 default: | 1215 default: |
| 1216 LOG(FATAL) << "Got " << type << " ModelType"; | 1216 LOG(FATAL) << "Got " << type << " ModelType"; |
| 1217 } | 1217 } |
| 1218 | 1218 |
| 1219 // Process local extensions. | 1219 // Process local extensions. |
| 1220 // TODO(yoz): Determine whether pending extensions should be considered too. | 1220 // TODO(yoz): Determine whether pending extensions should be considered too. |
| 1221 // See crbug.com/104399. | 1221 // See crbug.com/104399. |
| 1222 csync::SyncDataList sync_data_list = GetAllSyncData(type); | 1222 syncer::SyncDataList sync_data_list = GetAllSyncData(type); |
| 1223 csync::SyncChangeList sync_change_list; | 1223 syncer::SyncChangeList sync_change_list; |
| 1224 for (csync::SyncDataList::const_iterator i = sync_data_list.begin(); | 1224 for (syncer::SyncDataList::const_iterator i = sync_data_list.begin(); |
| 1225 i != sync_data_list.end(); | 1225 i != sync_data_list.end(); |
| 1226 ++i) { | 1226 ++i) { |
| 1227 switch (type) { | 1227 switch (type) { |
| 1228 case syncable::EXTENSIONS: | 1228 case syncable::EXTENSIONS: |
| 1229 sync_change_list.push_back( | 1229 sync_change_list.push_back( |
| 1230 extension_sync_bundle_.CreateSyncChange(*i)); | 1230 extension_sync_bundle_.CreateSyncChange(*i)); |
| 1231 break; | 1231 break; |
| 1232 case syncable::APPS: | 1232 case syncable::APPS: |
| 1233 sync_change_list.push_back(app_sync_bundle_.CreateSyncChange(*i)); | 1233 sync_change_list.push_back(app_sync_bundle_.CreateSyncChange(*i)); |
| 1234 break; | 1234 break; |
| 1235 default: | 1235 default: |
| 1236 LOG(FATAL) << "Got " << type << " ModelType"; | 1236 LOG(FATAL) << "Got " << type << " ModelType"; |
| 1237 } | 1237 } |
| 1238 } | 1238 } |
| 1239 | 1239 |
| 1240 | 1240 |
| 1241 if (type == syncable::EXTENSIONS) { | 1241 if (type == syncable::EXTENSIONS) { |
| 1242 extension_sync_bundle_.ProcessSyncChangeList(sync_change_list); | 1242 extension_sync_bundle_.ProcessSyncChangeList(sync_change_list); |
| 1243 } else if (type == syncable::APPS) { | 1243 } else if (type == syncable::APPS) { |
| 1244 app_sync_bundle_.ProcessSyncChangeList(sync_change_list); | 1244 app_sync_bundle_.ProcessSyncChangeList(sync_change_list); |
| 1245 } | 1245 } |
| 1246 | 1246 |
| 1247 return csync::SyncError(); | 1247 return syncer::SyncError(); |
| 1248 } | 1248 } |
| 1249 | 1249 |
| 1250 void ExtensionService::StopSyncing(syncable::ModelType type) { | 1250 void ExtensionService::StopSyncing(syncable::ModelType type) { |
| 1251 if (type == syncable::APPS) { | 1251 if (type == syncable::APPS) { |
| 1252 app_sync_bundle_.Reset(); | 1252 app_sync_bundle_.Reset(); |
| 1253 } else if (type == syncable::EXTENSIONS) { | 1253 } else if (type == syncable::EXTENSIONS) { |
| 1254 extension_sync_bundle_.Reset(); | 1254 extension_sync_bundle_.Reset(); |
| 1255 } | 1255 } |
| 1256 } | 1256 } |
| 1257 | 1257 |
| 1258 csync::SyncDataList ExtensionService::GetAllSyncData( | 1258 syncer::SyncDataList ExtensionService::GetAllSyncData( |
| 1259 syncable::ModelType type) const { | 1259 syncable::ModelType type) const { |
| 1260 if (type == syncable::EXTENSIONS) { | 1260 if (type == syncable::EXTENSIONS) { |
| 1261 return extension_sync_bundle_.GetAllSyncData(); | 1261 return extension_sync_bundle_.GetAllSyncData(); |
| 1262 | 1262 |
| 1263 } else if (type == syncable::APPS) { | 1263 } else if (type == syncable::APPS) { |
| 1264 return app_sync_bundle_.GetAllSyncData(); | 1264 return app_sync_bundle_.GetAllSyncData(); |
| 1265 } | 1265 } |
| 1266 | 1266 |
| 1267 // We should only get sync data for extensions and apps. | 1267 // We should only get sync data for extensions and apps. |
| 1268 NOTREACHED(); | 1268 NOTREACHED(); |
| 1269 | 1269 |
| 1270 return csync::SyncDataList(); | 1270 return syncer::SyncDataList(); |
| 1271 } | 1271 } |
| 1272 | 1272 |
| 1273 csync::SyncError ExtensionService::ProcessSyncChanges( | 1273 syncer::SyncError ExtensionService::ProcessSyncChanges( |
| 1274 const tracked_objects::Location& from_here, | 1274 const tracked_objects::Location& from_here, |
| 1275 const csync::SyncChangeList& change_list) { | 1275 const syncer::SyncChangeList& change_list) { |
| 1276 for (csync::SyncChangeList::const_iterator i = change_list.begin(); | 1276 for (syncer::SyncChangeList::const_iterator i = change_list.begin(); |
| 1277 i != change_list.end(); | 1277 i != change_list.end(); |
| 1278 ++i) { | 1278 ++i) { |
| 1279 syncable::ModelType type = i->sync_data().GetDataType(); | 1279 syncable::ModelType type = i->sync_data().GetDataType(); |
| 1280 if (type == syncable::EXTENSIONS) { | 1280 if (type == syncable::EXTENSIONS) { |
| 1281 extension_sync_bundle_.ProcessSyncChange( | 1281 extension_sync_bundle_.ProcessSyncChange( |
| 1282 extensions::ExtensionSyncData(*i)); | 1282 extensions::ExtensionSyncData(*i)); |
| 1283 } else if (type == syncable::APPS) { | 1283 } else if (type == syncable::APPS) { |
| 1284 app_sync_bundle_.ProcessSyncChange(extensions::AppSyncData(*i)); | 1284 app_sync_bundle_.ProcessSyncChange(extensions::AppSyncData(*i)); |
| 1285 } | 1285 } |
| 1286 } | 1286 } |
| 1287 | 1287 |
| 1288 extension_prefs()->extension_sorting()->FixNTPOrdinalCollisions(); | 1288 extension_prefs()->extension_sorting()->FixNTPOrdinalCollisions(); |
| 1289 | 1289 |
| 1290 return csync::SyncError(); | 1290 return syncer::SyncError(); |
| 1291 } | 1291 } |
| 1292 | 1292 |
| 1293 extensions::ExtensionSyncData ExtensionService::GetExtensionSyncData( | 1293 extensions::ExtensionSyncData ExtensionService::GetExtensionSyncData( |
| 1294 const Extension& extension) const { | 1294 const Extension& extension) const { |
| 1295 return extensions::ExtensionSyncData(extension, | 1295 return extensions::ExtensionSyncData(extension, |
| 1296 IsExtensionEnabled(extension.id()), | 1296 IsExtensionEnabled(extension.id()), |
| 1297 IsIncognitoEnabled(extension.id())); | 1297 IsIncognitoEnabled(extension.id())); |
| 1298 } | 1298 } |
| 1299 | 1299 |
| 1300 extensions::AppSyncData ExtensionService::GetAppSyncData( | 1300 extensions::AppSyncData ExtensionService::GetAppSyncData( |
| (...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2560 | 2560 |
| 2561 // To coexist with certain unit tests that don't have a work-thread message | 2561 // To coexist with certain unit tests that don't have a work-thread message |
| 2562 // loop available at ExtensionService shutdown, we lazy-initialize this | 2562 // loop available at ExtensionService shutdown, we lazy-initialize this |
| 2563 // object so that those cases neither create nor destroy an | 2563 // object so that those cases neither create nor destroy an |
| 2564 // APIResourceController. | 2564 // APIResourceController. |
| 2565 if (!api_resource_controller_.get()) { | 2565 if (!api_resource_controller_.get()) { |
| 2566 api_resource_controller_.reset(new extensions::APIResourceController()); | 2566 api_resource_controller_.reset(new extensions::APIResourceController()); |
| 2567 } | 2567 } |
| 2568 return api_resource_controller_.get(); | 2568 return api_resource_controller_.get(); |
| 2569 } | 2569 } |
| OLD | NEW |