Commit ee3e7323 authored by Ramin Halavati's avatar Ramin Halavati Committed by Chromium LUCI CQ

Disable Sync for ephemeral Guest profiles.

This change has no effect until EnableEphemeralGuestProfilesOnDesktop
flag is enabled.

Please see go/ephemeral-guest-profiles for more context.

Bug: 1125474
Change-Id: I23caee7e825153faf7b6e3f8d11ce3f8b3640898
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2469566
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836088}
parent a6a844ee
...@@ -122,6 +122,15 @@ ProfileSyncServiceFactory::GetAsProfileSyncServiceForProfile(Profile* profile) { ...@@ -122,6 +122,15 @@ ProfileSyncServiceFactory::GetAsProfileSyncServiceForProfile(Profile* profile) {
return static_cast<syncer::ProfileSyncService*>(GetForProfile(profile)); return static_cast<syncer::ProfileSyncService*>(GetForProfile(profile));
} }
content::BrowserContext* ProfileSyncServiceFactory::GetBrowserContextToUse(
content::BrowserContext* context) const {
if (context->IsOffTheRecord())
return nullptr;
if (Profile::FromBrowserContext(context)->IsEphemeralGuestProfile())
return nullptr;
return context;
}
ProfileSyncServiceFactory::ProfileSyncServiceFactory() ProfileSyncServiceFactory::ProfileSyncServiceFactory()
: BrowserContextKeyedServiceFactory( : BrowserContextKeyedServiceFactory(
"ProfileSyncService", "ProfileSyncService",
...@@ -286,6 +295,7 @@ bool ProfileSyncServiceFactory::HasSyncService(Profile* profile) { ...@@ -286,6 +295,7 @@ bool ProfileSyncServiceFactory::HasSyncService(Profile* profile) {
// static // static
bool ProfileSyncServiceFactory::IsSyncAllowed(Profile* profile) { bool ProfileSyncServiceFactory::IsSyncAllowed(Profile* profile) {
DCHECK(profile); DCHECK(profile);
if (HasSyncService(profile)) { if (HasSyncService(profile)) {
syncer::SyncService* sync_service = GetForProfile(profile); syncer::SyncService* sync_service = GetForProfile(profile);
return !sync_service->HasDisableReason( return !sync_service->HasDisableReason(
......
...@@ -67,6 +67,8 @@ class ProfileSyncServiceFactory : public BrowserContextKeyedServiceFactory { ...@@ -67,6 +67,8 @@ class ProfileSyncServiceFactory : public BrowserContextKeyedServiceFactory {
// BrowserContextKeyedServiceFactory: // BrowserContextKeyedServiceFactory:
KeyedService* BuildServiceInstanceFor( KeyedService* BuildServiceInstanceFor(
content::BrowserContext* context) const override; content::BrowserContext* context) const override;
content::BrowserContext* GetBrowserContextToUse(
content::BrowserContext* context) const override;
// A factory function for overriding the way the SyncClient is created. // A factory function for overriding the way the SyncClient is created.
// This is a raw pointer so it can be statically initialized. // This is a raw pointer so it can be statically initialized.
......
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