Commit e2e77251 authored by zea's avatar zea Committed by Commit bot

[Sync] Device info should be enabled by default

Device info is always enabled, regardless of sync everything state.

BUG=429217

Review URL: https://codereview.chromium.org/694903002

Cr-Commit-Position: refs/heads/master@{#302487}
parent 22299120
...@@ -112,6 +112,10 @@ IN_PROC_BROWSER_TEST_F(EnableDisableSingleClientTest, DisableOneAtATime) { ...@@ -112,6 +112,10 @@ IN_PROC_BROWSER_TEST_F(EnableDisableSingleClientTest, DisableOneAtATime) {
it.Get() == syncer::SYNCED_NOTIFICATION_APP_INFO) it.Get() == syncer::SYNCED_NOTIFICATION_APP_INFO)
continue; continue;
// Device info cannot be disabled.
if (it.Get() == syncer::DEVICE_INFO)
continue;
ASSERT_TRUE(GetClient(0)->DisableSyncForDatatype(it.Get())); ASSERT_TRUE(GetClient(0)->DisableSyncForDatatype(it.Get()));
// AUTOFILL_PROFILE is lumped together with AUTOFILL. // AUTOFILL_PROFILE is lumped together with AUTOFILL.
......
...@@ -66,9 +66,11 @@ void SyncPrefs::RegisterProfilePrefs( ...@@ -66,9 +66,11 @@ void SyncPrefs::RegisterProfilePrefs(
// although they don't have sync representations. // although they don't have sync representations.
user_types.PutAll(syncer::ProxyTypes()); user_types.PutAll(syncer::ProxyTypes());
// Treat bookmarks specially. // Treat bookmarks and device info specially.
RegisterDataTypePreferredPref(registry, syncer::BOOKMARKS, true); RegisterDataTypePreferredPref(registry, syncer::BOOKMARKS, true);
RegisterDataTypePreferredPref(registry, syncer::DEVICE_INFO, true);
user_types.Remove(syncer::BOOKMARKS); user_types.Remove(syncer::BOOKMARKS);
user_types.Remove(syncer::DEVICE_INFO);
// These two prefs are set from sync experiment to enable enhanced bookmarks. // These two prefs are set from sync experiment to enable enhanced bookmarks.
registry->RegisterIntegerPref( registry->RegisterIntegerPref(
...@@ -349,7 +351,7 @@ const char* SyncPrefs::GetPrefNameForDataType(syncer::ModelType data_type) { ...@@ -349,7 +351,7 @@ const char* SyncPrefs::GetPrefNameForDataType(syncer::ModelType data_type) {
default: default:
break; break;
} }
NOTREACHED(); NOTREACHED() << "Type is " << data_type;
return NULL; return NULL;
} }
...@@ -454,6 +456,11 @@ bool SyncPrefs::GetDataTypePreferred(syncer::ModelType type) const { ...@@ -454,6 +456,11 @@ bool SyncPrefs::GetDataTypePreferred(syncer::ModelType type) const {
NOTREACHED(); NOTREACHED();
return false; return false;
} }
// Device info is always enabled.
if (pref_name == prefs::kSyncDeviceInfo)
return true;
if (type == syncer::PROXY_TABS && if (type == syncer::PROXY_TABS &&
pref_service_->GetUserPrefValue(pref_name) == NULL && pref_service_->GetUserPrefValue(pref_name) == NULL &&
pref_service_->IsUserModifiablePreference(pref_name)) { pref_service_->IsUserModifiablePreference(pref_name)) {
...@@ -473,6 +480,11 @@ void SyncPrefs::SetDataTypePreferred(syncer::ModelType type, ...@@ -473,6 +480,11 @@ void SyncPrefs::SetDataTypePreferred(syncer::ModelType type,
NOTREACHED(); NOTREACHED();
return; return;
} }
// Device info is always preferred.
if (type == syncer::DEVICE_INFO)
return;
pref_service_->SetBoolean(pref_name, is_preferred); pref_service_->SetBoolean(pref_name, is_preferred);
} }
......
...@@ -68,10 +68,11 @@ TEST_F(SyncPrefsTest, DefaultTypes) { ...@@ -68,10 +68,11 @@ TEST_F(SyncPrefsTest, DefaultTypes) {
SyncPrefs sync_prefs(&pref_service_); SyncPrefs sync_prefs(&pref_service_);
sync_prefs.SetKeepEverythingSynced(false); sync_prefs.SetKeepEverythingSynced(false);
// Only bookmarks are enabled by default. // Only bookmarks and device info are enabled by default.
syncer::ModelTypeSet expected(syncer::BOOKMARKS, syncer::DEVICE_INFO);
syncer::ModelTypeSet preferred_types = syncer::ModelTypeSet preferred_types =
sync_prefs.GetPreferredDataTypes(syncer::UserTypes()); sync_prefs.GetPreferredDataTypes(syncer::UserTypes());
EXPECT_TRUE(preferred_types.Equals(syncer::ModelTypeSet(syncer::BOOKMARKS))); EXPECT_TRUE(preferred_types.Equals(expected));
// Simulate an upgrade to delete directives + proxy tabs support. None of the // Simulate an upgrade to delete directives + proxy tabs support. None of the
// new types or their pref group types should be registering, ensuring they // new types or their pref group types should be registering, ensuring they
...@@ -164,6 +165,10 @@ TEST_F(SyncPrefsTest, PreferredTypesNotKeepEverythingSynced) { ...@@ -164,6 +165,10 @@ TEST_F(SyncPrefsTest, PreferredTypesNotKeepEverythingSynced) {
expected_preferred_types.Put(syncer::FAVICON_IMAGES); expected_preferred_types.Put(syncer::FAVICON_IMAGES);
expected_preferred_types.Put(syncer::FAVICON_TRACKING); expected_preferred_types.Put(syncer::FAVICON_TRACKING);
} }
// Device info is always preferred.
expected_preferred_types.Put(syncer::DEVICE_INFO);
sync_prefs.SetPreferredDataTypes(user_types, preferred_types); sync_prefs.SetPreferredDataTypes(user_types, preferred_types);
EXPECT_TRUE(expected_preferred_types.Equals( EXPECT_TRUE(expected_preferred_types.Equals(
sync_prefs.GetPreferredDataTypes(user_types))); sync_prefs.GetPreferredDataTypes(user_types)));
...@@ -232,6 +237,19 @@ TEST_F(SyncPrefsTest, ClearPreferences) { ...@@ -232,6 +237,19 @@ TEST_F(SyncPrefsTest, ClearPreferences) {
EXPECT_TRUE(sync_prefs.GetEncryptionBootstrapToken().empty()); EXPECT_TRUE(sync_prefs.GetEncryptionBootstrapToken().empty());
} }
// Device info should always be enabled.
TEST_F(SyncPrefsTest, DeviceInfo) {
SyncPrefs sync_prefs(&pref_service_);
EXPECT_TRUE(sync_prefs.GetPreferredDataTypes(syncer::UserTypes())
.Has(syncer::DEVICE_INFO));
sync_prefs.SetKeepEverythingSynced(true);
EXPECT_TRUE(sync_prefs.GetPreferredDataTypes(syncer::UserTypes())
.Has(syncer::DEVICE_INFO));
sync_prefs.SetKeepEverythingSynced(false);
EXPECT_TRUE(sync_prefs.GetPreferredDataTypes(syncer::UserTypes())
.Has(syncer::DEVICE_INFO));
}
} // namespace } // namespace
} // namespace sync_driver } // namespace sync_driver
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