Commit 5115f824 authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Update StartupBrowserCreator to support ephemeral Guest profiles.

Startup browser creator is updated to support ephemeral Guest profiles.
Ephemeral Guest profiles are not off-the-record and will deprecate OTR
Guest profiles.

This change is behind disabled EnableEphemeralGuestProfilesOnDesktop
flag. Please see go/guest-on-disk for more context.

Bug: 1125474
Change-Id: I7af1cbf8e799e7387a6a96ca018bc772009d1205
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2449335
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarTommy Martino <tmartino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815166}
parent e6ea2b47
...@@ -265,6 +265,9 @@ bool CanOpenProfileOnStartup(Profile* profile) { ...@@ -265,6 +265,9 @@ bool CanOpenProfileOnStartup(Profile* profile) {
// Guest or system profiles are not available unless a separate process // Guest or system profiles are not available unless a separate process
// already has a window open for the profile. // already has a window open for the profile.
if (profile->IsEphemeralGuestProfile())
return chrome::GetBrowserCount(profile->GetOriginalProfile()) > 0;
return (!profile->IsGuestSession() && !profile->IsSystemProfile()) || return (!profile->IsGuestSession() && !profile->IsSystemProfile()) ||
(chrome::GetBrowserCount(profile->GetPrimaryOTRProfile()) > 0); (chrome::GetBrowserCount(profile->GetPrimaryOTRProfile()) > 0);
#endif #endif
...@@ -415,9 +418,10 @@ bool StartupBrowserCreator::LaunchBrowser( ...@@ -415,9 +418,10 @@ bool StartupBrowserCreator::LaunchBrowser(
} }
if (IsGuestModeEnforced(command_line, /* show_warning= */ true)) { if (IsGuestModeEnforced(command_line, /* show_warning= */ true)) {
profile = g_browser_process->profile_manager() profile = g_browser_process->profile_manager()->GetProfile(
->GetProfile(ProfileManager::GetGuestProfilePath()) ProfileManager::GetGuestProfilePath());
->GetPrimaryOTRProfile(); if (!profile->IsEphemeralGuestProfile())
profile = profile->GetPrimaryOTRProfile();
} }
#if defined(OS_WIN) #if defined(OS_WIN)
...@@ -507,7 +511,7 @@ SessionStartupPref StartupBrowserCreator::GetSessionStartupPref( ...@@ -507,7 +511,7 @@ SessionStartupPref StartupBrowserCreator::GetSessionStartupPref(
} }
// A browser starting for a profile being unlocked should always restore. // A browser starting for a profile being unlocked should always restore.
if (!profile->IsGuestSession()) { if (!profile->IsGuestSession() && !profile->IsEphemeralGuestProfile()) {
ProfileAttributesEntry* entry = nullptr; ProfileAttributesEntry* entry = nullptr;
bool has_entry = bool has_entry =
g_browser_process->profile_manager() g_browser_process->profile_manager()
...@@ -921,7 +925,7 @@ bool StartupBrowserCreator::ProcessLastOpenedProfiles( ...@@ -921,7 +925,7 @@ bool StartupBrowserCreator::ProcessLastOpenedProfiles(
// Launch the profiles in the order they became active. // Launch the profiles in the order they became active.
for (Profile* profile : last_opened_profiles) { for (Profile* profile : last_opened_profiles) {
DCHECK(!profile->IsGuestSession()); DCHECK(!profile->IsGuestSession() && !profile->IsEphemeralGuestProfile());
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
// Skip any locked profile. // Skip any locked profile.
...@@ -933,8 +937,10 @@ bool StartupBrowserCreator::ProcessLastOpenedProfiles( ...@@ -933,8 +937,10 @@ bool StartupBrowserCreator::ProcessLastOpenedProfiles(
// when Chrome was closed. In this case, pick a different open profile // when Chrome was closed. In this case, pick a different open profile
// to be the active one, since the Guest profile is never added to the // to be the active one, since the Guest profile is never added to the
// list of open profiles. // list of open profiles.
if (last_used_profile->IsGuestSession()) if (last_used_profile->IsGuestSession() ||
last_used_profile->IsEphemeralGuestProfile()) {
last_used_profile = profile; last_used_profile = profile;
}
#endif #endif
// Don't launch additional profiles which would only open a new tab // Don't launch additional profiles which would only open a new tab
......
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