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

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: rebase 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) 2011 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/sync/api/syncable_service.h" 13 #include "chrome/browser/sync/api/syncable_service.h"
15 #include "chrome/browser/sync/glue/app_data_type_controller.h" 14 #include "chrome/browser/sync/glue/app_data_type_controller.h"
16 #include "chrome/browser/sync/glue/app_notification_data_type_controller.h" 15 #include "chrome/browser/sync/glue/app_notification_data_type_controller.h"
17 #include "chrome/browser/sync/glue/autofill_data_type_controller.h" 16 #include "chrome/browser/sync/glue/autofill_data_type_controller.h"
18 #include "chrome/browser/sync/glue/autofill_profile_data_type_controller.h" 17 #include "chrome/browser/sync/glue/autofill_profile_data_type_controller.h"
19 #include "chrome/browser/sync/glue/bookmark_change_processor.h" 18 #include "chrome/browser/sync/glue/bookmark_change_processor.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 using browser_sync::TypedUrlModelAssociator; 81 using browser_sync::TypedUrlModelAssociator;
83 using browser_sync::UnrecoverableErrorHandler; 82 using browser_sync::UnrecoverableErrorHandler;
84 using content::BrowserThread; 83 using content::BrowserThread;
85 84
86 ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl( 85 ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl(
87 Profile* profile, CommandLine* command_line) 86 Profile* profile, CommandLine* command_line)
88 : profile_(profile), 87 : profile_(profile),
89 command_line_(command_line) { 88 command_line_(command_line) {
90 } 89 }
91 90
92 ProfileSyncService*
93 ProfileSyncComponentsFactoryImpl::CreateProfileSyncService() {
94 ProfileSyncService::StartBehavior behavior =
95 browser_defaults::kSyncAutoStarts ? ProfileSyncService::AUTO_START
96 : ProfileSyncService::MANUAL_START;
97
98 PrefService* prefs = profile_->GetPrefs();
99 SigninManager* signin = new SigninManager();
100 signin->SetAuthenticatedUsername(prefs->GetString(
101 prefs::kGoogleServicesUsername));
102
103 // TODO(tim): Currently, AUTO/MANUAL settings refer to the *first* time sync
104 // is set up and *not* a browser restart for a manual-start platform (where
105 // sync has already been set up, and should be able to start without user
106 // intervention). We can get rid of the browser_default eventually, but
107 // need to take care that ProfileSyncService doesn't get tripped up between
108 // those two cases. Bug 88109.
109 ProfileSyncService* pss = new ProfileSyncService(
110 this, profile_, signin, behavior);
111 return pss;
112 }
113
114 void ProfileSyncComponentsFactoryImpl::RegisterDataTypes( 91 void ProfileSyncComponentsFactoryImpl::RegisterDataTypes(
115 ProfileSyncService* pss) { 92 ProfileSyncService* pss) {
116 // App sync is enabled by default. Register unless explicitly 93 // App sync is enabled by default. Register unless explicitly
117 // disabled. 94 // disabled.
118 if (!command_line_->HasSwitch(switches::kDisableSyncApps)) { 95 if (!command_line_->HasSwitch(switches::kDisableSyncApps)) {
119 pss->RegisterDataTypeController( 96 pss->RegisterDataTypeController(
120 new AppDataTypeController(this, profile_, pss)); 97 new AppDataTypeController(this, profile_, pss));
121 } 98 }
122 99
123 // Autofill sync is enabled by default. Register unless explicitly 100 // Autofill sync is enabled by default. Register unless explicitly
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 GenericChangeProcessor* change_processor = 391 GenericChangeProcessor* change_processor =
415 new GenericChangeProcessor(error_handler, 392 new GenericChangeProcessor(error_handler,
416 notif_sync_service, 393 notif_sync_service,
417 user_share); 394 user_share);
418 SyncableServiceAdapter* sync_service_adapter = 395 SyncableServiceAdapter* sync_service_adapter =
419 new SyncableServiceAdapter(syncable::APP_NOTIFICATIONS, 396 new SyncableServiceAdapter(syncable::APP_NOTIFICATIONS,
420 notif_sync_service, 397 notif_sync_service,
421 change_processor); 398 change_processor);
422 return SyncComponents(sync_service_adapter, change_processor); 399 return SyncComponents(sync_service_adapter, change_processor);
423 } 400 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698