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

Side by Side Diff: chrome/browser/sync/profile_sync_components_factory_impl.cc

Issue 10185008: Taking over issue 10006037: Moved WebDataService to ProfileKeyedService (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 "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 29 matching lines...) Expand all
40 #include "chrome/browser/sync/glue/theme_model_associator.h" 40 #include "chrome/browser/sync/glue/theme_model_associator.h"
41 #include "chrome/browser/sync/glue/typed_url_change_processor.h" 41 #include "chrome/browser/sync/glue/typed_url_change_processor.h"
42 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h" 42 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h"
43 #include "chrome/browser/sync/glue/typed_url_model_associator.h" 43 #include "chrome/browser/sync/glue/typed_url_model_associator.h"
44 #include "chrome/browser/sync/glue/ui_data_type_controller.h" 44 #include "chrome/browser/sync/glue/ui_data_type_controller.h"
45 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" 45 #include "chrome/browser/sync/profile_sync_components_factory_impl.h"
46 #include "chrome/browser/sync/profile_sync_service.h" 46 #include "chrome/browser/sync/profile_sync_service.h"
47 #include "chrome/browser/webdata/autocomplete_syncable_service.h" 47 #include "chrome/browser/webdata/autocomplete_syncable_service.h"
48 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" 48 #include "chrome/browser/webdata/autofill_profile_syncable_service.h"
49 #include "chrome/browser/webdata/web_data_service.h" 49 #include "chrome/browser/webdata/web_data_service.h"
50 #include "chrome/browser/webdata/web_data_service_factory.h"
50 #include "chrome/common/chrome_switches.h" 51 #include "chrome/common/chrome_switches.h"
51 #include "chrome/common/pref_names.h" 52 #include "chrome/common/pref_names.h"
52 #include "content/public/browser/browser_thread.h" 53 #include "content/public/browser/browser_thread.h"
53 54
54 using browser_sync::AppNotificationDataTypeController; 55 using browser_sync::AppNotificationDataTypeController;
55 using browser_sync::AutofillDataTypeController; 56 using browser_sync::AutofillDataTypeController;
56 using browser_sync::AutofillProfileDataTypeController; 57 using browser_sync::AutofillProfileDataTypeController;
57 using browser_sync::BookmarkChangeProcessor; 58 using browser_sync::BookmarkChangeProcessor;
58 using browser_sync::BookmarkDataTypeController; 59 using browser_sync::BookmarkDataTypeController;
59 using browser_sync::BookmarkModelAssociator; 60 using browser_sync::BookmarkModelAssociator;
(...skipping 20 matching lines...) Expand all
80 using browser_sync::TypedUrlModelAssociator; 81 using browser_sync::TypedUrlModelAssociator;
81 using browser_sync::UIDataTypeController; 82 using browser_sync::UIDataTypeController;
82 using browser_sync::DataTypeErrorHandler; 83 using browser_sync::DataTypeErrorHandler;
83 using content::BrowserThread; 84 using content::BrowserThread;
84 85
85 ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl( 86 ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl(
86 Profile* profile, CommandLine* command_line) 87 Profile* profile, CommandLine* command_line)
87 : profile_(profile), 88 : profile_(profile),
88 command_line_(command_line), 89 command_line_(command_line),
89 extension_system_( 90 extension_system_(
90 ExtensionSystem::Get(profile)) { 91 ExtensionSystemFactory::GetForProfile(profile)),
92 web_data_service_(WebDataServiceFactory::GetForProfile(
93 profile_, Profile::IMPLICIT_ACCESS)) {
94 }
95
96 ProfileSyncComponentsFactoryImpl::~ProfileSyncComponentsFactoryImpl() {
91 } 97 }
92 98
93 void ProfileSyncComponentsFactoryImpl::RegisterDataTypes( 99 void ProfileSyncComponentsFactoryImpl::RegisterDataTypes(
94 ProfileSyncService* pss) { 100 ProfileSyncService* pss) {
95 // App sync is enabled by default. Register unless explicitly 101 // App sync is enabled by default. Register unless explicitly
96 // disabled. 102 // disabled.
97 if (!command_line_->HasSwitch(switches::kDisableSyncApps)) { 103 if (!command_line_->HasSwitch(switches::kDisableSyncApps)) {
98 pss->RegisterDataTypeController( 104 pss->RegisterDataTypeController(
99 new ExtensionDataTypeController(syncable::APPS, this, profile_, pss)); 105 new ExtensionDataTypeController(syncable::APPS, this, profile_, pss));
100 } 106 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 base::WeakPtr<SyncableService> ProfileSyncComponentsFactoryImpl:: 226 base::WeakPtr<SyncableService> ProfileSyncComponentsFactoryImpl::
221 GetSyncableServiceForType(syncable::ModelType type) { 227 GetSyncableServiceForType(syncable::ModelType type) {
222 if (!profile_) { // For tests. 228 if (!profile_) { // For tests.
223 return base::WeakPtr<SyncableService>(); 229 return base::WeakPtr<SyncableService>();
224 } 230 }
225 switch (type) { 231 switch (type) {
226 case syncable::PREFERENCES: 232 case syncable::PREFERENCES:
227 return profile_->GetPrefs()->GetSyncableService()->AsWeakPtr(); 233 return profile_->GetPrefs()->GetSyncableService()->AsWeakPtr();
228 case syncable::AUTOFILL: 234 case syncable::AUTOFILL:
229 case syncable::AUTOFILL_PROFILE: { 235 case syncable::AUTOFILL_PROFILE: {
230 WebDataService* wds = 236 if (!web_data_service_.get())
231 profile_->GetWebDataService(Profile::IMPLICIT_ACCESS);
232 if (!wds)
233 return base::WeakPtr<SyncableService>(); 237 return base::WeakPtr<SyncableService>();
234 if (type == syncable::AUTOFILL) 238 if (type == syncable::AUTOFILL) {
235 return wds->GetAutocompleteSyncableService()->AsWeakPtr(); 239 return web_data_service_->GetAutocompleteSyncableService()->AsWeakPtr();
236 else 240 } else {
237 return wds->GetAutofillProfileSyncableService()->AsWeakPtr(); 241 return web_data_service_->
242 GetAutofillProfileSyncableService()->AsWeakPtr();
243 }
238 } 244 }
239 case syncable::APPS: 245 case syncable::APPS:
240 case syncable::EXTENSIONS: 246 case syncable::EXTENSIONS:
241 return extension_system_->extension_service()->AsWeakPtr(); 247 return extension_system_->extension_service()->AsWeakPtr();
242 case syncable::SEARCH_ENGINES: 248 case syncable::SEARCH_ENGINES:
243 return TemplateURLServiceFactory::GetForProfile(profile_)->AsWeakPtr(); 249 return TemplateURLServiceFactory::GetForProfile(profile_)->AsWeakPtr();
244 case syncable::APP_SETTINGS: 250 case syncable::APP_SETTINGS:
245 case syncable::EXTENSION_SETTINGS: 251 case syncable::EXTENSION_SETTINGS:
246 return extension_system_->extension_service()->settings_frontend()-> 252 return extension_system_->extension_service()->settings_frontend()->
247 GetBackendForSync(type)->AsWeakPtr(); 253 GetBackendForSync(type)->AsWeakPtr();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 ProfileSyncComponentsFactory::SyncComponents 340 ProfileSyncComponentsFactory::SyncComponents
335 ProfileSyncComponentsFactoryImpl::CreateSessionSyncComponents( 341 ProfileSyncComponentsFactoryImpl::CreateSessionSyncComponents(
336 ProfileSyncService* profile_sync_service, 342 ProfileSyncService* profile_sync_service,
337 DataTypeErrorHandler* error_handler) { 343 DataTypeErrorHandler* error_handler) {
338 SessionModelAssociator* model_associator = 344 SessionModelAssociator* model_associator =
339 new SessionModelAssociator(profile_sync_service, error_handler); 345 new SessionModelAssociator(profile_sync_service, error_handler);
340 SessionChangeProcessor* change_processor = 346 SessionChangeProcessor* change_processor =
341 new SessionChangeProcessor(error_handler, model_associator); 347 new SessionChangeProcessor(error_handler, model_associator);
342 return SyncComponents(model_associator, change_processor); 348 return SyncComponents(model_associator, change_processor);
343 } 349 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698