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

Side by Side Diff: chrome/browser/extensions/extension_service.cc

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

Powered by Google App Engine
This is Rietveld 408576698