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

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

Issue 7775008: Enable sync for the settings from the Extension Settings API. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Review #6 Created 9 years, 3 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) 2011 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/extension_service.h" 6 #include "chrome/browser/extensions/extension_service.h"
7 #include "chrome/browser/extensions/extension_settings.h"
7 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/search_engines/template_url_service.h" 9 #include "chrome/browser/search_engines/template_url_service.h"
9 #include "chrome/browser/search_engines/template_url_service_factory.h" 10 #include "chrome/browser/search_engines/template_url_service_factory.h"
10 #include "chrome/browser/sync/api/syncable_service.h" 11 #include "chrome/browser/sync/api/syncable_service.h"
11 #include "chrome/browser/sync/glue/app_data_type_controller.h" 12 #include "chrome/browser/sync/glue/app_data_type_controller.h"
12 #include "chrome/browser/sync/glue/autofill_change_processor.h" 13 #include "chrome/browser/sync/glue/autofill_change_processor.h"
13 #include "chrome/browser/sync/glue/autofill_data_type_controller.h" 14 #include "chrome/browser/sync/glue/autofill_data_type_controller.h"
14 #include "chrome/browser/sync/glue/autofill_model_associator.h" 15 #include "chrome/browser/sync/glue/autofill_model_associator.h"
15 #include "chrome/browser/sync/glue/autofill_profile_change_processor.h" 16 #include "chrome/browser/sync/glue/autofill_profile_change_processor.h"
16 #include "chrome/browser/sync/glue/autofill_profile_data_type_controller.h" 17 #include "chrome/browser/sync/glue/autofill_profile_data_type_controller.h"
17 #include "chrome/browser/sync/glue/autofill_profile_model_associator.h" 18 #include "chrome/browser/sync/glue/autofill_profile_model_associator.h"
18 #include "chrome/browser/sync/glue/bookmark_change_processor.h" 19 #include "chrome/browser/sync/glue/bookmark_change_processor.h"
19 #include "chrome/browser/sync/glue/bookmark_data_type_controller.h" 20 #include "chrome/browser/sync/glue/bookmark_data_type_controller.h"
20 #include "chrome/browser/sync/glue/bookmark_model_associator.h" 21 #include "chrome/browser/sync/glue/bookmark_model_associator.h"
21 #include "chrome/browser/sync/glue/data_type_manager_impl.h" 22 #include "chrome/browser/sync/glue/data_type_manager_impl.h"
22 #include "chrome/browser/sync/glue/extension_data_type_controller.h" 23 #include "chrome/browser/sync/glue/extension_data_type_controller.h"
24 #include "chrome/browser/sync/glue/extension_setting_data_type_controller.h"
23 #include "chrome/browser/sync/glue/generic_change_processor.h" 25 #include "chrome/browser/sync/glue/generic_change_processor.h"
24 #include "chrome/browser/sync/glue/password_change_processor.h" 26 #include "chrome/browser/sync/glue/password_change_processor.h"
25 #include "chrome/browser/sync/glue/password_data_type_controller.h" 27 #include "chrome/browser/sync/glue/password_data_type_controller.h"
26 #include "chrome/browser/sync/glue/password_model_associator.h" 28 #include "chrome/browser/sync/glue/password_model_associator.h"
27 #include "chrome/browser/sync/glue/preference_data_type_controller.h" 29 #include "chrome/browser/sync/glue/preference_data_type_controller.h"
28 #include "chrome/browser/sync/glue/search_engine_data_type_controller.h" 30 #include "chrome/browser/sync/glue/search_engine_data_type_controller.h"
29 #include "chrome/browser/sync/glue/session_change_processor.h" 31 #include "chrome/browser/sync/glue/session_change_processor.h"
30 #include "chrome/browser/sync/glue/session_data_type_controller.h" 32 #include "chrome/browser/sync/glue/session_data_type_controller.h"
31 #include "chrome/browser/sync/glue/session_model_associator.h" 33 #include "chrome/browser/sync/glue/session_model_associator.h"
32 #include "chrome/browser/sync/glue/syncable_service_adapter.h" 34 #include "chrome/browser/sync/glue/syncable_service_adapter.h"
33 #include "chrome/browser/sync/glue/sync_backend_host.h" 35 #include "chrome/browser/sync/glue/sync_backend_host.h"
34 #include "chrome/browser/sync/glue/theme_change_processor.h" 36 #include "chrome/browser/sync/glue/theme_change_processor.h"
35 #include "chrome/browser/sync/glue/theme_data_type_controller.h" 37 #include "chrome/browser/sync/glue/theme_data_type_controller.h"
36 #include "chrome/browser/sync/glue/theme_model_associator.h" 38 #include "chrome/browser/sync/glue/theme_model_associator.h"
37 #include "chrome/browser/sync/glue/typed_url_change_processor.h" 39 #include "chrome/browser/sync/glue/typed_url_change_processor.h"
38 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h" 40 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h"
39 #include "chrome/browser/sync/glue/typed_url_model_associator.h" 41 #include "chrome/browser/sync/glue/typed_url_model_associator.h"
40 #include "chrome/browser/sync/profile_sync_service.h" 42 #include "chrome/browser/sync/profile_sync_service.h"
41 #include "chrome/browser/sync/profile_sync_factory_impl.h" 43 #include "chrome/browser/sync/profile_sync_factory_impl.h"
42 #include "chrome/browser/sync/signin_manager.h" 44 #include "chrome/browser/sync/signin_manager.h"
43 #include "chrome/browser/webdata/web_data_service.h" 45 #include "chrome/browser/webdata/web_data_service.h"
44 #include "chrome/common/chrome_switches.h" 46 #include "chrome/common/chrome_switches.h"
45 #include "chrome/common/pref_names.h" 47 #include "chrome/common/pref_names.h"
48 #include "content/browser/browser_thread.h"
46 49
47 using browser_sync::AppDataTypeController; 50 using browser_sync::AppDataTypeController;
48 using browser_sync::AutofillChangeProcessor; 51 using browser_sync::AutofillChangeProcessor;
49 using browser_sync::AutofillProfileChangeProcessor; 52 using browser_sync::AutofillProfileChangeProcessor;
50 using browser_sync::AutofillDataTypeController; 53 using browser_sync::AutofillDataTypeController;
51 using browser_sync::AutofillProfileDataTypeController; 54 using browser_sync::AutofillProfileDataTypeController;
52 using browser_sync::AutofillModelAssociator; 55 using browser_sync::AutofillModelAssociator;
53 using browser_sync::AutofillProfileModelAssociator; 56 using browser_sync::AutofillProfileModelAssociator;
54 using browser_sync::BookmarkChangeProcessor; 57 using browser_sync::BookmarkChangeProcessor;
55 using browser_sync::BookmarkDataTypeController; 58 using browser_sync::BookmarkDataTypeController;
56 using browser_sync::BookmarkModelAssociator; 59 using browser_sync::BookmarkModelAssociator;
57 using browser_sync::DataTypeController; 60 using browser_sync::DataTypeController;
58 using browser_sync::DataTypeManager; 61 using browser_sync::DataTypeManager;
59 using browser_sync::DataTypeManagerImpl; 62 using browser_sync::DataTypeManagerImpl;
60 using browser_sync::ExtensionDataTypeController; 63 using browser_sync::ExtensionDataTypeController;
64 using browser_sync::ExtensionSettingDataTypeController;
61 using browser_sync::GenericChangeProcessor; 65 using browser_sync::GenericChangeProcessor;
62 using browser_sync::PasswordChangeProcessor; 66 using browser_sync::PasswordChangeProcessor;
63 using browser_sync::PasswordDataTypeController; 67 using browser_sync::PasswordDataTypeController;
64 using browser_sync::PasswordModelAssociator; 68 using browser_sync::PasswordModelAssociator;
65 using browser_sync::PreferenceDataTypeController; 69 using browser_sync::PreferenceDataTypeController;
66 using browser_sync::SearchEngineDataTypeController; 70 using browser_sync::SearchEngineDataTypeController;
67 using browser_sync::SessionChangeProcessor; 71 using browser_sync::SessionChangeProcessor;
68 using browser_sync::SessionDataTypeController; 72 using browser_sync::SessionDataTypeController;
69 using browser_sync::SessionModelAssociator; 73 using browser_sync::SessionModelAssociator;
70 using browser_sync::SyncableServiceAdapter; 74 using browser_sync::SyncableServiceAdapter;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 new TypedUrlDataTypeController(this, profile_)); 152 new TypedUrlDataTypeController(this, profile_));
149 } 153 }
150 154
151 // Session sync is disabled by default. Register only if explicitly 155 // Session sync is disabled by default. Register only if explicitly
152 // enabled. 156 // enabled.
153 if (command_line_->HasSwitch(switches::kEnableSyncTabs)) { 157 if (command_line_->HasSwitch(switches::kEnableSyncTabs)) {
154 pss->RegisterDataTypeController( 158 pss->RegisterDataTypeController(
155 new SessionDataTypeController(this, profile_, pss)); 159 new SessionDataTypeController(this, profile_, pss));
156 } 160 }
157 161
162 // Extension setting sync is disabled by default. Register only if
163 // explicitly enabled.
164 if (command_line_->HasSwitch(switches::kEnableSyncExtensionSettings)) {
165 pss->RegisterDataTypeController(
166 new ExtensionSettingDataTypeController(this, profile_, pss));
167 }
168
158 if (!command_line_->HasSwitch(switches::kDisableSyncAutofillProfile)) { 169 if (!command_line_->HasSwitch(switches::kDisableSyncAutofillProfile)) {
159 pss->RegisterDataTypeController( 170 pss->RegisterDataTypeController(
160 new AutofillProfileDataTypeController(this, profile_)); 171 new AutofillProfileDataTypeController(this, profile_));
161 } 172 }
162 173
163 // Search Engine sync is disabled by default. Register only if explicitly 174 // Search Engine sync is disabled by default. Register only if explicitly
164 // enabled. 175 // enabled.
165 if (command_line_->HasSwitch(switches::kEnableSyncSearchEngines)) { 176 if (command_line_->HasSwitch(switches::kEnableSyncSearchEngines)) {
166 pss->RegisterDataTypeController( 177 pss->RegisterDataTypeController(
167 new SearchEngineDataTypeController(this, profile_, pss)); 178 new SearchEngineDataTypeController(this, profile_, pss));
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 new BookmarkModelAssociator(bookmark_model, 250 new BookmarkModelAssociator(bookmark_model,
240 user_share, 251 user_share,
241 error_handler); 252 error_handler);
242 BookmarkChangeProcessor* change_processor = 253 BookmarkChangeProcessor* change_processor =
243 new BookmarkChangeProcessor(model_associator, 254 new BookmarkChangeProcessor(model_associator,
244 error_handler); 255 error_handler);
245 return SyncComponents(model_associator, change_processor); 256 return SyncComponents(model_associator, change_processor);
246 } 257 }
247 258
248 ProfileSyncFactory::SyncComponents 259 ProfileSyncFactory::SyncComponents
260 ProfileSyncFactoryImpl::CreateExtensionSettingSyncComponents(
261 ExtensionSettings* extension_settings,
262 ProfileSyncService* profile_sync_service,
263 UnrecoverableErrorHandler* error_handler) {
264 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
265 sync_api::UserShare* user_share = profile_sync_service->GetUserShare();
266 GenericChangeProcessor* change_processor =
267 new GenericChangeProcessor(extension_settings, error_handler, user_share);
268 browser_sync::SyncableServiceAdapter* sync_service_adapter =
269 new browser_sync::SyncableServiceAdapter(syncable::EXTENSION_SETTINGS,
270 extension_settings,
271 change_processor);
272 return SyncComponents(sync_service_adapter, change_processor);
273 }
274
275 ProfileSyncFactory::SyncComponents
249 ProfileSyncFactoryImpl::CreateExtensionSyncComponents( 276 ProfileSyncFactoryImpl::CreateExtensionSyncComponents(
250 ProfileSyncService* profile_sync_service, 277 ProfileSyncService* profile_sync_service,
251 UnrecoverableErrorHandler* error_handler) { 278 UnrecoverableErrorHandler* error_handler) {
252 SyncableService* extension_sync_service = 279 SyncableService* extension_sync_service =
253 profile_sync_service->profile()->GetExtensionService(); 280 profile_sync_service->profile()->GetExtensionService();
254 sync_api::UserShare* user_share = profile_sync_service->GetUserShare(); 281 sync_api::UserShare* user_share = profile_sync_service->GetUserShare();
255 GenericChangeProcessor* change_processor = 282 GenericChangeProcessor* change_processor =
256 new GenericChangeProcessor(extension_sync_service, error_handler, 283 new GenericChangeProcessor(extension_sync_service, error_handler,
257 user_share); 284 user_share);
258 browser_sync::SyncableServiceAdapter* sync_service_adapter = 285 browser_sync::SyncableServiceAdapter* sync_service_adapter =
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 DCHECK(se_sync_service); 366 DCHECK(se_sync_service);
340 sync_api::UserShare* user_share = profile_sync_service->GetUserShare(); 367 sync_api::UserShare* user_share = profile_sync_service->GetUserShare();
341 GenericChangeProcessor* change_processor = 368 GenericChangeProcessor* change_processor =
342 new GenericChangeProcessor(se_sync_service, error_handler, user_share); 369 new GenericChangeProcessor(se_sync_service, error_handler, user_share);
343 SyncableServiceAdapter* sync_service_adapter = 370 SyncableServiceAdapter* sync_service_adapter =
344 new SyncableServiceAdapter(syncable::SEARCH_ENGINES, 371 new SyncableServiceAdapter(syncable::SEARCH_ENGINES,
345 se_sync_service, 372 se_sync_service,
346 change_processor); 373 change_processor);
347 return SyncComponents(sync_service_adapter, change_processor); 374 return SyncComponents(sync_service_adapter, change_processor);
348 } 375 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698