Commit 8ec52a04 authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Update OTR profile calls in Startup browser creator and tab provider.

Profile API is being updated (issue 1033903) and the usage of
GetOffTheRecordProfile without argument is getting deprecated. Use cases
of this call that only refer to incognito or guest mode can use
GetPrimaryOTRProfile() instead.

All calls to this function in StartupBrowserCreator and
StartupTabProvider test are updated.
This CL does not make any behavioral changes.

Bug: 1060940
Change-Id: I15ae29ced658772423994bf5429eeb483b13593a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2131327Reviewed-by: default avatarTommy Martino <tmartino@chromium.org>
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759542}
parent 6d769734
......@@ -259,7 +259,7 @@ bool CanOpenProfileOnStartup(Profile* profile) {
// Guest or system profiles are not available unless a separate process
// already has a window open for the profile.
return (!profile->IsGuestSession() && !profile->IsSystemProfile()) ||
(chrome::GetBrowserCount(profile->GetOffTheRecordProfile()) > 0);
(chrome::GetBrowserCount(profile->GetPrimaryOTRProfile()) > 0);
#endif
}
......@@ -361,7 +361,7 @@ bool StartupBrowserCreator::LaunchBrowser(
// is forced.
if (IncognitoModePrefs::ShouldLaunchIncognito(command_line,
profile->GetPrefs())) {
profile = profile->GetOffTheRecordProfile();
profile = profile->GetPrimaryOTRProfile();
} else if (command_line.HasSwitch(switches::kIncognito)) {
LOG(WARNING) << "Incognito mode disabled by policy, launching a normal "
<< "browser session.";
......@@ -370,13 +370,13 @@ bool StartupBrowserCreator::LaunchBrowser(
if (IsGuestModeEnforced(command_line, /* show_warning= */ true)) {
profile = g_browser_process->profile_manager()
->GetProfile(ProfileManager::GetGuestProfilePath())
->GetOffTheRecordProfile();
->GetPrimaryOTRProfile();
}
#if defined(OS_WIN)
// Continue with the incognito profile if this is a credential provider logon.
if (command_line.HasSwitch(credential_provider::kGcpwSigninSwitch))
profile = profile->GetOffTheRecordProfile();
profile = profile->GetPrimaryOTRProfile();
#endif
if (!IsSilentLaunchEnabled(command_line, profile)) {
......@@ -828,10 +828,9 @@ bool StartupBrowserCreator::LaunchBrowserForLastProfiles(
// - All of the last opened profiles fail to initialize.
if (last_opened_profiles.empty() || was_windows_notification_launch) {
if (CanOpenProfileOnStartup(last_used_profile)) {
Profile* profile_to_open =
last_used_profile->IsGuestSession()
? last_used_profile->GetOffTheRecordProfile()
: last_used_profile;
Profile* profile_to_open = last_used_profile->IsGuestSession()
? last_used_profile->GetPrimaryOTRProfile()
: last_used_profile;
return LaunchBrowser(command_line, profile_to_open, cur_dir,
is_process_startup, is_first_run);
......
......@@ -241,7 +241,7 @@ TEST(StartupTabProviderTest, GetNewTabPageTabsForState_Negative) {
TEST(StartupTabProviderTest, IncognitoProfile) {
content::BrowserTaskEnvironment task_environment;
TestingProfile profile;
Profile* incognito = profile.GetOffTheRecordProfile();
Profile* incognito = profile.GetPrimaryOTRProfile();
StartupTabs output = StartupTabProviderImpl().GetOnboardingTabs(incognito);
EXPECT_TRUE(output.empty());
}
......
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