Commit 1a77e63e authored by nyquist@chromium.org's avatar nyquist@chromium.org

[sync] Refactor how default sync datatypes are set.

Android does not sync all datatypes, so we need a way to differentiate
which datatypes should be enabled by default.

Since parts of this require extensions, we need to register the user preferences for extensions as part of this.

BUG=139057
TEST=Signing in to sync on should enable all the correct default
datatypes.

Review URL: https://chromiumcodereview.appspot.com/10829019

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150485 0039d316-1c4b-4281-b951-d872f2087c98
parent dfcc8927
...@@ -201,6 +201,7 @@ void RegisterUserPrefs(PrefService* user_prefs) { ...@@ -201,6 +201,7 @@ void RegisterUserPrefs(PrefService* user_prefs) {
chrome_browser_net::HttpServerPropertiesManager::RegisterPrefs(user_prefs); chrome_browser_net::HttpServerPropertiesManager::RegisterPrefs(user_prefs);
chrome_browser_net::Predictor::RegisterUserPrefs(user_prefs); chrome_browser_net::Predictor::RegisterUserPrefs(user_prefs);
DownloadPrefs::RegisterUserPrefs(user_prefs); DownloadPrefs::RegisterUserPrefs(user_prefs);
extensions::ExtensionPrefs::RegisterUserPrefs(user_prefs);
ExtensionWebUI::RegisterUserPrefs(user_prefs); ExtensionWebUI::RegisterUserPrefs(user_prefs);
GAIAInfoUpdateService::RegisterUserPrefs(user_prefs); GAIAInfoUpdateService::RegisterUserPrefs(user_prefs);
HostContentSettingsMap::RegisterUserPrefs(user_prefs); HostContentSettingsMap::RegisterUserPrefs(user_prefs);
...@@ -242,7 +243,6 @@ void RegisterUserPrefs(PrefService* user_prefs) { ...@@ -242,7 +243,6 @@ void RegisterUserPrefs(PrefService* user_prefs) {
ChromeToMobileService::RegisterUserPrefs(user_prefs); ChromeToMobileService::RegisterUserPrefs(user_prefs);
extensions::CommandService::RegisterUserPrefs(user_prefs); extensions::CommandService::RegisterUserPrefs(user_prefs);
extensions::ComponentLoader::RegisterUserPrefs(user_prefs); extensions::ComponentLoader::RegisterUserPrefs(user_prefs);
extensions::ExtensionPrefs::RegisterUserPrefs(user_prefs);
ExtensionSettingsHandler::RegisterUserPrefs(user_prefs); ExtensionSettingsHandler::RegisterUserPrefs(user_prefs);
RegisterBrowserUserPrefs(user_prefs); RegisterBrowserUserPrefs(user_prefs);
RegisterAutolaunchPrefs(user_prefs); RegisterAutolaunchPrefs(user_prefs);
......
...@@ -99,6 +99,38 @@ ProfileSyncComponentsFactoryImpl::~ProfileSyncComponentsFactoryImpl() { ...@@ -99,6 +99,38 @@ ProfileSyncComponentsFactoryImpl::~ProfileSyncComponentsFactoryImpl() {
void ProfileSyncComponentsFactoryImpl::RegisterDataTypes( void ProfileSyncComponentsFactoryImpl::RegisterDataTypes(
ProfileSyncService* pss) { ProfileSyncService* pss) {
RegisterCommonDataTypes(pss);
#if !defined(OS_ANDROID)
RegisterDesktopDataTypes(pss);
#endif
}
void ProfileSyncComponentsFactoryImpl::RegisterCommonDataTypes(
ProfileSyncService* pss) {
// Bookmark sync is enabled by default. Register unless explicitly
// disabled.
if (!command_line_->HasSwitch(switches::kDisableSyncBookmarks)) {
pss->RegisterDataTypeController(
new BookmarkDataTypeController(this, profile_, pss));
}
// TypedUrl sync is enabled by default. Register unless explicitly disabled,
// or if saving history is disabled.
if (!profile_->GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled) &&
!command_line_->HasSwitch(switches::kDisableSyncTypedUrls)) {
pss->RegisterDataTypeController(
new TypedUrlDataTypeController(this, profile_, pss));
}
// Session sync is enabled by default. Register unless explicitly disabled.
if (!command_line_->HasSwitch(switches::kDisableSyncTabs)) {
pss->RegisterDataTypeController(
new SessionDataTypeController(this, profile_, pss));
}
}
void ProfileSyncComponentsFactoryImpl::RegisterDesktopDataTypes(
ProfileSyncService* pss) {
// App sync is enabled by default. Register unless explicitly // App sync is enabled by default. Register unless explicitly
// disabled. // disabled.
if (!command_line_->HasSwitch(switches::kDisableSyncApps)) { if (!command_line_->HasSwitch(switches::kDisableSyncApps)) {
...@@ -113,13 +145,6 @@ void ProfileSyncComponentsFactoryImpl::RegisterDataTypes( ...@@ -113,13 +145,6 @@ void ProfileSyncComponentsFactoryImpl::RegisterDataTypes(
new AutofillDataTypeController(this, profile_, pss)); new AutofillDataTypeController(this, profile_, pss));
} }
// Bookmark sync is enabled by default. Register unless explicitly
// disabled.
if (!command_line_->HasSwitch(switches::kDisableSyncBookmarks)) {
pss->RegisterDataTypeController(
new BookmarkDataTypeController(this, profile_, pss));
}
// Extension sync is enabled by default. Register unless explicitly // Extension sync is enabled by default. Register unless explicitly
// disabled. // disabled.
if (!command_line_->HasSwitch(switches::kDisableSyncExtensions)) { if (!command_line_->HasSwitch(switches::kDisableSyncExtensions)) {
...@@ -150,14 +175,6 @@ void ProfileSyncComponentsFactoryImpl::RegisterDataTypes( ...@@ -150,14 +175,6 @@ void ProfileSyncComponentsFactoryImpl::RegisterDataTypes(
} }
#endif #endif
// TypedUrl sync is enabled by default. Register unless explicitly disabled,
// or if saving history is disabled.
if (!profile_->GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled) &&
!command_line_->HasSwitch(switches::kDisableSyncTypedUrls)) {
pss->RegisterDataTypeController(
new TypedUrlDataTypeController(this, profile_, pss));
}
// Search Engine sync is enabled by default. Register only if explicitly // Search Engine sync is enabled by default. Register only if explicitly
// disabled. // disabled.
if (!command_line_->HasSwitch(switches::kDisableSyncSearchEngines)) { if (!command_line_->HasSwitch(switches::kDisableSyncSearchEngines)) {
...@@ -165,12 +182,6 @@ void ProfileSyncComponentsFactoryImpl::RegisterDataTypes( ...@@ -165,12 +182,6 @@ void ProfileSyncComponentsFactoryImpl::RegisterDataTypes(
new SearchEngineDataTypeController(this, profile_, pss)); new SearchEngineDataTypeController(this, profile_, pss));
} }
// Session sync is enabled by default. Register unless explicitly disabled.
if (!command_line_->HasSwitch(switches::kDisableSyncTabs)) {
pss->RegisterDataTypeController(
new SessionDataTypeController(this, profile_, pss));
}
// Extension setting sync is enabled by default. Register unless explicitly // Extension setting sync is enabled by default. Register unless explicitly
// disabled. // disabled.
if (!command_line_->HasSwitch(switches::kDisableSyncExtensionSettings)) { if (!command_line_->HasSwitch(switches::kDisableSyncExtensionSettings)) {
......
...@@ -64,6 +64,11 @@ class ProfileSyncComponentsFactoryImpl : public ProfileSyncComponentsFactory { ...@@ -64,6 +64,11 @@ class ProfileSyncComponentsFactoryImpl : public ProfileSyncComponentsFactory {
browser_sync::DataTypeErrorHandler* error_handler) OVERRIDE; browser_sync::DataTypeErrorHandler* error_handler) OVERRIDE;
private: private:
// Register data types which are enabled on desktop platforms only.
void RegisterDesktopDataTypes(ProfileSyncService* pss);
// Register data types which are enabled on both desktop and mobile.
void RegisterCommonDataTypes(ProfileSyncService* pss);
Profile* profile_; Profile* profile_;
CommandLine* command_line_; CommandLine* command_line_;
// Set on the UI thread (since extensions::ExtensionSystemFactory is // Set on the UI thread (since extensions::ExtensionSystemFactory is
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment