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