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

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

Issue 10829019: [sync] Refactor how default sync datatypes are set. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Registering extension prefs and using standard constructor Created 8 years, 4 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 extensions::ExtensionSystemFactory::GetForProfile(profile)), 91 extensions::ExtensionSystemFactory::GetForProfile(profile)),
92 web_data_service_(WebDataServiceFactory::GetForProfile( 92 web_data_service_(WebDataServiceFactory::GetForProfile(
93 profile_, Profile::IMPLICIT_ACCESS)) { 93 profile_, Profile::IMPLICIT_ACCESS)) {
94 } 94 }
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 RegisterCommonDataTypes(pss);
102 #if !defined(OS_ANDROID)
103 RegisterDesktopDataTypes(pss);
104 #endif
105 }
106
107 void ProfileSyncComponentsFactoryImpl::RegisterCommonDataTypes(
108 ProfileSyncService* pss) {
109 // Bookmark sync is enabled by default. Register unless explicitly
110 // disabled.
111 if (!command_line_->HasSwitch(switches::kDisableSyncBookmarks)) {
112 pss->RegisterDataTypeController(
113 new BookmarkDataTypeController(this, profile_, pss));
114 }
115
116 // TypedUrl sync is enabled by default. Register unless explicitly disabled,
117 // or if saving history is disabled.
118 if (!profile_->GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled) &&
119 !command_line_->HasSwitch(switches::kDisableSyncTypedUrls)) {
120 pss->RegisterDataTypeController(
121 new TypedUrlDataTypeController(this, profile_, pss));
122 }
123
124 // Session sync is enabled by default. Register unless explicitly disabled.
125 if (!command_line_->HasSwitch(switches::kDisableSyncTabs)) {
126 pss->RegisterDataTypeController(
127 new SessionDataTypeController(this, profile_, pss));
128 }
129 }
130
131 void ProfileSyncComponentsFactoryImpl::RegisterDesktopDataTypes(
132 ProfileSyncService* pss) {
101 // App sync is enabled by default. Register unless explicitly 133 // App sync is enabled by default. Register unless explicitly
102 // disabled. 134 // disabled.
103 if (!command_line_->HasSwitch(switches::kDisableSyncApps)) { 135 if (!command_line_->HasSwitch(switches::kDisableSyncApps)) {
104 pss->RegisterDataTypeController( 136 pss->RegisterDataTypeController(
105 new ExtensionDataTypeController(syncer::APPS, this, profile_, pss)); 137 new ExtensionDataTypeController(syncer::APPS, this, profile_, pss));
106 } 138 }
107 139
108 // Autofill sync is enabled by default. Register unless explicitly 140 // Autofill sync is enabled by default. Register unless explicitly
109 // disabled. 141 // disabled.
110 if (!command_line_->HasSwitch(switches::kDisableSyncAutofill)) { 142 if (!command_line_->HasSwitch(switches::kDisableSyncAutofill)) {
111 pss->RegisterDataTypeController( 143 pss->RegisterDataTypeController(
112 new AutofillDataTypeController(this, profile_, pss)); 144 new AutofillDataTypeController(this, profile_, pss));
113 } 145 }
114 146
115 // Bookmark sync is enabled by default. Register unless explicitly
116 // disabled.
117 if (!command_line_->HasSwitch(switches::kDisableSyncBookmarks)) {
118 pss->RegisterDataTypeController(
119 new BookmarkDataTypeController(this, profile_, pss));
120 }
121
122 // Extension sync is enabled by default. Register unless explicitly 147 // Extension sync is enabled by default. Register unless explicitly
123 // disabled. 148 // disabled.
124 if (!command_line_->HasSwitch(switches::kDisableSyncExtensions)) { 149 if (!command_line_->HasSwitch(switches::kDisableSyncExtensions)) {
125 pss->RegisterDataTypeController( 150 pss->RegisterDataTypeController(
126 new ExtensionDataTypeController(syncer::EXTENSIONS, 151 new ExtensionDataTypeController(syncer::EXTENSIONS,
127 this, profile_, pss)); 152 this, profile_, pss));
128 } 153 }
129 154
130 // Password sync is enabled by default. Register unless explicitly 155 // Password sync is enabled by default. Register unless explicitly
131 // disabled. 156 // disabled.
(...skipping 10 matching lines...) Expand all
142 } 167 }
143 168
144 #if defined(ENABLE_THEMES) 169 #if defined(ENABLE_THEMES)
145 // Theme sync is enabled by default. Register unless explicitly disabled. 170 // Theme sync is enabled by default. Register unless explicitly disabled.
146 if (!command_line_->HasSwitch(switches::kDisableSyncThemes)) { 171 if (!command_line_->HasSwitch(switches::kDisableSyncThemes)) {
147 pss->RegisterDataTypeController( 172 pss->RegisterDataTypeController(
148 new ThemeDataTypeController(this, profile_, pss)); 173 new ThemeDataTypeController(this, profile_, pss));
149 } 174 }
150 #endif 175 #endif
151 176
152 // TypedUrl sync is enabled by default. Register unless explicitly disabled,
153 // or if saving history is disabled.
154 if (!profile_->GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled) &&
155 !command_line_->HasSwitch(switches::kDisableSyncTypedUrls)) {
156 pss->RegisterDataTypeController(
157 new TypedUrlDataTypeController(this, profile_, pss));
158 }
159
160 // Search Engine sync is enabled by default. Register only if explicitly 177 // Search Engine sync is enabled by default. Register only if explicitly
161 // disabled. 178 // disabled.
162 if (!command_line_->HasSwitch(switches::kDisableSyncSearchEngines)) { 179 if (!command_line_->HasSwitch(switches::kDisableSyncSearchEngines)) {
163 pss->RegisterDataTypeController( 180 pss->RegisterDataTypeController(
164 new SearchEngineDataTypeController(this, profile_, pss)); 181 new SearchEngineDataTypeController(this, profile_, pss));
165 } 182 }
166 183
167 // Session sync is enabled by default. Register unless explicitly disabled.
168 if (!command_line_->HasSwitch(switches::kDisableSyncTabs)) {
169 pss->RegisterDataTypeController(
170 new SessionDataTypeController(this, profile_, pss));
171 }
172
173 // Extension setting sync is enabled by default. Register unless explicitly 184 // Extension setting sync is enabled by default. Register unless explicitly
174 // disabled. 185 // disabled.
175 if (!command_line_->HasSwitch(switches::kDisableSyncExtensionSettings)) { 186 if (!command_line_->HasSwitch(switches::kDisableSyncExtensionSettings)) {
176 pss->RegisterDataTypeController( 187 pss->RegisterDataTypeController(
177 new ExtensionSettingDataTypeController( 188 new ExtensionSettingDataTypeController(
178 syncer::EXTENSION_SETTINGS, this, profile_, pss)); 189 syncer::EXTENSION_SETTINGS, this, profile_, pss));
179 } 190 }
180 191
181 // App setting sync is enabled by default. Register unless explicitly 192 // App setting sync is enabled by default. Register unless explicitly
182 // disabled. 193 // disabled.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 GetAutofillProfileSyncableService()->AsWeakPtr(); 251 GetAutofillProfileSyncableService()->AsWeakPtr();
241 } 252 }
242 } 253 }
243 case syncer::APPS: 254 case syncer::APPS:
244 case syncer::EXTENSIONS: 255 case syncer::EXTENSIONS:
245 return extension_system_->extension_service()->AsWeakPtr(); 256 return extension_system_->extension_service()->AsWeakPtr();
246 case syncer::SEARCH_ENGINES: 257 case syncer::SEARCH_ENGINES:
247 return TemplateURLServiceFactory::GetForProfile(profile_)->AsWeakPtr(); 258 return TemplateURLServiceFactory::GetForProfile(profile_)->AsWeakPtr();
248 case syncer::APP_SETTINGS: 259 case syncer::APP_SETTINGS:
249 case syncer::EXTENSION_SETTINGS: 260 case syncer::EXTENSION_SETTINGS:
261 #if defined(OS_ANDROID)
262 // Android does not sync application or extension settings.
263 NOTREACHED();
264 return base::WeakPtr<syncer::SyncableService>();
nilesh 2012/08/01 16:43:20 Now that we are initializing extension system, I t
nyquist 2012/08/02 18:28:17 Verified that it still builds and you can sign in
265 #else
250 return extension_system_->extension_service()->settings_frontend()-> 266 return extension_system_->extension_service()->settings_frontend()->
251 GetBackendForSync(type)->AsWeakPtr(); 267 GetBackendForSync(type)->AsWeakPtr();
268 #endif
252 case syncer::APP_NOTIFICATIONS: 269 case syncer::APP_NOTIFICATIONS:
253 return extension_system_->extension_service()-> 270 return extension_system_->extension_service()->
254 app_notification_manager()->AsWeakPtr(); 271 app_notification_manager()->AsWeakPtr();
255 default: 272 default:
256 // The following datatypes still need to be transitioned to the 273 // The following datatypes still need to be transitioned to the
257 // syncer::SyncableService API: 274 // syncer::SyncableService API:
258 // Bookmarks 275 // Bookmarks
259 // Passwords 276 // Passwords
260 // Sessions 277 // Sessions
261 // Themes 278 // Themes
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 ProfileSyncComponentsFactory::SyncComponents 355 ProfileSyncComponentsFactory::SyncComponents
339 ProfileSyncComponentsFactoryImpl::CreateSessionSyncComponents( 356 ProfileSyncComponentsFactoryImpl::CreateSessionSyncComponents(
340 ProfileSyncService* profile_sync_service, 357 ProfileSyncService* profile_sync_service,
341 DataTypeErrorHandler* error_handler) { 358 DataTypeErrorHandler* error_handler) {
342 SessionModelAssociator* model_associator = 359 SessionModelAssociator* model_associator =
343 new SessionModelAssociator(profile_sync_service, error_handler); 360 new SessionModelAssociator(profile_sync_service, error_handler);
344 SessionChangeProcessor* change_processor = 361 SessionChangeProcessor* change_processor =
345 new SessionChangeProcessor(error_handler, model_associator); 362 new SessionChangeProcessor(error_handler, model_associator);
346 return SyncComponents(model_associator, change_processor); 363 return SyncComponents(model_associator, change_processor);
347 } 364 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698