Commit 52b1f708 authored by Chris Sharp's avatar Chris Sharp Committed by Commit Bot

Allow roaming profiles to work even if sync is disabled by policy.

Bug: 1146509
Change-Id: I67d27099b546bc913807f516ec807f36bd74f9a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2523491
Commit-Queue: Chris Sharp <csharp@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Reviewed-by: default avatarJulian Pastarmov <pastarmovj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826299}
parent a0a2773b
...@@ -288,7 +288,8 @@ bool ProfileSyncServiceFactory::IsSyncAllowed(Profile* profile) { ...@@ -288,7 +288,8 @@ bool ProfileSyncServiceFactory::IsSyncAllowed(Profile* profile) {
// No ProfileSyncService created yet - we don't want to create one, so just // No ProfileSyncService created yet - we don't want to create one, so just
// infer the accessible state by looking at prefs/command line flags. // infer the accessible state by looking at prefs/command line flags.
syncer::SyncPrefs prefs(profile->GetPrefs()); syncer::SyncPrefs prefs(profile->GetPrefs());
return switches::IsSyncAllowedByFlag() && !prefs.IsManaged(); return switches::IsSyncAllowedByFlag() &&
(!prefs.IsManaged() || prefs.IsLocalSyncEnabled());
} }
// static // static
......
...@@ -3456,9 +3456,7 @@ ...@@ -3456,9 +3456,7 @@
If this policy is left not set Google Sync will be available for the user to choose whether to use it or not. If this policy is left not set Google Sync will be available for the user to choose whether to use it or not.
To fully disable Google Sync, it is recommended that you disable the Google Sync service in the Google Admin console. To fully disable Google Sync, it is recommended that you disable the Google Sync service in the Google Admin console.''',
This policy should not be enabled when <ph name="ROAMING_PROFILE_SUPPORT_ENABLED_POLICY_NAME">RoamingProfileSupportEnabled</ph> policy is set to enabled as that feature shares the same client side functionality. The Google-hosted synchronization is disabled in this case completely.''',
'arc_support': 'Disabling Google Sync will cause Android Backup and Restore to not function properly.', 'arc_support': 'Disabling Google Sync will cause Android Backup and Restore to not function properly.',
}, },
{ {
...@@ -3498,9 +3496,7 @@ ...@@ -3498,9 +3496,7 @@
'tags': ['local-data-access'], 'tags': ['local-data-access'],
'desc': '''If you enable this setting, the settings stored in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> profiles like bookmarks, autofill data, passwords, etc. will also be written to a file stored in the Roaming user profile folder or a location specified by the Administrator through the <ph name="ROAMING_PROFILE_LOCATION_POLICY_NAME">RoamingProfileLocation</ph> policy. Enabling this policy disables cloud sync. 'desc': '''If you enable this setting, the settings stored in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> profiles like bookmarks, autofill data, passwords, etc. will also be written to a file stored in the Roaming user profile folder or a location specified by the Administrator through the <ph name="ROAMING_PROFILE_LOCATION_POLICY_NAME">RoamingProfileLocation</ph> policy. Enabling this policy disables cloud sync.
If this policy is disabled or left not set only the regular local profiles will be used. If this policy is disabled or left not set only the regular local profiles will be used.''',
The <ph name="SYNC_DISABLED_POLICY_NAME">SyncDisabled</ph> policy disables all data synchronization, overriding <ph name="ROAMING_PROFILE_SUPPORT_ENABLED_POLICY_NAME">RoamingProfileSupportEnabled</ph>.''',
'label': '''Enable the creation of roaming copies for <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> profile data.''', 'label': '''Enable the creation of roaming copies for <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> profile data.''',
}, },
{ {
...@@ -727,18 +727,20 @@ SyncService::DisableReasonSet ProfileSyncService::GetDisableReasons() const { ...@@ -727,18 +727,20 @@ SyncService::DisableReasonSet ProfileSyncService::GetDisableReasons() const {
if (!user_settings_->IsSyncAllowedByPlatform()) { if (!user_settings_->IsSyncAllowedByPlatform()) {
result.Put(DISABLE_REASON_PLATFORM_OVERRIDE); result.Put(DISABLE_REASON_PLATFORM_OVERRIDE);
} }
if (sync_prefs_.IsManaged() || sync_disabled_by_admin_) {
result.Put(DISABLE_REASON_ENTERPRISE_POLICY); // If local sync is enabled, most disable reasons don't apply.
} if (!IsLocalSyncEnabled()) {
// Local sync doesn't require sign-in. if (sync_prefs_.IsManaged() || sync_disabled_by_admin_) {
if (!IsSignedIn() && !IsLocalSyncEnabled()) { result.Put(DISABLE_REASON_ENTERPRISE_POLICY);
result.Put(DISABLE_REASON_NOT_SIGNED_IN); }
} if (!IsSignedIn()) {
// When local sync is on sync should be considered requsted or otherwise it result.Put(DISABLE_REASON_NOT_SIGNED_IN);
// will not resume after the policy or the flag has been removed. }
if (!user_settings_->IsSyncRequested() && !IsLocalSyncEnabled()) { if (!user_settings_->IsSyncRequested()) {
result.Put(DISABLE_REASON_USER_CHOICE); result.Put(DISABLE_REASON_USER_CHOICE);
}
} }
if (unrecoverable_error_reason_) { if (unrecoverable_error_reason_) {
result.Put(DISABLE_REASON_UNRECOVERABLE_ERROR); result.Put(DISABLE_REASON_UNRECOVERABLE_ERROR);
} }
...@@ -1495,6 +1497,13 @@ void ProfileSyncService::GetEntityCountsForDebugging( ...@@ -1495,6 +1497,13 @@ void ProfileSyncService::GetEntityCountsForDebugging(
void ProfileSyncService::OnSyncManagedPrefChange(bool is_sync_managed) { void ProfileSyncService::OnSyncManagedPrefChange(bool is_sync_managed) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// Local sync is not controlled by the "sync managed" policy, so these pref
// changes make no difference to the service state.
if (IsLocalSyncEnabled()) {
return;
}
if (is_sync_managed) { if (is_sync_managed) {
StopImpl(CLEAR_DATA); StopImpl(CLEAR_DATA);
} else { } else {
......
...@@ -1281,8 +1281,8 @@ TEST_F(ProfileSyncServiceTest, DisableSyncOnClient) { ...@@ -1281,8 +1281,8 @@ TEST_F(ProfileSyncServiceTest, DisableSyncOnClient) {
EXPECT_FALSE(service()->IsSyncFeatureActive()); EXPECT_FALSE(service()->IsSyncFeatureActive());
} }
// Verify a that local sync mode resumes after the policy is lifted. // Verify a that local sync mode isn't impacted by sync being disabled.
TEST_F(ProfileSyncServiceTest, LocalBackendDisabledByPolicy) { TEST_F(ProfileSyncServiceTest, LocalBackendUnimpactedByPolicy) {
prefs()->SetManagedPref(prefs::kSyncManaged, prefs()->SetManagedPref(prefs::kSyncManaged,
std::make_unique<base::Value>(false)); std::make_unique<base::Value>(false));
CreateServiceWithLocalSyncBackend(); CreateServiceWithLocalSyncBackend();
...@@ -1294,10 +1294,8 @@ TEST_F(ProfileSyncServiceTest, LocalBackendDisabledByPolicy) { ...@@ -1294,10 +1294,8 @@ TEST_F(ProfileSyncServiceTest, LocalBackendDisabledByPolicy) {
prefs()->SetManagedPref(prefs::kSyncManaged, prefs()->SetManagedPref(prefs::kSyncManaged,
std::make_unique<base::Value>(true)); std::make_unique<base::Value>(true));
EXPECT_EQ(SyncService::DisableReasonSet( EXPECT_EQ(SyncService::DisableReasonSet(), service()->GetDisableReasons());
SyncService::DISABLE_REASON_ENTERPRISE_POLICY), EXPECT_EQ(SyncService::TransportState::ACTIVE,
service()->GetDisableReasons());
EXPECT_EQ(SyncService::TransportState::DISABLED,
service()->GetTransportState()); service()->GetTransportState());
// Note: If standalone transport is enabled, then setting kSyncManaged to // Note: If standalone transport is enabled, then setting kSyncManaged to
......
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