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

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

Issue 9232011: sync: Make ProfileSyncService a ProfileKeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: init Created 8 years, 11 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 "chrome/browser/extensions/app_notification_manager.h" 6 #include "chrome/browser/extensions/app_notification_manager.h"
7 #include "chrome/browser/extensions/extension_service.h" 7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/extensions/settings/settings_backend.h" 8 #include "chrome/browser/extensions/settings/settings_backend.h"
9 #include "chrome/browser/defaults.h"
10 #include "chrome/browser/prefs/pref_model_associator.h" 9 #include "chrome/browser/prefs/pref_model_associator.h"
11 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/search_engines/template_url_service.h" 11 #include "chrome/browser/search_engines/template_url_service.h"
13 #include "chrome/browser/search_engines/template_url_service_factory.h" 12 #include "chrome/browser/search_engines/template_url_service_factory.h"
14 #include "chrome/browser/signin/signin_manager.h"
15 #include "chrome/browser/sync/api/syncable_service.h" 13 #include "chrome/browser/sync/api/syncable_service.h"
16 #include "chrome/browser/sync/glue/app_data_type_controller.h" 14 #include "chrome/browser/sync/glue/app_data_type_controller.h"
17 #include "chrome/browser/sync/glue/app_notification_data_type_controller.h" 15 #include "chrome/browser/sync/glue/app_notification_data_type_controller.h"
18 #include "chrome/browser/sync/glue/autofill_data_type_controller.h" 16 #include "chrome/browser/sync/glue/autofill_data_type_controller.h"
19 #include "chrome/browser/sync/glue/autofill_profile_data_type_controller.h" 17 #include "chrome/browser/sync/glue/autofill_profile_data_type_controller.h"
20 #include "chrome/browser/sync/glue/bookmark_change_processor.h" 18 #include "chrome/browser/sync/glue/bookmark_change_processor.h"
21 #include "chrome/browser/sync/glue/bookmark_data_type_controller.h" 19 #include "chrome/browser/sync/glue/bookmark_data_type_controller.h"
22 #include "chrome/browser/sync/glue/bookmark_model_associator.h" 20 #include "chrome/browser/sync/glue/bookmark_model_associator.h"
23 #include "chrome/browser/sync/glue/data_type_manager_impl.h" 21 #include "chrome/browser/sync/glue/data_type_manager_impl.h"
24 #include "chrome/browser/sync/glue/extension_data_type_controller.h" 22 #include "chrome/browser/sync/glue/extension_data_type_controller.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 using browser_sync::TypedUrlModelAssociator; 80 using browser_sync::TypedUrlModelAssociator;
83 using browser_sync::UnrecoverableErrorHandler; 81 using browser_sync::UnrecoverableErrorHandler;
84 using content::BrowserThread; 82 using content::BrowserThread;
85 83
86 ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl( 84 ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl(
87 Profile* profile, CommandLine* command_line) 85 Profile* profile, CommandLine* command_line)
88 : profile_(profile), 86 : profile_(profile),
89 command_line_(command_line) { 87 command_line_(command_line) {
90 } 88 }
91 89
92 ProfileSyncService*
93 ProfileSyncComponentsFactoryImpl::CreateProfileSyncService() {
94 ProfileSyncService::StartBehavior behavior =
95 browser_defaults::kSyncAutoStarts ? ProfileSyncService::AUTO_START
96 : ProfileSyncService::MANUAL_START;
97
98 SigninManager* signin = profile_->GetSigninManager();
99
100 // TODO(tim): Currently, AUTO/MANUAL settings refer to the *first* time sync
101 // is set up and *not* a browser restart for a manual-start platform (where
102 // sync has already been set up, and should be able to start without user
103 // intervention). We can get rid of the browser_default eventually, but
104 // need to take care that ProfileSyncService doesn't get tripped up between
105 // those two cases. Bug 88109.
106 ProfileSyncService* pss = new ProfileSyncService(
107 this, profile_, signin, behavior);
108 return pss;
109 }
110
111 void ProfileSyncComponentsFactoryImpl::RegisterDataTypes( 90 void ProfileSyncComponentsFactoryImpl::RegisterDataTypes(
112 ProfileSyncService* pss) { 91 ProfileSyncService* pss) {
113 // App sync is enabled by default. Register unless explicitly 92 // App sync is enabled by default. Register unless explicitly
114 // disabled. 93 // disabled.
115 if (!command_line_->HasSwitch(switches::kDisableSyncApps)) { 94 if (!command_line_->HasSwitch(switches::kDisableSyncApps)) {
116 pss->RegisterDataTypeController( 95 pss->RegisterDataTypeController(
117 new AppDataTypeController(this, profile_, pss)); 96 new AppDataTypeController(this, profile_, pss));
118 } 97 }
119 98
120 // Autofill sync is enabled by default. Register unless explicitly 99 // Autofill sync is enabled by default. Register unless explicitly
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 GenericChangeProcessor* change_processor = 390 GenericChangeProcessor* change_processor =
412 new GenericChangeProcessor(error_handler, 391 new GenericChangeProcessor(error_handler,
413 notif_sync_service, 392 notif_sync_service,
414 user_share); 393 user_share);
415 SyncableServiceAdapter* sync_service_adapter = 394 SyncableServiceAdapter* sync_service_adapter =
416 new SyncableServiceAdapter(syncable::APP_NOTIFICATIONS, 395 new SyncableServiceAdapter(syncable::APP_NOTIFICATIONS,
417 notif_sync_service, 396 notif_sync_service,
418 change_processor); 397 change_processor);
419 return SyncComponents(sync_service_adapter, change_processor); 398 return SyncComponents(sync_service_adapter, change_processor);
420 } 399 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698