| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
| 7 #include "chrome/browser/extensions/app_notification_manager.h" | 7 #include "chrome/browser/extensions/app_notification_manager.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/extensions/extension_system.h" | 9 #include "chrome/browser/extensions/extension_system.h" |
| 10 #include "chrome/browser/extensions/extension_system_factory.h" | 10 #include "chrome/browser/extensions/extension_system_factory.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 ProfileSyncComponentsFactoryImpl::~ProfileSyncComponentsFactoryImpl() { | 96 ProfileSyncComponentsFactoryImpl::~ProfileSyncComponentsFactoryImpl() { |
| 97 } | 97 } |
| 98 | 98 |
| 99 void ProfileSyncComponentsFactoryImpl::RegisterDataTypes( | 99 void ProfileSyncComponentsFactoryImpl::RegisterDataTypes( |
| 100 ProfileSyncService* pss) { | 100 ProfileSyncService* pss) { |
| 101 // App sync is enabled by default. Register unless explicitly | 101 // App sync is enabled by default. Register unless explicitly |
| 102 // disabled. | 102 // disabled. |
| 103 if (!command_line_->HasSwitch(switches::kDisableSyncApps)) { | 103 if (!command_line_->HasSwitch(switches::kDisableSyncApps)) { |
| 104 pss->RegisterDataTypeController( | 104 pss->RegisterDataTypeController( |
| 105 new ExtensionDataTypeController(syncable::APPS, this, profile_, pss)); | 105 new ExtensionDataTypeController(syncer::APPS, this, profile_, pss)); |
| 106 } | 106 } |
| 107 | 107 |
| 108 // Autofill sync is enabled by default. Register unless explicitly | 108 // Autofill sync is enabled by default. Register unless explicitly |
| 109 // disabled. | 109 // disabled. |
| 110 if (!command_line_->HasSwitch(switches::kDisableSyncAutofill)) { | 110 if (!command_line_->HasSwitch(switches::kDisableSyncAutofill)) { |
| 111 pss->RegisterDataTypeController( | 111 pss->RegisterDataTypeController( |
| 112 new AutofillDataTypeController(this, profile_, pss)); | 112 new AutofillDataTypeController(this, profile_, pss)); |
| 113 } | 113 } |
| 114 | 114 |
| 115 // Bookmark sync is enabled by default. Register unless explicitly | 115 // Bookmark sync is enabled by default. Register unless explicitly |
| 116 // disabled. | 116 // disabled. |
| 117 if (!command_line_->HasSwitch(switches::kDisableSyncBookmarks)) { | 117 if (!command_line_->HasSwitch(switches::kDisableSyncBookmarks)) { |
| 118 pss->RegisterDataTypeController( | 118 pss->RegisterDataTypeController( |
| 119 new BookmarkDataTypeController(this, profile_, pss)); | 119 new BookmarkDataTypeController(this, profile_, pss)); |
| 120 } | 120 } |
| 121 | 121 |
| 122 // Extension sync is enabled by default. Register unless explicitly | 122 // Extension sync is enabled by default. Register unless explicitly |
| 123 // disabled. | 123 // disabled. |
| 124 if (!command_line_->HasSwitch(switches::kDisableSyncExtensions)) { | 124 if (!command_line_->HasSwitch(switches::kDisableSyncExtensions)) { |
| 125 pss->RegisterDataTypeController( | 125 pss->RegisterDataTypeController( |
| 126 new ExtensionDataTypeController(syncable::EXTENSIONS, | 126 new ExtensionDataTypeController(syncer::EXTENSIONS, |
| 127 this, profile_, pss)); | 127 this, profile_, pss)); |
| 128 } | 128 } |
| 129 | 129 |
| 130 // Password sync is enabled by default. Register unless explicitly | 130 // Password sync is enabled by default. Register unless explicitly |
| 131 // disabled. | 131 // disabled. |
| 132 if (!command_line_->HasSwitch(switches::kDisableSyncPasswords)) { | 132 if (!command_line_->HasSwitch(switches::kDisableSyncPasswords)) { |
| 133 pss->RegisterDataTypeController( | 133 pss->RegisterDataTypeController( |
| 134 new PasswordDataTypeController(this, profile_, pss)); | 134 new PasswordDataTypeController(this, profile_, pss)); |
| 135 } | 135 } |
| 136 | 136 |
| 137 // Preference sync is enabled by default. Register unless explicitly | 137 // Preference sync is enabled by default. Register unless explicitly |
| 138 // disabled. | 138 // disabled. |
| 139 if (!command_line_->HasSwitch(switches::kDisableSyncPreferences)) { | 139 if (!command_line_->HasSwitch(switches::kDisableSyncPreferences)) { |
| 140 pss->RegisterDataTypeController( | 140 pss->RegisterDataTypeController( |
| 141 new UIDataTypeController(syncable::PREFERENCES, this, profile_, pss)); | 141 new UIDataTypeController(syncer::PREFERENCES, this, profile_, pss)); |
| 142 } | 142 } |
| 143 | 143 |
| 144 #if defined(ENABLE_THEMES) | 144 #if defined(ENABLE_THEMES) |
| 145 // Theme sync is enabled by default. Register unless explicitly disabled. | 145 // Theme sync is enabled by default. Register unless explicitly disabled. |
| 146 if (!command_line_->HasSwitch(switches::kDisableSyncThemes)) { | 146 if (!command_line_->HasSwitch(switches::kDisableSyncThemes)) { |
| 147 pss->RegisterDataTypeController( | 147 pss->RegisterDataTypeController( |
| 148 new ThemeDataTypeController(this, profile_, pss)); | 148 new ThemeDataTypeController(this, profile_, pss)); |
| 149 } | 149 } |
| 150 #endif | 150 #endif |
| 151 | 151 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 168 if (!command_line_->HasSwitch(switches::kDisableSyncTabs)) { | 168 if (!command_line_->HasSwitch(switches::kDisableSyncTabs)) { |
| 169 pss->RegisterDataTypeController( | 169 pss->RegisterDataTypeController( |
| 170 new SessionDataTypeController(this, profile_, pss)); | 170 new SessionDataTypeController(this, profile_, pss)); |
| 171 } | 171 } |
| 172 | 172 |
| 173 // Extension setting sync is enabled by default. Register unless explicitly | 173 // Extension setting sync is enabled by default. Register unless explicitly |
| 174 // disabled. | 174 // disabled. |
| 175 if (!command_line_->HasSwitch(switches::kDisableSyncExtensionSettings)) { | 175 if (!command_line_->HasSwitch(switches::kDisableSyncExtensionSettings)) { |
| 176 pss->RegisterDataTypeController( | 176 pss->RegisterDataTypeController( |
| 177 new ExtensionSettingDataTypeController( | 177 new ExtensionSettingDataTypeController( |
| 178 syncable::EXTENSION_SETTINGS, this, profile_, pss)); | 178 syncer::EXTENSION_SETTINGS, this, profile_, pss)); |
| 179 } | 179 } |
| 180 | 180 |
| 181 // App setting sync is enabled by default. Register unless explicitly | 181 // App setting sync is enabled by default. Register unless explicitly |
| 182 // disabled. | 182 // disabled. |
| 183 if (!command_line_->HasSwitch(switches::kDisableSyncAppSettings)) { | 183 if (!command_line_->HasSwitch(switches::kDisableSyncAppSettings)) { |
| 184 pss->RegisterDataTypeController( | 184 pss->RegisterDataTypeController( |
| 185 new ExtensionSettingDataTypeController( | 185 new ExtensionSettingDataTypeController( |
| 186 syncable::APP_SETTINGS, this, profile_, pss)); | 186 syncer::APP_SETTINGS, this, profile_, pss)); |
| 187 } | 187 } |
| 188 | 188 |
| 189 if (!command_line_->HasSwitch(switches::kDisableSyncAutofillProfile)) { | 189 if (!command_line_->HasSwitch(switches::kDisableSyncAutofillProfile)) { |
| 190 pss->RegisterDataTypeController( | 190 pss->RegisterDataTypeController( |
| 191 new AutofillProfileDataTypeController(this, profile_, pss)); | 191 new AutofillProfileDataTypeController(this, profile_, pss)); |
| 192 } | 192 } |
| 193 | 193 |
| 194 // App notifications sync is enabled by default. Register only if | 194 // App notifications sync is enabled by default. Register only if |
| 195 // explicitly disabled. | 195 // explicitly disabled. |
| 196 if (!command_line_->HasSwitch(switches::kDisableSyncAppNotifications)) { | 196 if (!command_line_->HasSwitch(switches::kDisableSyncAppNotifications)) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 215 local_service, | 215 local_service, |
| 216 user_share); | 216 user_share); |
| 217 } | 217 } |
| 218 | 218 |
| 219 browser_sync::SharedChangeProcessor* ProfileSyncComponentsFactoryImpl:: | 219 browser_sync::SharedChangeProcessor* ProfileSyncComponentsFactoryImpl:: |
| 220 CreateSharedChangeProcessor() { | 220 CreateSharedChangeProcessor() { |
| 221 return new SharedChangeProcessor(); | 221 return new SharedChangeProcessor(); |
| 222 } | 222 } |
| 223 | 223 |
| 224 base::WeakPtr<syncer::SyncableService> ProfileSyncComponentsFactoryImpl:: | 224 base::WeakPtr<syncer::SyncableService> ProfileSyncComponentsFactoryImpl:: |
| 225 GetSyncableServiceForType(syncable::ModelType type) { | 225 GetSyncableServiceForType(syncer::ModelType type) { |
| 226 if (!profile_) { // For tests. | 226 if (!profile_) { // For tests. |
| 227 return base::WeakPtr<syncer::SyncableService>(); | 227 return base::WeakPtr<syncer::SyncableService>(); |
| 228 } | 228 } |
| 229 switch (type) { | 229 switch (type) { |
| 230 case syncable::PREFERENCES: | 230 case syncer::PREFERENCES: |
| 231 return profile_->GetPrefs()->GetSyncableService()->AsWeakPtr(); | 231 return profile_->GetPrefs()->GetSyncableService()->AsWeakPtr(); |
| 232 case syncable::AUTOFILL: | 232 case syncer::AUTOFILL: |
| 233 case syncable::AUTOFILL_PROFILE: { | 233 case syncer::AUTOFILL_PROFILE: { |
| 234 if (!web_data_service_.get()) | 234 if (!web_data_service_.get()) |
| 235 return base::WeakPtr<syncer::SyncableService>(); | 235 return base::WeakPtr<syncer::SyncableService>(); |
| 236 if (type == syncable::AUTOFILL) { | 236 if (type == syncer::AUTOFILL) { |
| 237 return web_data_service_->GetAutocompleteSyncableService()->AsWeakPtr(); | 237 return web_data_service_->GetAutocompleteSyncableService()->AsWeakPtr(); |
| 238 } else { | 238 } else { |
| 239 return web_data_service_-> | 239 return web_data_service_-> |
| 240 GetAutofillProfileSyncableService()->AsWeakPtr(); | 240 GetAutofillProfileSyncableService()->AsWeakPtr(); |
| 241 } | 241 } |
| 242 } | 242 } |
| 243 case syncable::APPS: | 243 case syncer::APPS: |
| 244 case syncable::EXTENSIONS: | 244 case syncer::EXTENSIONS: |
| 245 return extension_system_->extension_service()->AsWeakPtr(); | 245 return extension_system_->extension_service()->AsWeakPtr(); |
| 246 case syncable::SEARCH_ENGINES: | 246 case syncer::SEARCH_ENGINES: |
| 247 return TemplateURLServiceFactory::GetForProfile(profile_)->AsWeakPtr(); | 247 return TemplateURLServiceFactory::GetForProfile(profile_)->AsWeakPtr(); |
| 248 case syncable::APP_SETTINGS: | 248 case syncer::APP_SETTINGS: |
| 249 case syncable::EXTENSION_SETTINGS: | 249 case syncer::EXTENSION_SETTINGS: |
| 250 return extension_system_->extension_service()->settings_frontend()-> | 250 return extension_system_->extension_service()->settings_frontend()-> |
| 251 GetBackendForSync(type)->AsWeakPtr(); | 251 GetBackendForSync(type)->AsWeakPtr(); |
| 252 case syncable::APP_NOTIFICATIONS: | 252 case syncer::APP_NOTIFICATIONS: |
| 253 return extension_system_->extension_service()-> | 253 return extension_system_->extension_service()-> |
| 254 app_notification_manager()->AsWeakPtr(); | 254 app_notification_manager()->AsWeakPtr(); |
| 255 default: | 255 default: |
| 256 // The following datatypes still need to be transitioned to the | 256 // The following datatypes still need to be transitioned to the |
| 257 // syncer::SyncableService API: | 257 // syncer::SyncableService API: |
| 258 // Bookmarks | 258 // Bookmarks |
| 259 // Passwords | 259 // Passwords |
| 260 // Sessions | 260 // Sessions |
| 261 // Themes | 261 // Themes |
| 262 // Typed URLs | 262 // Typed URLs |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 ProfileSyncComponentsFactory::SyncComponents | 338 ProfileSyncComponentsFactory::SyncComponents |
| 339 ProfileSyncComponentsFactoryImpl::CreateSessionSyncComponents( | 339 ProfileSyncComponentsFactoryImpl::CreateSessionSyncComponents( |
| 340 ProfileSyncService* profile_sync_service, | 340 ProfileSyncService* profile_sync_service, |
| 341 DataTypeErrorHandler* error_handler) { | 341 DataTypeErrorHandler* error_handler) { |
| 342 SessionModelAssociator* model_associator = | 342 SessionModelAssociator* model_associator = |
| 343 new SessionModelAssociator(profile_sync_service, error_handler); | 343 new SessionModelAssociator(profile_sync_service, error_handler); |
| 344 SessionChangeProcessor* change_processor = | 344 SessionChangeProcessor* change_processor = |
| 345 new SessionChangeProcessor(error_handler, model_associator); | 345 new SessionChangeProcessor(error_handler, model_associator); |
| 346 return SyncComponents(model_associator, change_processor); | 346 return SyncComponents(model_associator, change_processor); |
| 347 } | 347 } |
| OLD | NEW |