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

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

Issue 9834056: Moved WebDataService to ProfileKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed return NULL; to NOTREACHED() Created 8 years, 8 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/settings/settings_frontend.h" 9 #include "chrome/browser/extensions/settings/settings_frontend.h"
10 #include "chrome/browser/prefs/pref_model_associator.h" 10 #include "chrome/browser/prefs/pref_model_associator.h"
(...skipping 27 matching lines...) Expand all
38 #include "chrome/browser/sync/glue/theme_model_associator.h" 38 #include "chrome/browser/sync/glue/theme_model_associator.h"
39 #include "chrome/browser/sync/glue/typed_url_change_processor.h" 39 #include "chrome/browser/sync/glue/typed_url_change_processor.h"
40 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h" 40 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h"
41 #include "chrome/browser/sync/glue/typed_url_model_associator.h" 41 #include "chrome/browser/sync/glue/typed_url_model_associator.h"
42 #include "chrome/browser/sync/glue/ui_data_type_controller.h" 42 #include "chrome/browser/sync/glue/ui_data_type_controller.h"
43 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" 43 #include "chrome/browser/sync/profile_sync_components_factory_impl.h"
44 #include "chrome/browser/sync/profile_sync_service.h" 44 #include "chrome/browser/sync/profile_sync_service.h"
45 #include "chrome/browser/webdata/autocomplete_syncable_service.h" 45 #include "chrome/browser/webdata/autocomplete_syncable_service.h"
46 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" 46 #include "chrome/browser/webdata/autofill_profile_syncable_service.h"
47 #include "chrome/browser/webdata/web_data_service.h" 47 #include "chrome/browser/webdata/web_data_service.h"
48 #include "chrome/browser/webdata/web_data_service_factory.h"
48 #include "chrome/common/chrome_switches.h" 49 #include "chrome/common/chrome_switches.h"
49 #include "chrome/common/pref_names.h" 50 #include "chrome/common/pref_names.h"
50 #include "content/public/browser/browser_thread.h" 51 #include "content/public/browser/browser_thread.h"
51 52
52 using browser_sync::AppNotificationDataTypeController; 53 using browser_sync::AppNotificationDataTypeController;
53 using browser_sync::AutofillDataTypeController; 54 using browser_sync::AutofillDataTypeController;
54 using browser_sync::AutofillProfileDataTypeController; 55 using browser_sync::AutofillProfileDataTypeController;
55 using browser_sync::BookmarkChangeProcessor; 56 using browser_sync::BookmarkChangeProcessor;
56 using browser_sync::BookmarkDataTypeController; 57 using browser_sync::BookmarkDataTypeController;
57 using browser_sync::BookmarkModelAssociator; 58 using browser_sync::BookmarkModelAssociator;
(...skipping 18 matching lines...) Expand all
76 using browser_sync::TypedUrlChangeProcessor; 77 using browser_sync::TypedUrlChangeProcessor;
77 using browser_sync::TypedUrlDataTypeController; 78 using browser_sync::TypedUrlDataTypeController;
78 using browser_sync::TypedUrlModelAssociator; 79 using browser_sync::TypedUrlModelAssociator;
79 using browser_sync::UIDataTypeController; 80 using browser_sync::UIDataTypeController;
80 using browser_sync::DataTypeErrorHandler; 81 using browser_sync::DataTypeErrorHandler;
81 using content::BrowserThread; 82 using content::BrowserThread;
82 83
83 ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl( 84 ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl(
84 Profile* profile, CommandLine* command_line) 85 Profile* profile, CommandLine* command_line)
85 : profile_(profile), 86 : profile_(profile),
86 command_line_(command_line) { 87 command_line_(command_line),
88 web_data_service_(WebDataServiceFactory::GetForProfile(
89 profile_, Profile::IMPLICIT_ACCESS)) {
90 }
91
92 ProfileSyncComponentsFactoryImpl::~ProfileSyncComponentsFactoryImpl() {
87 } 93 }
88 94
89 void ProfileSyncComponentsFactoryImpl::RegisterDataTypes( 95 void ProfileSyncComponentsFactoryImpl::RegisterDataTypes(
90 ProfileSyncService* pss) { 96 ProfileSyncService* pss) {
91 // App sync is enabled by default. Register unless explicitly 97 // App sync is enabled by default. Register unless explicitly
92 // disabled. 98 // disabled.
93 if (!command_line_->HasSwitch(switches::kDisableSyncApps)) { 99 if (!command_line_->HasSwitch(switches::kDisableSyncApps)) {
94 pss->RegisterDataTypeController( 100 pss->RegisterDataTypeController(
95 new ExtensionDataTypeController(syncable::APPS, this, profile_, pss)); 101 new ExtensionDataTypeController(syncable::APPS, this, profile_, pss));
96 } 102 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 base::WeakPtr<SyncableService> ProfileSyncComponentsFactoryImpl:: 222 base::WeakPtr<SyncableService> ProfileSyncComponentsFactoryImpl::
217 GetSyncableServiceForType(syncable::ModelType type) { 223 GetSyncableServiceForType(syncable::ModelType type) {
218 if (!profile_) { // For tests. 224 if (!profile_) { // For tests.
219 return base::WeakPtr<SyncableService>(); 225 return base::WeakPtr<SyncableService>();
220 } 226 }
221 switch (type) { 227 switch (type) {
222 case syncable::PREFERENCES: 228 case syncable::PREFERENCES:
223 return profile_->GetPrefs()->GetSyncableService()->AsWeakPtr(); 229 return profile_->GetPrefs()->GetSyncableService()->AsWeakPtr();
224 case syncable::AUTOFILL: 230 case syncable::AUTOFILL:
225 case syncable::AUTOFILL_PROFILE: { 231 case syncable::AUTOFILL_PROFILE: {
226 WebDataService* wds = 232 if (!web_data_service_.get())
227 profile_->GetWebDataService(Profile::IMPLICIT_ACCESS);
228 if (!wds)
229 return base::WeakPtr<SyncableService>(); 233 return base::WeakPtr<SyncableService>();
230 if (type == syncable::AUTOFILL) 234 if (type == syncable::AUTOFILL) {
231 return wds->GetAutocompleteSyncableService()->AsWeakPtr(); 235 return web_data_service_->GetAutocompleteSyncableService()->AsWeakPtr();
232 else 236 } else {
233 return wds->GetAutofillProfileSyncableService()->AsWeakPtr(); 237 return web_data_service_->
238 GetAutofillProfileSyncableService()->AsWeakPtr();
239 }
234 } 240 }
235 case syncable::APPS: 241 case syncable::APPS:
236 case syncable::EXTENSIONS: 242 case syncable::EXTENSIONS:
237 return profile_->GetExtensionService()->AsWeakPtr(); 243 return profile_->GetExtensionService()->AsWeakPtr();
238 case syncable::SEARCH_ENGINES: 244 case syncable::SEARCH_ENGINES:
239 return TemplateURLServiceFactory::GetForProfile(profile_)->AsWeakPtr(); 245 return TemplateURLServiceFactory::GetForProfile(profile_)->AsWeakPtr();
240 case syncable::APP_SETTINGS: 246 case syncable::APP_SETTINGS:
241 case syncable::EXTENSION_SETTINGS: 247 case syncable::EXTENSION_SETTINGS:
242 return profile_->GetExtensionService()->settings_frontend()-> 248 return profile_->GetExtensionService()->settings_frontend()->
243 GetBackendForSync(type)->AsWeakPtr(); 249 GetBackendForSync(type)->AsWeakPtr();
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 ProfileSyncComponentsFactory::SyncComponents 334 ProfileSyncComponentsFactory::SyncComponents
329 ProfileSyncComponentsFactoryImpl::CreateSessionSyncComponents( 335 ProfileSyncComponentsFactoryImpl::CreateSessionSyncComponents(
330 ProfileSyncService* profile_sync_service, 336 ProfileSyncService* profile_sync_service,
331 DataTypeErrorHandler* error_handler) { 337 DataTypeErrorHandler* error_handler) {
332 SessionModelAssociator* model_associator = 338 SessionModelAssociator* model_associator =
333 new SessionModelAssociator(profile_sync_service); 339 new SessionModelAssociator(profile_sync_service);
334 SessionChangeProcessor* change_processor = 340 SessionChangeProcessor* change_processor =
335 new SessionChangeProcessor(error_handler, model_associator); 341 new SessionChangeProcessor(error_handler, model_associator);
336 return SyncComponents(model_associator, change_processor); 342 return SyncComponents(model_associator, change_processor);
337 } 343 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698