Commit 4637005b authored by Henrique Ferreiro's avatar Henrique Ferreiro Committed by Chromium LUCI CQ

Make KioskAppLaunchError::Error 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: I9f547f785679fcc03dde65f60b090b28c250f95a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2640253Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Owners-Override: James Cook <jamescook@chromium.org>
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
Cr-Commit-Position: refs/heads/master@{#845554}
parent 9d3c4a91
......@@ -23,55 +23,56 @@ constexpr char kKeyLaunchError[] = "launch_error";
constexpr char kKeyCryptohomeFailure[] = "cryptohome_failure";
// Error from the last kiosk launch.
KioskAppLaunchError::Error s_last_error = KioskAppLaunchError::ERROR_COUNT;
KioskAppLaunchError::Error s_last_error = KioskAppLaunchError::Error::kCount;
} // namespace
// static
std::string KioskAppLaunchError::GetErrorMessage(Error error) {
switch (error) {
case NONE:
case Error::kNone:
return std::string();
case HAS_PENDING_LAUNCH:
case NOT_KIOSK_ENABLED:
case UNABLE_TO_RETRIEVE_HASH:
case POLICY_LOAD_FAILED:
case ARC_AUTH_FAILED:
case Error::kHasPendingLaunch:
case Error::kNotKioskEnabled:
case Error::kUnableToRetrieveHash:
case Error::kPolicyLoadFailed:
case Error::kArcAuthFailed:
return l10n_util::GetStringUTF8(IDS_KIOSK_APP_FAILED_TO_LAUNCH);
case CRYPTOHOMED_NOT_RUNNING:
case ALREADY_MOUNTED:
case UNABLE_TO_MOUNT:
case UNABLE_TO_REMOVE:
case Error::kCryptohomedNotRunning:
case Error::kAlreadyMounted:
case Error::kUnableToMount:
case Error::kUnableToRemove:
return l10n_util::GetStringUTF8(IDS_KIOSK_APP_ERROR_UNABLE_TO_MOUNT);
case UNABLE_TO_INSTALL:
case Error::kUnableToInstall:
return l10n_util::GetStringUTF8(IDS_KIOSK_APP_ERROR_UNABLE_TO_INSTALL);
case USER_CANCEL:
case Error::kUserCancel:
return l10n_util::GetStringUTF8(IDS_KIOSK_APP_ERROR_USER_CANCEL);
case UNABLE_TO_DOWNLOAD:
case Error::kUnableToDownload:
return l10n_util::GetStringUTF8(IDS_KIOSK_APP_ERROR_UNABLE_TO_DOWNLOAD);
case UNABLE_TO_LAUNCH:
case Error::kUnableToLaunch:
return l10n_util::GetStringUTF8(IDS_KIOSK_APP_ERROR_UNABLE_TO_LAUNCH);
case EXTENSIONS_LOAD_TIMEOUT:
case Error::kExtensionsLoadTimeout:
return l10n_util::GetStringUTF8(
IDS_KIOSK_APP_ERROR_EXTENSIONS_LOAD_TIMEOUT);
case EXTENSIONS_POLICY_INVALID:
case Error::kExtensionsPolicyInvalid:
return l10n_util::GetStringUTF8(
IDS_KIOSK_APP_ERROR_EXTENSIONS_POLICY_INVALID);
case ERROR_COUNT:
case Error::kCount:
// Break onto the NOTREACHED() code path below.
break;
}
NOTREACHED() << "Unknown kiosk app launch error, error=" << error;
NOTREACHED() << "Unknown kiosk app launch error, error="
<< static_cast<int>(error);
return l10n_util::GetStringUTF8(IDS_KIOSK_APP_FAILED_TO_LAUNCH);
}
......@@ -80,7 +81,7 @@ void KioskAppLaunchError::Save(KioskAppLaunchError::Error error) {
PrefService* local_state = g_browser_process->local_state();
DictionaryPrefUpdate dict_update(local_state,
KioskAppManager::kKioskDictionaryName);
dict_update->SetInteger(kKeyLaunchError, error);
dict_update->SetInteger(kKeyLaunchError, static_cast<int>(error));
s_last_error = error;
}
......@@ -95,9 +96,9 @@ void KioskAppLaunchError::SaveCryptohomeFailure(
// static
KioskAppLaunchError::Error KioskAppLaunchError::Get() {
if (s_last_error != KioskAppLaunchError::ERROR_COUNT)
if (s_last_error != Error::kCount)
return s_last_error;
s_last_error = KioskAppLaunchError::NONE;
s_last_error = Error::kNone;
PrefService* local_state = g_browser_process->local_state();
const base::DictionaryValue* dict =
local_state->GetDictionary(KioskAppManager::kKioskDictionaryName);
......@@ -108,7 +109,7 @@ KioskAppLaunchError::Error KioskAppLaunchError::Get() {
return s_last_error;
}
return KioskAppLaunchError::NONE;
return Error::kNone;
}
// static
......@@ -120,7 +121,7 @@ void KioskAppLaunchError::RecordMetricAndClear() {
int error;
if (dict_update->GetInteger(kKeyLaunchError, &error))
UMA_HISTOGRAM_ENUMERATION("Kiosk.Launch.Error", static_cast<Error>(error),
ERROR_COUNT);
Error::kCount);
dict_update->Remove(kKeyLaunchError, NULL);
int cryptohome_failure;
......
......@@ -17,26 +17,26 @@ class KioskAppLaunchError {
public:
// Enum used for UMA. Do NOT reorder or remove entry. Don't forget to
// update histograms.xml when adding new entries.
enum Error {
NONE = 0, // No error.
HAS_PENDING_LAUNCH = 1, // There is a pending launch already.
CRYPTOHOMED_NOT_RUNNING = 2, // Unable to call cryptohome daemon.
ALREADY_MOUNTED = 3, // Cryptohome is already mounted.
UNABLE_TO_MOUNT = 4, // Unable to mount cryptohome.
UNABLE_TO_REMOVE = 5, // Unable to remove cryptohome.
UNABLE_TO_INSTALL = 6, // Unable to install app.
USER_CANCEL = 7, // Canceled by user.
NOT_KIOSK_ENABLED = 8, // Not a kiosk enabled app.
UNABLE_TO_RETRIEVE_HASH = 9, // Unable to retrieve username hash.
POLICY_LOAD_FAILED = 10, // Failed to load policy for kiosk account.
UNABLE_TO_DOWNLOAD = 11, // Unable to download app's crx file.
UNABLE_TO_LAUNCH = 12, // Unable to launch app.
ARC_AUTH_FAILED = 13, // Failed to authorise ARC session
EXTENSIONS_LOAD_TIMEOUT = 14, // Timeout is triggered during loading
// force-installed extensions.
EXTENSIONS_POLICY_INVALID =
15, // The policy value of ExtensionInstallForcelist is invalid.
ERROR_COUNT, // Count of all errors.
enum class Error {
kNone = 0, // No error.
kHasPendingLaunch = 1, // There is a pending launch already.
kCryptohomedNotRunning = 2, // Unable to call cryptohome daemon.
kAlreadyMounted = 3, // Cryptohome is already mounted.
kUnableToMount = 4, // Unable to mount cryptohome.
kUnableToRemove = 5, // Unable to remove cryptohome.
kUnableToInstall = 6, // Unable to install app.
kUserCancel = 7, // Canceled by user.
kNotKioskEnabled = 8, // Not a kiosk enabled app.
kUnableToRetrieveHash = 9, // Unable to retrieve username hash.
kPolicyLoadFailed = 10, // Failed to load policy for kiosk account.
kUnableToDownload = 11, // Unable to download app's crx file.
kUnableToLaunch = 12, // Unable to launch app.
kArcAuthFailed = 13, // Failed to authorise ARC session
kExtensionsLoadTimeout = 14, // Timeout is triggered during loading
// force-installed extensions.
kExtensionsPolicyInvalid =
15, // The policy value of ExtensionInstallForcelist is invalid.
kCount, // Count of all errors.
};
// Returns a message for given |error|.
......
......@@ -51,55 +51,65 @@ class KioskAppLaunchErrorTest : public testing::Test {
TEST_F(KioskAppLaunchErrorTest, GetErrorMessage) {
std::string expected_message;
VerifyErrorMessage(KioskAppLaunchError::NONE, expected_message);
VerifyErrorMessage(KioskAppLaunchError::Error::kNone, expected_message);
expected_message = l10n_util::GetStringUTF8(IDS_KIOSK_APP_FAILED_TO_LAUNCH);
VerifyErrorMessage(KioskAppLaunchError::HAS_PENDING_LAUNCH, expected_message);
VerifyErrorMessage(KioskAppLaunchError::NOT_KIOSK_ENABLED, expected_message);
VerifyErrorMessage(KioskAppLaunchError::UNABLE_TO_RETRIEVE_HASH,
VerifyErrorMessage(KioskAppLaunchError::Error::kHasPendingLaunch,
expected_message);
VerifyErrorMessage(KioskAppLaunchError::Error::kNotKioskEnabled,
expected_message);
VerifyErrorMessage(KioskAppLaunchError::Error::kUnableToRetrieveHash,
expected_message);
VerifyErrorMessage(KioskAppLaunchError::Error::kPolicyLoadFailed,
expected_message);
VerifyErrorMessage(KioskAppLaunchError::Error::kArcAuthFailed,
expected_message);
VerifyErrorMessage(KioskAppLaunchError::POLICY_LOAD_FAILED, expected_message);
VerifyErrorMessage(KioskAppLaunchError::ARC_AUTH_FAILED, expected_message);
expected_message =
l10n_util::GetStringUTF8(IDS_KIOSK_APP_ERROR_UNABLE_TO_MOUNT);
VerifyErrorMessage(KioskAppLaunchError::CRYPTOHOMED_NOT_RUNNING,
VerifyErrorMessage(KioskAppLaunchError::Error::kCryptohomedNotRunning,
expected_message);
VerifyErrorMessage(KioskAppLaunchError::Error::kAlreadyMounted,
expected_message);
VerifyErrorMessage(KioskAppLaunchError::Error::kUnableToMount,
expected_message);
VerifyErrorMessage(KioskAppLaunchError::Error::kUnableToRemove,
expected_message);
VerifyErrorMessage(KioskAppLaunchError::ALREADY_MOUNTED, expected_message);
VerifyErrorMessage(KioskAppLaunchError::UNABLE_TO_MOUNT, expected_message);
VerifyErrorMessage(KioskAppLaunchError::UNABLE_TO_REMOVE, expected_message);
expected_message =
l10n_util::GetStringUTF8(IDS_KIOSK_APP_ERROR_UNABLE_TO_INSTALL);
VerifyErrorMessage(KioskAppLaunchError::UNABLE_TO_INSTALL, expected_message);
VerifyErrorMessage(KioskAppLaunchError::Error::kUnableToInstall,
expected_message);
expected_message = l10n_util::GetStringUTF8(IDS_KIOSK_APP_ERROR_USER_CANCEL);
VerifyErrorMessage(KioskAppLaunchError::USER_CANCEL, expected_message);
VerifyErrorMessage(KioskAppLaunchError::Error::kUserCancel, expected_message);
expected_message =
l10n_util::GetStringUTF8(IDS_KIOSK_APP_ERROR_UNABLE_TO_DOWNLOAD);
VerifyErrorMessage(KioskAppLaunchError::UNABLE_TO_DOWNLOAD, expected_message);
VerifyErrorMessage(KioskAppLaunchError::Error::kUnableToDownload,
expected_message);
expected_message =
l10n_util::GetStringUTF8(IDS_KIOSK_APP_ERROR_UNABLE_TO_LAUNCH);
VerifyErrorMessage(KioskAppLaunchError::UNABLE_TO_LAUNCH, expected_message);
VerifyErrorMessage(KioskAppLaunchError::Error::kUnableToLaunch,
expected_message);
}
TEST_F(KioskAppLaunchErrorTest, SaveError) {
// No launch error is stored before it is saved.
EXPECT_FALSE(GetKioskDictionary()->HasKey(kKeyLaunchError));
KioskAppLaunchError::Save(KioskAppLaunchError::ERROR_COUNT);
KioskAppLaunchError::Save(KioskAppLaunchError::Error::kCount);
// The launch error can be retrieved.
int out_error;
EXPECT_TRUE(GetKioskDictionary()->GetInteger(kKeyLaunchError, &out_error));
EXPECT_EQ(out_error, KioskAppLaunchError::ERROR_COUNT);
EXPECT_EQ(KioskAppLaunchError::Get(), KioskAppLaunchError::ERROR_COUNT);
EXPECT_EQ(out_error, static_cast<int>(KioskAppLaunchError::Error::kCount));
EXPECT_EQ(KioskAppLaunchError::Get(), KioskAppLaunchError::Error::kCount);
// The launch error is cleaned up after clear operation.
KioskAppLaunchError::RecordMetricAndClear();
EXPECT_FALSE(GetKioskDictionary()->HasKey(kKeyLaunchError));
EXPECT_EQ(KioskAppLaunchError::Get(), KioskAppLaunchError::NONE);
EXPECT_EQ(KioskAppLaunchError::Get(), KioskAppLaunchError::Error::kNone);
}
TEST_F(KioskAppLaunchErrorTest, SaveCryptohomeFailure) {
......
......@@ -165,7 +165,8 @@ IN_PROC_BROWSER_TEST_F(ChromeKioskCrashRestoreTest, ChromeAppNotInstalled) {
// If app is not installed when restoring from crash, the kiosk launch is
// expected to fail, as in that case the crash occured during the app
// initialization - before the app was actually launched.
EXPECT_EQ(KioskAppLaunchError::UNABLE_TO_LAUNCH, KioskAppLaunchError::Get());
EXPECT_EQ(KioskAppLaunchError::Error::kUnableToLaunch,
KioskAppLaunchError::Get());
}
class WebKioskCrashRestoreTest : public KioskCrashRestoreTest {
......@@ -179,7 +180,7 @@ IN_PROC_BROWSER_TEST_F(WebKioskCrashRestoreTest, WebKioskLaunches) {
// If app is not installed when restoring from crash, the kiosk launch is
// expected to fail, as in that case the crash occured during the app
// initialization - before the app was actually launched.
EXPECT_EQ(KioskAppLaunchError::NONE, KioskAppLaunchError::Get());
EXPECT_EQ(KioskAppLaunchError::Error::kNone, KioskAppLaunchError::Get());
KioskSessionInitializedWaiter().Wait();
}
......
......@@ -42,14 +42,14 @@ KioskAppLaunchError::Error LoginFailureToKioskAppLaunchError(
switch (error.reason()) {
case AuthFailure::COULD_NOT_MOUNT_TMPFS:
case AuthFailure::COULD_NOT_MOUNT_CRYPTOHOME:
return KioskAppLaunchError::UNABLE_TO_MOUNT;
return KioskAppLaunchError::Error::kUnableToMount;
case AuthFailure::DATA_REMOVAL_FAILED:
return KioskAppLaunchError::UNABLE_TO_REMOVE;
return KioskAppLaunchError::Error::kUnableToRemove;
case AuthFailure::USERNAME_HASH_FAILED:
return KioskAppLaunchError::UNABLE_TO_RETRIEVE_HASH;
return KioskAppLaunchError::Error::kUnableToRetrieveHash;
default:
NOTREACHED();
return KioskAppLaunchError::UNABLE_TO_MOUNT;
return KioskAppLaunchError::Error::kUnableToMount;
}
}
......@@ -82,7 +82,7 @@ class KioskProfileLoader::CryptohomedChecker
++retry_count_;
if (retry_count_ > kMaxRetryTimes) {
SYSLOG(ERROR) << "Could not talk to cryptohomed for launching kiosk app.";
ReportCheckResult(KioskAppLaunchError::CRYPTOHOMED_NOT_RUNNING);
ReportCheckResult(KioskAppLaunchError::Error::kCryptohomedNotRunning);
return;
}
......@@ -110,15 +110,15 @@ class KioskProfileLoader::CryptohomedChecker
// Proceed only when cryptohome is not mounded or running on dev box.
if (!is_mounted.value() || !base::SysInfo::IsRunningOnChromeOS()) {
ReportCheckResult(KioskAppLaunchError::NONE);
ReportCheckResult(KioskAppLaunchError::Error::kNone);
} else {
SYSLOG(ERROR) << "Cryptohome is mounted before launching kiosk app.";
ReportCheckResult(KioskAppLaunchError::ALREADY_MOUNTED);
ReportCheckResult(KioskAppLaunchError::Error::kAlreadyMounted);
}
}
void ReportCheckResult(KioskAppLaunchError::Error error) {
if (error == KioskAppLaunchError::NONE)
if (error == KioskAppLaunchError::Error::kNone)
loader_->LoginAsKioskAccount();
else
loader_->ReportLaunchResult(error);
......@@ -174,7 +174,7 @@ void KioskProfileLoader::LoginAsKioskAccount() {
void KioskProfileLoader::ReportLaunchResult(KioskAppLaunchError::Error error) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (error != KioskAppLaunchError::NONE) {
if (error != KioskAppLaunchError::Error::kNone) {
delegate_->OnProfileLoadFailed(error);
}
}
......@@ -223,7 +223,7 @@ void KioskProfileLoader::AllowlistCheckFailed(const std::string& email) {
}
void KioskProfileLoader::PolicyLoadFailed() {
ReportLaunchResult(KioskAppLaunchError::POLICY_LOAD_FAILED);
ReportLaunchResult(KioskAppLaunchError::Error::kPolicyLoadFailed);
}
void KioskProfileLoader::OnOldEncryptionDetected(
......@@ -239,7 +239,7 @@ void KioskProfileLoader::OnProfilePrepared(Profile* profile,
UserSessionManager::GetInstance()->DelegateDeleted(this);
delegate_->OnProfileLoaded(profile);
ReportLaunchResult(KioskAppLaunchError::NONE);
ReportLaunchResult(KioskAppLaunchError::Error::kNone);
}
} // namespace chromeos
......@@ -192,7 +192,7 @@ void StartupAppLauncher::MaybeLaunchApp() {
// this means that the kiosk app might not yet be downloaded. If that is
// the case, bail out from the app launch.
if (!extension || !AreSecondaryAppsInstalled()) {
OnLaunchFailure(KioskAppLaunchError::UNABLE_TO_LAUNCH);
OnLaunchFailure(KioskAppLaunchError::Error::kUnableToLaunch);
return;
}
......@@ -219,7 +219,7 @@ void StartupAppLauncher::MaybeLaunchApp() {
weak_ptr_factory_.GetWeakPtr()));
return;
}
OnLaunchFailure(KioskAppLaunchError::UNABLE_TO_LAUNCH);
OnLaunchFailure(KioskAppLaunchError::Error::kUnableToLaunch);
}
}
......@@ -278,7 +278,7 @@ void StartupAppLauncher::OnFinishCrxInstall(const std::string& extension_id,
if (DidPrimaryOrSecondaryAppFailedToInstall(success, extension_id)) {
install_observer_.RemoveAll();
OnLaunchFailure(KioskAppLaunchError::UNABLE_TO_INSTALL);
OnLaunchFailure(KioskAppLaunchError::Error::kUnableToInstall);
return;
}
......@@ -298,12 +298,12 @@ void StartupAppLauncher::OnFinishCrxInstall(const std::string& extension_id,
const extensions::Extension* primary_app = GetPrimaryAppExtension();
if (!primary_app) {
OnLaunchFailure(KioskAppLaunchError::UNABLE_TO_INSTALL);
OnLaunchFailure(KioskAppLaunchError::Error::kUnableToInstall);
return;
}
if (!extensions::KioskModeInfo::IsKioskEnabled(primary_app)) {
OnLaunchFailure(KioskAppLaunchError::NOT_KIOSK_ENABLED);
OnLaunchFailure(KioskAppLaunchError::Error::kNotKioskEnabled);
return;
}
......@@ -334,7 +334,7 @@ void StartupAppLauncher::OnKioskAppDataLoadStatusChanged(
if (KioskAppManager::Get()->HasCachedCrx(app_id_))
BeginInstall();
else
OnLaunchFailure(KioskAppLaunchError::UNABLE_TO_DOWNLOAD);
OnLaunchFailure(KioskAppLaunchError::Error::kUnableToDownload);
}
bool StartupAppLauncher::IsAnySecondaryAppPending() const {
......@@ -420,7 +420,7 @@ void StartupAppLauncher::LaunchApp() {
CHECK(extension);
if (!extensions::KioskModeInfo::IsKioskEnabled(extension)) {
OnLaunchFailure(KioskAppLaunchError::NOT_KIOSK_ENABLED);
OnLaunchFailure(KioskAppLaunchError::Error::kNotKioskEnabled);
return;
}
......@@ -463,8 +463,8 @@ void StartupAppLauncher::OnAppWindowAdded(extensions::AppWindow* app_window) {
}
void StartupAppLauncher::OnLaunchFailure(KioskAppLaunchError::Error error) {
SYSLOG(ERROR) << "App launch failed, error: " << error;
DCHECK_NE(KioskAppLaunchError::NONE, error);
SYSLOG(ERROR) << "App launch failed, error: " << static_cast<int>(error);
DCHECK_NE(KioskAppLaunchError::Error::kNone, error);
delegate_->OnLaunchFailed(error);
}
......@@ -489,13 +489,13 @@ void StartupAppLauncher::BeginInstall() {
const extensions::Extension* primary_app = GetPrimaryAppExtension();
if (!primary_app) {
// The extension is skipped for installation due to some error.
OnLaunchFailure(KioskAppLaunchError::UNABLE_TO_INSTALL);
OnLaunchFailure(KioskAppLaunchError::Error::kUnableToInstall);
return;
}
if (!extensions::KioskModeInfo::IsKioskEnabled(primary_app)) {
// The installed primary app is not kiosk enabled.
OnLaunchFailure(KioskAppLaunchError::NOT_KIOSK_ENABLED);
OnLaunchFailure(KioskAppLaunchError::Error::kNotKioskEnabled);
return;
}
......@@ -536,7 +536,7 @@ void StartupAppLauncher::MaybeInstallSecondaryApps() {
// Check extension update before launching the primary kiosk app.
MaybeCheckExtensionUpdate();
} else {
OnLaunchFailure(KioskAppLaunchError::UNABLE_TO_INSTALL);
OnLaunchFailure(KioskAppLaunchError::Error::kUnableToInstall);
}
}
......
......@@ -145,7 +145,7 @@ class TestAppLaunchDelegate : public StartupAppLauncher::Delegate {
LaunchState launch_state_ = LaunchState::kNotStarted;
std::vector<LaunchState> launch_state_changes_;
KioskAppLaunchError::Error launch_error_ = KioskAppLaunchError::NONE;
KioskAppLaunchError::Error launch_error_ = KioskAppLaunchError::Error::kNone;
bool network_ready_ = false;
bool showing_network_config_screen_ = false;
......@@ -738,7 +738,7 @@ TEST_F(StartupAppLauncherTest, PrimaryAppDownloadFailure) {
EXPECT_EQ(std::vector<LaunchState>({LaunchState::kLaunchFailed}),
startup_launch_delegate_.launch_state_changes());
EXPECT_EQ(KioskAppLaunchError::UNABLE_TO_DOWNLOAD,
EXPECT_EQ(KioskAppLaunchError::Error::kUnableToDownload,
startup_launch_delegate_.launch_error());
EXPECT_FALSE(kiosk_app_session_initialized_);
......@@ -757,7 +757,7 @@ TEST_F(StartupAppLauncherTest, PrimaryAppCrxInstallFailure) {
EXPECT_EQ(std::vector<LaunchState>({LaunchState::kLaunchFailed}),
startup_launch_delegate_.launch_state_changes());
EXPECT_EQ(KioskAppLaunchError::UNABLE_TO_INSTALL,
EXPECT_EQ(KioskAppLaunchError::Error::kUnableToInstall,
startup_launch_delegate_.launch_error());
EXPECT_FALSE(kiosk_app_session_initialized_);
......@@ -781,7 +781,7 @@ TEST_F(StartupAppLauncherTest, PrimaryAppNotKioskEnabled) {
EXPECT_EQ(std::vector<LaunchState>({LaunchState::kLaunchFailed}),
startup_launch_delegate_.launch_state_changes());
EXPECT_EQ(KioskAppLaunchError::NOT_KIOSK_ENABLED,
EXPECT_EQ(KioskAppLaunchError::Error::kNotKioskEnabled,
startup_launch_delegate_.launch_error());
EXPECT_FALSE(kiosk_app_session_initialized_);
......@@ -804,7 +804,7 @@ TEST_F(StartupAppLauncherTest, PrimaryAppIsExtension) {
EXPECT_EQ(std::vector<LaunchState>({LaunchState::kLaunchFailed}),
startup_launch_delegate_.launch_state_changes());
EXPECT_EQ(KioskAppLaunchError::NOT_KIOSK_ENABLED,
EXPECT_EQ(KioskAppLaunchError::Error::kNotKioskEnabled,
startup_launch_delegate_.launch_error());
EXPECT_FALSE(kiosk_app_session_initialized_);
......@@ -1030,7 +1030,7 @@ TEST_F(StartupAppLauncherTest, SecondaryAppCrxInstallFailure) {
ASSERT_TRUE(
external_apps_loader_handler_->FailPendingInstall(kSecondaryAppId));
EXPECT_EQ(KioskAppLaunchError::UNABLE_TO_INSTALL,
EXPECT_EQ(KioskAppLaunchError::Error::kUnableToInstall,
startup_launch_delegate_.launch_error());
EXPECT_FALSE(kiosk_app_session_initialized_);
......
......@@ -76,7 +76,7 @@ void WebKioskAppLauncher::OnAppDataObtained(
std::unique_ptr<WebApplicationInfo> app_info) {
if (!app_info) {
// Notify about failed installation, let the controller decide what to do.
delegate_->OnLaunchFailed(KioskAppLaunchError::UNABLE_TO_INSTALL);
delegate_->OnLaunchFailed(KioskAppLaunchError::Error::kUnableToInstall);
return;
}
......@@ -85,7 +85,7 @@ void WebKioskAppLauncher::OnAppDataObtained(
if (url::Origin::Create(GetCurrentApp()->install_url()) !=
url::Origin::Create(app_info->start_url)) {
VLOG(1) << "Origin of the app does not match the origin of install url";
delegate_->OnLaunchFailed(KioskAppLaunchError::UNABLE_TO_LAUNCH);
delegate_->OnLaunchFailed(KioskAppLaunchError::Error::kUnableToLaunch);
return;
}
......
......@@ -249,7 +249,7 @@ TEST_F(WebKioskAppLauncherTest, NormalFlowBadLaunchUrl) {
base::RunLoop loop2;
EXPECT_CALL(*delegate(), OnAppInstalling());
EXPECT_CALL(*delegate(),
OnLaunchFailed((KioskAppLaunchError::Error::UNABLE_TO_LAUNCH)))
OnLaunchFailed((KioskAppLaunchError::Error::kUnableToLaunch)))
.WillOnce(RunClosure(loop2.QuitClosure()));
launcher()->ContinueWithNetworkReady();
loop2.Run();
......@@ -322,7 +322,7 @@ TEST_F(WebKioskAppLauncherTest, UrlNotLoaded) {
base::RunLoop loop2;
EXPECT_CALL(*delegate(), OnAppInstalling());
EXPECT_CALL(*delegate(),
OnLaunchFailed(KioskAppLaunchError::Error::UNABLE_TO_INSTALL))
OnLaunchFailed(KioskAppLaunchError::Error::kUnableToInstall))
.WillOnce(RunClosure(loop2.QuitClosure()));
launcher()->ContinueWithNetworkReady();
loop2.Run();
......
......@@ -245,7 +245,7 @@ bool ShouldAutoLaunchKioskApp(const base::CommandLine& command_line) {
(app_manager->IsAutoLaunchEnabled() ||
web_app_manager->GetAutoLaunchAccountId().is_valid() ||
arc_app_manager->GetAutoLaunchAccountId().is_valid()) &&
KioskAppLaunchError::Get() == KioskAppLaunchError::NONE;
KioskAppLaunchError::Get() == KioskAppLaunchError::Error::kNone;
}
// Creates an instance of the NetworkPortalDetector implementation or a stub.
......
......@@ -342,7 +342,8 @@ IN_PROC_BROWSER_TEST_F(AutoLaunchedNonKioskEnabledAppTest, NotLaunched) {
termination_waiter.Wait();
EXPECT_FALSE(listener.was_satisfied());
EXPECT_EQ(KioskAppLaunchError::NOT_KIOSK_ENABLED, KioskAppLaunchError::Get());
EXPECT_EQ(KioskAppLaunchError::Error::kNotKioskEnabled,
KioskAppLaunchError::Get());
}
// Used to test management API availability in kiosk sessions.
......
......@@ -637,7 +637,7 @@ class KioskTest : public OobeBaseTest {
EXPECT_TRUE(static_cast<ProfileImpl*>(app_profile)->chromeos_preferences_);
// Check installer status.
EXPECT_EQ(chromeos::KioskAppLaunchError::NONE,
EXPECT_EQ(chromeos::KioskAppLaunchError::Error::kNone,
chromeos::KioskAppLaunchError::Get());
// Check if the kiosk webapp is really installed for the default profile.
......@@ -1119,7 +1119,7 @@ IN_PROC_BROWSER_TEST_F(KioskDeviceOwnedTest, DISABLED_LaunchAppUserCancel) {
LoginDisplayHost::default_host()->HandleAccelerator(
ash::LoginAcceleratorAction::kAppLaunchBailout);
signal.Wait();
EXPECT_EQ(chromeos::KioskAppLaunchError::USER_CANCEL,
EXPECT_EQ(chromeos::KioskAppLaunchError::Error::kUserCancel,
chromeos::KioskAppLaunchError::Get());
}
......@@ -2553,7 +2553,7 @@ IN_PROC_BROWSER_TEST_F(KioskEnterpriseTest, EnterpriseKioskApp) {
KioskSessionInitializedWaiter().Wait();
// Check installer status.
EXPECT_EQ(chromeos::KioskAppLaunchError::NONE,
EXPECT_EQ(chromeos::KioskAppLaunchError::Error::kNone,
chromeos::KioskAppLaunchError::Get());
EXPECT_EQ(extensions::Manifest::EXTERNAL_POLICY, GetInstalledAppLocation());
......
......@@ -261,7 +261,7 @@ void KioskLaunchController::OnCancelAppLaunch() {
SYSLOG(INFO) << "Canceling kiosk app launch.";
KioskAppLaunchError::Save(KioskAppLaunchError::USER_CANCEL);
KioskAppLaunchError::Save(KioskAppLaunchError::Error::kUserCancel);
CleanUp();
chrome::AttemptUserExit();
}
......@@ -355,7 +355,7 @@ void KioskLaunchController::OnAppPrepared() {
SYSLOG(WARNING) << "The ExtensionInstallForcelist policy value is invalid.";
splash_screen_view_->ShowErrorMessage(
KioskAppLaunchError::EXTENSIONS_POLICY_INVALID);
KioskAppLaunchError::Error::kExtensionsPolicyInvalid);
OnForceInstalledExtensionsReady();
return;
}
......@@ -421,7 +421,7 @@ void KioskLaunchController::OnExtensionWaitTimedOut() {
SYSLOG(WARNING) << "OnExtensionWaitTimedout...";
splash_screen_view_->ShowErrorMessage(
KioskAppLaunchError::EXTENSIONS_LOAD_TIMEOUT);
KioskAppLaunchError::Error::kExtensionsLoadTimeout);
OnForceInstalledExtensionsReady();
}
......@@ -438,8 +438,8 @@ bool KioskLaunchController::ShouldSkipAppInstallation() const {
}
void KioskLaunchController::OnLaunchFailed(KioskAppLaunchError::Error error) {
DCHECK_NE(KioskAppLaunchError::NONE, error);
SYSLOG(ERROR) << "Kiosk launch failed, error=" << error;
DCHECK_NE(KioskAppLaunchError::Error::kNone, error);
SYSLOG(ERROR) << "Kiosk launch failed, error=" << static_cast<int>(error);
if (kiosk_app_id_.type == KioskAppType::WEB_APP) {
HandleWebAppInstallFailed();
......@@ -447,8 +447,8 @@ void KioskLaunchController::OnLaunchFailed(KioskAppLaunchError::Error error) {
}
// Reboot on the recoverable cryptohome errors.
if (error == KioskAppLaunchError::CRYPTOHOMED_NOT_RUNNING ||
error == KioskAppLaunchError::ALREADY_MOUNTED) {
if (error == KioskAppLaunchError::Error::kCryptohomedNotRunning ||
error == KioskAppLaunchError::Error::kAlreadyMounted) {
// Do not save the error because saved errors would stop app from launching
// on the next run.
chrome::AttemptRelaunch();
......
......@@ -488,7 +488,7 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerWithInvalidExtensionTest,
ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
EXPECT_EQ(view()->GetErrorMessageType(),
KioskAppLaunchError::EXTENSIONS_POLICY_INVALID);
KioskAppLaunchError::Error::kExtensionsPolicyInvalid);
}
INSTANTIATE_TEST_SUITE_P(All,
......
......@@ -76,7 +76,7 @@ bool ShouldAutoLaunchKioskApp(const base::CommandLine& command_line) {
(app_manager->IsAutoLaunchEnabled() ||
web_app_manager->GetAutoLaunchAccountId().is_valid() ||
arc_app_manager->GetAutoLaunchAccountId().is_valid()) &&
KioskAppLaunchError::Get() == KioskAppLaunchError::NONE &&
KioskAppLaunchError::Get() == KioskAppLaunchError::Error::kNone &&
// IsOobeCompleted() is needed to prevent kiosk session start in case
// of enterprise rollback, when keeping the enrollment, policy, not
// clearing TPM, but wiping stateful partition.
......
......@@ -78,7 +78,7 @@ void KioskAppMenuController::SendKioskApps() {
base::BindRepeating(&KioskAppMenuController::OnMenuWillShow,
weak_factory_.GetWeakPtr()));
KioskAppLaunchError::Error error = KioskAppLaunchError::Get();
if (error == KioskAppLaunchError::NONE)
if (error == KioskAppLaunchError::Error::kNone)
return;
// Clear any old pending Kiosk launch errors
......
......@@ -26,7 +26,8 @@ class FakeAppLaunchSplashScreenHandler : public AppLaunchSplashScreenView {
AppLaunchState GetAppLaunchState();
private:
KioskAppLaunchError::Error error_message_type_ = KioskAppLaunchError::NONE;
KioskAppLaunchError::Error error_message_type_ =
KioskAppLaunchError::Error::kNone;
bool network_ready_ = false;
AppLaunchState state_ = APP_LAUNCH_STATE_PREPARING_PROFILE;
};
......
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