Skip to content

Commit

Permalink
Add kWebKioskSession into mojom::SessionType
Browse files Browse the repository at this point in the history
Support kWebKioskSession type when the LacrosService sets a Kiosk
profile as the main profile.

Bug: 1232794
Change-Id: Ib41d7d0ade8e76de148ed9e7c3a1bca01b718057
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3052590
Reviewed-by: Mihai Sardarescu <msarda@chromium.org>
Reviewed-by: Erik Chen <erikchen@chromium.org>
Commit-Queue: Anqing Zhao <anqing@chromium.org>
Cr-Commit-Position: refs/heads/master@{#907371}
  • Loading branch information
ananubis authored and Chromium LUCI CQ committed Jul 31, 2021
1 parent 5a9e108 commit 869f3ab
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
3 changes: 3 additions & 0 deletions chrome/browser/ash/crosapi/environment_provider.cc
Expand Up @@ -36,6 +36,9 @@ mojom::SessionType EnvironmentProvider::GetSessionType() {
if (profiles::IsPublicSession()) {
return mojom::SessionType::kPublicSession;
}
if (user->GetType() == user_manager::USER_TYPE_WEB_KIOSK_APP) {
return mojom::SessionType::kWebKioskSession;
}
return mojom::SessionType::kRegularSession;
}

Expand Down
35 changes: 35 additions & 0 deletions chrome/browser/profiles/profile_browsertest.cc
Expand Up @@ -1067,6 +1067,39 @@ IN_PROC_BROWSER_TEST_F(ProfileBrowserTest,
chromeos::LacrosService::Get()->SetInitParamsForTests(
std::move(init_params));

EXPECT_EQ(chromeos::LacrosService::Get()->init_params()->session_type,
crosapi::mojom::SessionType::kPublicSession);
EXPECT_TRUE(profile->IsMainProfile());

// Creating a profile causes an implicit connection attempt to a Mojo
// service, which occurs as part of a new task. Before deleting |profile|,
// ensure this task runs to prevent a crash.
FlushIoTaskRunnerAndSpinThreads();
}
FlushIoTaskRunnerAndSpinThreads();
}

IN_PROC_BROWSER_TEST_F(ProfileBrowserTest,
IsMainProfileReturnsTrueForWebKioskSession) {
base::ScopedAllowBlockingForTesting allow_blocking;
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());

{
base::FilePath profile_path =
temp_dir.GetPath().Append(chrome::kInitialProfile);
std::unique_ptr<Profile> profile(
CreateProfile(profile_path, /* delegate= */ nullptr,
Profile::CREATE_MODE_SYNCHRONOUS));

crosapi::mojom::BrowserInitParamsPtr init_params =
crosapi::mojom::BrowserInitParams::New();
init_params->session_type = crosapi::mojom::SessionType::kWebKioskSession;
chromeos::LacrosService::Get()->SetInitParamsForTests(
std::move(init_params));

EXPECT_EQ(chromeos::LacrosService::Get()->init_params()->session_type,
crosapi::mojom::SessionType::kWebKioskSession);
EXPECT_TRUE(profile->IsMainProfile());

// Creating a profile causes an implicit connection attempt to a Mojo
Expand Down Expand Up @@ -1099,6 +1132,8 @@ IN_PROC_BROWSER_TEST_F(
chromeos::LacrosService::Get()->SetInitParamsForTests(
std::move(init_params));

EXPECT_EQ(chromeos::LacrosService::Get()->init_params()->session_type,
crosapi::mojom::SessionType::kRegularSession);
EXPECT_TRUE(profile->IsMainProfile());

// Creating a profile causes an implicit connection attempt to a Mojo
Expand Down
7 changes: 4 additions & 3 deletions chromeos/crosapi/mojom/crosapi.mojom
Expand Up @@ -67,8 +67,8 @@ struct BrowserInfo {
// please note the milestone when you added it, to help us reason about
// compatibility between the client applications and older ash-chrome binaries.
//
// Next version: 40
// Next method id: 45
// Next version: 41
// Next method id: 46
[Stable, Uuid="8b79c34f-2bf8-4499-979a-b17cac522c1e",
RenamedFrom="crosapi.mojom.AshChromeService"]
interface Crosapi {
Expand Down Expand Up @@ -300,7 +300,8 @@ enum SessionType {
kUnknown,
kRegularSession,
kGuestSession,
kPublicSession
kPublicSession,
[MinVersion=40] kWebKioskSession,
};

// Device mode (e.g. enterprise enrollment state). See policy::DeviceMode.
Expand Down

0 comments on commit 869f3ab

Please sign in to comment.