OLD | NEW |
---|---|
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 using browser_sync::TypedUrlDataTypeController; | 80 using browser_sync::TypedUrlDataTypeController; |
81 using browser_sync::TypedUrlModelAssociator; | 81 using browser_sync::TypedUrlModelAssociator; |
82 using browser_sync::UIDataTypeController; | 82 using browser_sync::UIDataTypeController; |
83 using browser_sync::DataTypeErrorHandler; | 83 using browser_sync::DataTypeErrorHandler; |
84 using content::BrowserThread; | 84 using content::BrowserThread; |
85 | 85 |
86 ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl( | 86 ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl( |
87 Profile* profile, CommandLine* command_line) | 87 Profile* profile, CommandLine* command_line) |
88 : profile_(profile), | 88 : profile_(profile), |
89 command_line_(command_line), | 89 command_line_(command_line), |
90 #if defined(OS_ANDROID) | |
91 extension_system_(NULL) { | |
nilesh
2012/07/27 00:59:07
I think we include ExtensionSystemFactory and this
| |
92 #else | |
90 extension_system_( | 93 extension_system_( |
91 extensions::ExtensionSystemFactory::GetForProfile(profile)), | 94 extensions::ExtensionSystemFactory::GetForProfile(profile)), |
92 web_data_service_(WebDataServiceFactory::GetForProfile( | 95 web_data_service_(WebDataServiceFactory::GetForProfile( |
93 profile_, Profile::IMPLICIT_ACCESS)) { | 96 profile_, Profile::IMPLICIT_ACCESS)) { |
97 #endif | |
94 } | 98 } |
95 | 99 |
96 ProfileSyncComponentsFactoryImpl::~ProfileSyncComponentsFactoryImpl() { | 100 ProfileSyncComponentsFactoryImpl::~ProfileSyncComponentsFactoryImpl() { |
97 } | 101 } |
98 | 102 |
99 void ProfileSyncComponentsFactoryImpl::RegisterDataTypes( | 103 void ProfileSyncComponentsFactoryImpl::RegisterDataTypes( |
100 ProfileSyncService* pss) { | 104 ProfileSyncService* pss) { |
105 RegisterCommonDataTypes(pss); | |
106 #if !defined(OS_ANDROID) | |
107 RegisterDesktopDataTypes(pss); | |
108 #endif | |
109 } | |
110 | |
111 void ProfileSyncComponentsFactoryImpl::RegisterCommonDataTypes( | |
112 ProfileSyncService* pss) { | |
113 // Bookmark sync is enabled by default. Register unless explicitly | |
114 // disabled. | |
115 if (!command_line_->HasSwitch(switches::kDisableSyncBookmarks)) { | |
116 pss->RegisterDataTypeController( | |
117 new BookmarkDataTypeController(this, profile_, pss)); | |
118 } | |
119 | |
120 // TypedUrl sync is enabled by default. Register unless explicitly disabled, | |
121 // or if saving history is disabled. | |
122 if (!profile_->GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled) && | |
123 !command_line_->HasSwitch(switches::kDisableSyncTypedUrls)) { | |
124 pss->RegisterDataTypeController( | |
125 new TypedUrlDataTypeController(this, profile_, pss)); | |
126 } | |
127 | |
128 // Session sync is enabled by default. Register unless explicitly disabled. | |
129 if (!command_line_->HasSwitch(switches::kDisableSyncTabs)) { | |
130 pss->RegisterDataTypeController( | |
131 new SessionDataTypeController(this, profile_, pss)); | |
132 } | |
133 } | |
134 | |
135 void ProfileSyncComponentsFactoryImpl::RegisterDesktopDataTypes( | |
136 ProfileSyncService* pss) { | |
101 // App sync is enabled by default. Register unless explicitly | 137 // App sync is enabled by default. Register unless explicitly |
102 // disabled. | 138 // disabled. |
103 if (!command_line_->HasSwitch(switches::kDisableSyncApps)) { | 139 if (!command_line_->HasSwitch(switches::kDisableSyncApps)) { |
104 pss->RegisterDataTypeController( | 140 pss->RegisterDataTypeController( |
105 new ExtensionDataTypeController(syncer::APPS, this, profile_, pss)); | 141 new ExtensionDataTypeController(syncer::APPS, this, profile_, pss)); |
106 } | 142 } |
107 | 143 |
108 // Autofill sync is enabled by default. Register unless explicitly | 144 // Autofill sync is enabled by default. Register unless explicitly |
109 // disabled. | 145 // disabled. |
110 if (!command_line_->HasSwitch(switches::kDisableSyncAutofill)) { | 146 if (!command_line_->HasSwitch(switches::kDisableSyncAutofill)) { |
111 pss->RegisterDataTypeController( | 147 pss->RegisterDataTypeController( |
112 new AutofillDataTypeController(this, profile_, pss)); | 148 new AutofillDataTypeController(this, profile_, pss)); |
113 } | 149 } |
114 | 150 |
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 | 151 // Extension sync is enabled by default. Register unless explicitly |
123 // disabled. | 152 // disabled. |
124 if (!command_line_->HasSwitch(switches::kDisableSyncExtensions)) { | 153 if (!command_line_->HasSwitch(switches::kDisableSyncExtensions)) { |
125 pss->RegisterDataTypeController( | 154 pss->RegisterDataTypeController( |
126 new ExtensionDataTypeController(syncer::EXTENSIONS, | 155 new ExtensionDataTypeController(syncer::EXTENSIONS, |
127 this, profile_, pss)); | 156 this, profile_, pss)); |
128 } | 157 } |
129 | 158 |
130 // Password sync is enabled by default. Register unless explicitly | 159 // Password sync is enabled by default. Register unless explicitly |
131 // disabled. | 160 // disabled. |
(...skipping 10 matching lines...) Expand all Loading... | |
142 } | 171 } |
143 | 172 |
144 #if defined(ENABLE_THEMES) | 173 #if defined(ENABLE_THEMES) |
145 // Theme sync is enabled by default. Register unless explicitly disabled. | 174 // Theme sync is enabled by default. Register unless explicitly disabled. |
146 if (!command_line_->HasSwitch(switches::kDisableSyncThemes)) { | 175 if (!command_line_->HasSwitch(switches::kDisableSyncThemes)) { |
147 pss->RegisterDataTypeController( | 176 pss->RegisterDataTypeController( |
148 new ThemeDataTypeController(this, profile_, pss)); | 177 new ThemeDataTypeController(this, profile_, pss)); |
149 } | 178 } |
150 #endif | 179 #endif |
151 | 180 |
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 | 181 // Search Engine sync is enabled by default. Register only if explicitly |
161 // disabled. | 182 // disabled. |
162 if (!command_line_->HasSwitch(switches::kDisableSyncSearchEngines)) { | 183 if (!command_line_->HasSwitch(switches::kDisableSyncSearchEngines)) { |
163 pss->RegisterDataTypeController( | 184 pss->RegisterDataTypeController( |
164 new SearchEngineDataTypeController(this, profile_, pss)); | 185 new SearchEngineDataTypeController(this, profile_, pss)); |
165 } | 186 } |
166 | 187 |
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 | 188 // Extension setting sync is enabled by default. Register unless explicitly |
174 // disabled. | 189 // disabled. |
175 if (!command_line_->HasSwitch(switches::kDisableSyncExtensionSettings)) { | 190 if (!command_line_->HasSwitch(switches::kDisableSyncExtensionSettings)) { |
176 pss->RegisterDataTypeController( | 191 pss->RegisterDataTypeController( |
177 new ExtensionSettingDataTypeController( | 192 new ExtensionSettingDataTypeController( |
178 syncer::EXTENSION_SETTINGS, this, profile_, pss)); | 193 syncer::EXTENSION_SETTINGS, this, profile_, pss)); |
179 } | 194 } |
180 | 195 |
181 // App setting sync is enabled by default. Register unless explicitly | 196 // App setting sync is enabled by default. Register unless explicitly |
182 // disabled. | 197 // disabled. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
240 GetAutofillProfileSyncableService()->AsWeakPtr(); | 255 GetAutofillProfileSyncableService()->AsWeakPtr(); |
241 } | 256 } |
242 } | 257 } |
243 case syncer::APPS: | 258 case syncer::APPS: |
244 case syncer::EXTENSIONS: | 259 case syncer::EXTENSIONS: |
245 return extension_system_->extension_service()->AsWeakPtr(); | 260 return extension_system_->extension_service()->AsWeakPtr(); |
246 case syncer::SEARCH_ENGINES: | 261 case syncer::SEARCH_ENGINES: |
247 return TemplateURLServiceFactory::GetForProfile(profile_)->AsWeakPtr(); | 262 return TemplateURLServiceFactory::GetForProfile(profile_)->AsWeakPtr(); |
248 case syncer::APP_SETTINGS: | 263 case syncer::APP_SETTINGS: |
249 case syncer::EXTENSION_SETTINGS: | 264 case syncer::EXTENSION_SETTINGS: |
265 #if defined(OS_ANDROID) | |
266 // Android does not sync application or extension settings. | |
267 NOTREACHED(); | |
268 return base::WeakPtr<syncer::SyncableService>(); | |
269 #else | |
250 return extension_system_->extension_service()->settings_frontend()-> | 270 return extension_system_->extension_service()->settings_frontend()-> |
251 GetBackendForSync(type)->AsWeakPtr(); | 271 GetBackendForSync(type)->AsWeakPtr(); |
272 #endif | |
252 case syncer::APP_NOTIFICATIONS: | 273 case syncer::APP_NOTIFICATIONS: |
253 return extension_system_->extension_service()-> | 274 return extension_system_->extension_service()-> |
254 app_notification_manager()->AsWeakPtr(); | 275 app_notification_manager()->AsWeakPtr(); |
255 default: | 276 default: |
256 // The following datatypes still need to be transitioned to the | 277 // The following datatypes still need to be transitioned to the |
257 // syncer::SyncableService API: | 278 // syncer::SyncableService API: |
258 // Bookmarks | 279 // Bookmarks |
259 // Passwords | 280 // Passwords |
260 // Sessions | 281 // Sessions |
261 // Themes | 282 // Themes |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
338 ProfileSyncComponentsFactory::SyncComponents | 359 ProfileSyncComponentsFactory::SyncComponents |
339 ProfileSyncComponentsFactoryImpl::CreateSessionSyncComponents( | 360 ProfileSyncComponentsFactoryImpl::CreateSessionSyncComponents( |
340 ProfileSyncService* profile_sync_service, | 361 ProfileSyncService* profile_sync_service, |
341 DataTypeErrorHandler* error_handler) { | 362 DataTypeErrorHandler* error_handler) { |
342 SessionModelAssociator* model_associator = | 363 SessionModelAssociator* model_associator = |
343 new SessionModelAssociator(profile_sync_service, error_handler); | 364 new SessionModelAssociator(profile_sync_service, error_handler); |
344 SessionChangeProcessor* change_processor = | 365 SessionChangeProcessor* change_processor = |
345 new SessionChangeProcessor(error_handler, model_associator); | 366 new SessionChangeProcessor(error_handler, model_associator); |
346 return SyncComponents(model_associator, change_processor); | 367 return SyncComponents(model_associator, change_processor); |
347 } | 368 } |
OLD | NEW |