Commit 9d462351 authored by Henrique Ferreiro's avatar Henrique Ferreiro Committed by Chromium LUCI CQ

Make KioskAppManager::ConsumerKioskAutoLaunchStatus an enum class

This CL is part of the Chrome OS source code directory migration:
https://docs.google.com/document/d/1g-98HpzA8XcoGBWUv1gQNr4rbnD5yfvbtYZyPDDbkaE.

Bug: 1101837, 1164001
Change-Id: I9354ead3b5188c3fe2f0cde3911672f68d8e84df
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2640534
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Owners-Override: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#846005}
parent 563c078e
......@@ -324,7 +324,7 @@ void KioskAppManager::GetConsumerKioskAutoLaunchStatus(
KioskAppManager::GetConsumerKioskAutoLaunchStatusCallback callback) {
if (!IsConsumerKioskEnabled()) {
if (callback)
std::move(callback).Run(CONSUMER_KIOSK_AUTO_LAUNCH_DISABLED);
std::move(callback).Run(ConsumerKioskAutoLaunchStatus::kDisabled);
return;
}
......@@ -363,9 +363,9 @@ void KioskAppManager::OnOwnerFileChecked(
// If we have owner already established on the machine, don't let
// consumer kiosk to be enabled.
if (ownership_established_)
std::move(callback).Run(CONSUMER_KIOSK_AUTO_LAUNCH_DISABLED);
std::move(callback).Run(ConsumerKioskAutoLaunchStatus::kDisabled);
else
std::move(callback).Run(CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE);
std::move(callback).Run(ConsumerKioskAutoLaunchStatus::kConfigurable);
}
void KioskAppManager::OnReadImmutableAttributes(
......@@ -374,14 +374,14 @@ void KioskAppManager::OnReadImmutableAttributes(
return;
ConsumerKioskAutoLaunchStatus status =
CONSUMER_KIOSK_AUTO_LAUNCH_DISABLED;
ConsumerKioskAutoLaunchStatus::kDisabled;
policy::BrowserPolicyConnectorChromeOS* connector =
g_browser_process->platform_part()->browser_policy_connector_chromeos();
InstallAttributes* attributes = connector->GetInstallAttributes();
switch (attributes->GetMode()) {
case policy::DEVICE_MODE_NOT_SET: {
if (!base::SysInfo::IsRunningOnChromeOS()) {
status = CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE;
status = ConsumerKioskAutoLaunchStatus::kConfigurable;
} else if (!ownership_established_) {
bool* owner_present = new bool(false);
base::ThreadPool::PostTaskAndReply(
......@@ -395,7 +395,7 @@ void KioskAppManager::OnReadImmutableAttributes(
break;
}
case policy::DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH:
status = CONSUMER_KIOSK_AUTO_LAUNCH_ENABLED;
status = ConsumerKioskAutoLaunchStatus::kEnabled;
break;
default:
break;
......
......@@ -46,14 +46,14 @@ class OwnerSettingsServiceChromeOS;
class KioskAppManager : public KioskAppManagerBase,
public ExternalCacheDelegate {
public:
enum ConsumerKioskAutoLaunchStatus {
enum class ConsumerKioskAutoLaunchStatus {
// Consumer kiosk mode auto-launch feature can be enabled on this machine.
CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE,
kConfigurable,
// Consumer kiosk auto-launch feature is enabled on this machine.
CONSUMER_KIOSK_AUTO_LAUNCH_ENABLED,
kEnabled,
// Consumer kiosk mode auto-launch feature is disabled and cannot any longer
// be enabled on this machine.
CONSUMER_KIOSK_AUTO_LAUNCH_DISABLED,
kDisabled,
};
using EnableKioskAutoLaunchCallback = base::OnceCallback<void(bool success)>;
......
......@@ -73,7 +73,8 @@ void ConsumerKioskAutoLaunchStatusCheck(
KioskAppManager::ConsumerKioskAutoLaunchStatus* out_status,
base::OnceClosure runner_quit_task,
KioskAppManager::ConsumerKioskAutoLaunchStatus in_status) {
LOG(INFO) << "ConsumerKioskAutoLaunchStatus = " << in_status;
LOG(INFO) << "ConsumerKioskAutoLaunchStatus = "
<< static_cast<int>(in_status);
*out_status = in_status;
std::move(runner_quit_task).Run();
}
......@@ -901,14 +902,15 @@ IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, EnableConsumerKiosk) {
switches::kEnableConsumerKiosk);
KioskAppManager::ConsumerKioskAutoLaunchStatus status =
KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_DISABLED;
KioskAppManager::ConsumerKioskAutoLaunchStatus::kDisabled;
bool locked = false;
base::RunLoop run_loop;
manager()->GetConsumerKioskAutoLaunchStatus(base::BindOnce(
&ConsumerKioskAutoLaunchStatusCheck, &status, run_loop.QuitClosure()));
run_loop.Run();
EXPECT_EQ(status, KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE);
EXPECT_EQ(status,
KioskAppManager::ConsumerKioskAutoLaunchStatus::kConfigurable);
base::RunLoop run_loop2;
manager()->EnableConsumerKioskAutoLaunch(base::BindOnce(
......@@ -920,18 +922,18 @@ IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, EnableConsumerKiosk) {
manager()->GetConsumerKioskAutoLaunchStatus(base::BindOnce(
&ConsumerKioskAutoLaunchStatusCheck, &status, run_loop3.QuitClosure()));
run_loop3.Run();
EXPECT_EQ(status, KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_ENABLED);
EXPECT_EQ(status, KioskAppManager::ConsumerKioskAutoLaunchStatus::kEnabled);
}
IN_PROC_BROWSER_TEST_F(KioskAppManagerTest, ConsumerKioskDisabled) {
KioskAppManager::ConsumerKioskAutoLaunchStatus status =
KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE;
KioskAppManager::ConsumerKioskAutoLaunchStatus::kConfigurable;
base::RunLoop run_loop;
manager()->GetConsumerKioskAutoLaunchStatus(base::BindOnce(
&ConsumerKioskAutoLaunchStatusCheck, &status, run_loop.QuitClosure()));
run_loop.Run();
EXPECT_EQ(status, KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_DISABLED);
EXPECT_EQ(status, KioskAppManager::ConsumerKioskAutoLaunchStatus::kDisabled);
}
IN_PROC_BROWSER_TEST_F(KioskAppManagerTest,
......@@ -944,14 +946,14 @@ IN_PROC_BROWSER_TEST_F(KioskAppManagerTest,
EXPECT_EQ(LockDeviceForEnterprise(), InstallAttributes::LOCK_SUCCESS);
KioskAppManager::ConsumerKioskAutoLaunchStatus status =
KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_DISABLED;
KioskAppManager::ConsumerKioskAutoLaunchStatus::kDisabled;
bool locked = true;
base::RunLoop run_loop;
manager()->GetConsumerKioskAutoLaunchStatus(base::BindOnce(
&ConsumerKioskAutoLaunchStatusCheck, &status, run_loop.QuitClosure()));
run_loop.Run();
EXPECT_EQ(status, KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_DISABLED);
EXPECT_EQ(status, KioskAppManager::ConsumerKioskAutoLaunchStatus::kDisabled);
base::RunLoop run_loop2;
manager()->EnableConsumerKioskAutoLaunch(base::BindOnce(
......@@ -963,7 +965,7 @@ IN_PROC_BROWSER_TEST_F(KioskAppManagerTest,
manager()->GetConsumerKioskAutoLaunchStatus(base::BindOnce(
&ConsumerKioskAutoLaunchStatusCheck, &status, run_loop3.QuitClosure()));
run_loop3.Run();
EXPECT_EQ(status, KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_DISABLED);
EXPECT_EQ(status, KioskAppManager::ConsumerKioskAutoLaunchStatus::kDisabled);
}
IN_PROC_BROWSER_TEST_F(KioskAppManagerTest,
......
......@@ -257,7 +257,8 @@ void ConsumerKioskAutoLaunchStatusCheck(
KioskAppManager::ConsumerKioskAutoLaunchStatus* out_status,
base::OnceClosure runner_quit_task,
KioskAppManager::ConsumerKioskAutoLaunchStatus in_status) {
LOG(INFO) << "KioskAppManager::ConsumerKioskModeStatus = " << in_status;
LOG(INFO) << "KioskAppManager::ConsumerKioskModeStatus = "
<< static_cast<int>(in_status);
*out_status = in_status;
std::move(runner_quit_task).Run();
}
......@@ -1191,7 +1192,7 @@ IN_PROC_BROWSER_TEST_F(KioskTest, KioskEnableCancel) {
ASSERT_TRUE(wizard_controller);
// Check Kiosk mode status.
EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE,
EXPECT_EQ(KioskAppManager::ConsumerKioskAutoLaunchStatus::kConfigurable,
GetConsumerKioskModeStatus());
// Wait for the login UI to come up and switch to the kiosk_enable screen.
......@@ -1208,7 +1209,7 @@ IN_PROC_BROWSER_TEST_F(KioskTest, KioskEnableCancel) {
OobeScreenWaiter(GetFirstSigninScreen()).Wait();
// Check that the status still says configurable.
EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE,
EXPECT_EQ(KioskAppManager::ConsumerKioskAutoLaunchStatus::kConfigurable,
GetConsumerKioskModeStatus());
}
......@@ -1220,7 +1221,7 @@ IN_PROC_BROWSER_TEST_F(KioskTest, KioskEnableConfirmed) {
ASSERT_TRUE(wizard_controller);
// Check Kiosk mode status.
EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE,
EXPECT_EQ(KioskAppManager::ConsumerKioskAutoLaunchStatus::kConfigurable,
GetConsumerKioskModeStatus());
// Wait for the login UI to come up and switch to the kiosk_enable screen.
......@@ -1239,7 +1240,7 @@ IN_PROC_BROWSER_TEST_F(KioskTest, KioskEnableConfirmed) {
".state_ == 'success'")
->Wait();
EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_ENABLED,
EXPECT_EQ(KioskAppManager::ConsumerKioskAutoLaunchStatus::kEnabled,
GetConsumerKioskModeStatus());
}
......@@ -1250,7 +1251,7 @@ IN_PROC_BROWSER_TEST_F(KioskTest, KioskEnableAfter2ndSigninScreen) {
ASSERT_TRUE(wizard_controller);
// Check Kiosk mode status.
EXPECT_EQ(KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE,
EXPECT_EQ(KioskAppManager::ConsumerKioskAutoLaunchStatus::kConfigurable,
GetConsumerKioskModeStatus());
// Wait for the login UI to come up and switch to the kiosk_enable screen.
......
......@@ -824,7 +824,7 @@ void ExistingUserController::LocalStateChanged(
void ExistingUserController::OnConsumerKioskAutoLaunchCheckCompleted(
KioskAppManager::ConsumerKioskAutoLaunchStatus status) {
if (status == KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE)
if (status == KioskAppManager::ConsumerKioskAutoLaunchStatus::kConfigurable)
ShowKioskEnableScreen();
}
......
......@@ -49,7 +49,7 @@ void KioskEnableScreen::ShowImpl() {
void KioskEnableScreen::OnGetConsumerKioskAutoLaunchStatus(
KioskAppManager::ConsumerKioskAutoLaunchStatus status) {
is_configurable_ =
(status == KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_CONFIGURABLE);
(status == KioskAppManager::ConsumerKioskAutoLaunchStatus::kConfigurable);
if (!is_configurable_) {
LOG(WARNING) << "Consumer kiosk auto launch feature is not configurable!";
HandleClose();
......
......@@ -187,7 +187,7 @@ void KioskAppsHandler::OnGetConsumerKioskAutoLaunchStatus(
is_kiosk_enabled_ =
ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui()));
is_auto_launch_enabled_ =
status == KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_ENABLED;
status == KioskAppManager::ConsumerKioskAutoLaunchStatus::kEnabled;
}
} else {
// Otherwise, consumer kiosk is disabled.
......
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