Commit 35ef02fb authored by Sanja Perisic's avatar Sanja Perisic Committed by Chromium LUCI CQ

Improve the enum naming style in KioskLaunchController class

Improve the enumerator style to match constants, not macros (from ENUM_NAME to kEnumName) according to the Google C++ Style Guide.

Bug: 1157058
Change-Id: I6dda26e324917fdfd27e26523f8c30a41746c251
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2584975Reviewed-by: default avatarAnqing Zhao <anqing@chromium.org>
Commit-Queue: Sanja Perisic <sanjaperisic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836127}
parent dacd7b14
......@@ -211,16 +211,16 @@ void KioskLaunchController::OnProfileLoaded(Profile* profile) {
}
app_launcher_->Initialize();
if (network_ui_state_ == NetworkUIState::NEED_TO_SHOW)
if (network_ui_state_ == NetworkUIState::kNeedToShow)
ShowNetworkConfigureUI();
}
void KioskLaunchController::OnConfigureNetwork() {
DCHECK(profile_);
if (network_ui_state_ == NetworkUIState::SHOWING)
if (network_ui_state_ == NetworkUIState::kShowing)
return;
network_ui_state_ = NetworkUIState::SHOWING;
network_ui_state_ = NetworkUIState::kShowing;
if (CanConfigureNetwork() && NeedOwnerAuthToConfigureNetwork()) {
host_->VerifyOwnerForKiosk(
base::BindOnce(&KioskLaunchController::OnOwnerSigninSuccess,
......@@ -296,9 +296,9 @@ void KioskLaunchController::CleanUp() {
}
void KioskLaunchController::OnTimerFire() {
if (app_state_ == AppState::LAUNCHED) {
if (app_state_ == AppState::kLaunched) {
CloseSplashScreen();
} else if (app_state_ == AppState::INSTALLED) {
} else if (app_state_ == AppState::kInstalled) {
LaunchApp();
} else {
launch_on_install_ = true;
......@@ -311,7 +311,7 @@ void KioskLaunchController::CloseSplashScreen() {
void KioskLaunchController::OnAppInstalling() {
SYSLOG(INFO) << "Kiosk app started installing.";
app_state_ = AppState::INSTALLING_APP;
app_state_ = AppState::kInstallingApp;
if (!splash_screen_view_)
return;
splash_screen_view_->UpdateAppLaunchState(
......@@ -327,10 +327,10 @@ void KioskLaunchController::OnAppPrepared() {
if (!splash_screen_view_)
return;
if (network_ui_state_ != NetworkUIState::NOT_SHOWING)
if (network_ui_state_ != NetworkUIState::kNotShowing)
return;
app_state_ = AppState::INSTALLING_EXTENSIONS;
app_state_ = AppState::kInstallingExtensions;
extensions::ForceInstalledTracker* tracker =
GetForceInstalledTracker(profile_);
......@@ -363,14 +363,14 @@ void KioskLaunchController::InitializeNetwork() {
splash_screen_view_->UpdateAppLaunchState(
AppLaunchSplashScreenView::APP_LAUNCH_STATE_PREPARING_NETWORK);
app_state_ = AppState::INIT_NETWORK;
app_state_ = AppState::kInitNetwork;
if (splash_screen_view_->IsNetworkReady())
OnNetworkStateChanged(true);
}
void KioskLaunchController::OnNetworkWaitTimedOut() {
DCHECK_EQ(network_ui_state_, NetworkUIState::NOT_SHOWING);
DCHECK_EQ(network_ui_state_, NetworkUIState::kNotShowing);
auto connection_type = network::mojom::ConnectionType::CONNECTION_UNKNOWN;
content::GetNetworkConnectionTracker()->GetConnectionType(&connection_type,
......@@ -399,7 +399,7 @@ bool KioskLaunchController::IsNetworkReady() const {
}
bool KioskLaunchController::IsShowingNetworkConfigScreen() const {
return network_ui_state_ == NetworkUIState::SHOWING;
return network_ui_state_ == NetworkUIState::kShowing;
}
bool KioskLaunchController::ShouldSkipAppInstallation() const {
......@@ -437,7 +437,7 @@ void KioskLaunchController::HandleWebAppInstallFailed() {
// there is a third-party authorization which causes redirect to url that
// differs from the install url. We should proceed with launch in such cases,
// expecting this situation to not happen upon next launch.
app_state_ = AppState::INSTALLED;
app_state_ = AppState::kInstalled;
SYSLOG(WARNING) << "Failed to obtain app data, trying to launch anyway..";
......@@ -453,7 +453,7 @@ void KioskLaunchController::HandleWebAppInstallFailed() {
void KioskLaunchController::OnAppLaunched() {
SYSLOG(INFO) << "Kiosk launch succeeded, wait for app window.";
app_state_ = AppState::LAUNCHED;
app_state_ = AppState::kLaunched;
if (splash_screen_view_) {
splash_screen_view_->UpdateAppLaunchState(
AppLaunchSplashScreenView::APP_LAUNCH_STATE_WAITING_APP_WINDOW);
......@@ -498,7 +498,7 @@ void KioskLaunchController::OnOldEncryptionDetected(
}
void KioskLaunchController::OnForceInstalledExtensionsReady() {
app_state_ = AppState::INSTALLED;
app_state_ = AppState::kInstalled;
extensions::ForceInstalledTracker* tracker =
GetForceInstalledTracker(profile_);
if (tracker)
......@@ -575,53 +575,53 @@ void KioskLaunchController::ShowNetworkConfigureUI() {
splash_wait_timer_.Stop();
network_wait_timer_.Stop();
launch_on_install_ = true;
network_ui_state_ = NetworkUIState::SHOWING;
network_ui_state_ = NetworkUIState::kShowing;
splash_screen_view_->ShowNetworkConfigureUI();
}
void KioskLaunchController::CloseNetworkConfigureScreenIfOnline() {
if (network_ui_state_ == NetworkUIState::SHOWING && network_wait_timedout_) {
if (network_ui_state_ == NetworkUIState::kShowing && network_wait_timedout_) {
SYSLOG(INFO) << "We are back online, closing network configure screen.";
splash_screen_view_->ToggleNetworkConfig(false);
network_ui_state_ = NetworkUIState::NOT_SHOWING;
network_ui_state_ = NetworkUIState::kNotShowing;
}
}
void KioskLaunchController::OnNetworkConfigRequested() {
network_ui_state_ = NetworkUIState::NEED_TO_SHOW;
network_ui_state_ = NetworkUIState::kNeedToShow;
switch (app_state_) {
case AppState::CREATING_PROFILE:
case AppState::INIT_NETWORK:
case AppState::INSTALLED:
case AppState::kCreatingProfile:
case AppState::kInitNetwork:
case AppState::kInstalled:
MaybeShowNetworkConfigureUI();
break;
case AppState::INSTALLING_APP:
case AppState::INSTALLING_EXTENSIONS:
case AppState::kInstallingApp:
case AppState::kInstallingExtensions:
// When requesting to show network configure UI, we should cancel current
// installation and restart it as soon as the network is configured.
app_state_ = AppState::INIT_NETWORK;
app_state_ = AppState::kInitNetwork;
app_launcher_->RestartLauncher();
MaybeShowNetworkConfigureUI();
break;
case AppState::LAUNCHED:
case AppState::kLaunched:
// We do nothing since the splash screen is soon to be destroyed.
break;
}
}
void KioskLaunchController::OnNetworkConfigFinished() {
network_ui_state_ = NetworkUIState::NOT_SHOWING;
network_ui_state_ = NetworkUIState::kNotShowing;
splash_screen_view_->UpdateAppLaunchState(
AppLaunchSplashScreenView::APP_LAUNCH_STATE_PREPARING_PROFILE);
app_state_ = AppState::INIT_NETWORK;
app_state_ = AppState::kInitNetwork;
app_launcher_->RestartLauncher();
}
void KioskLaunchController::OnNetworkStateChanged(bool online) {
if (app_state_ == AppState::INIT_NETWORK && online) {
if (app_state_ == AppState::kInitNetwork && online) {
// If the network timed out, we should exit network config dialog as soon as
// we are back online.
if (network_ui_state_ == NetworkUIState::NOT_SHOWING ||
if (network_ui_state_ == NetworkUIState::kNotShowing ||
network_wait_timedout_) {
network_wait_timer_.Stop();
CloseNetworkConfigureScreenIfOnline();
......@@ -629,8 +629,8 @@ void KioskLaunchController::OnNetworkStateChanged(bool online) {
}
}
if ((app_state_ == AppState::INSTALLING_APP ||
app_state_ == AppState::INSTALLING_EXTENSIONS) &&
if ((app_state_ == AppState::kInstallingApp ||
app_state_ == AppState::kInstallingExtensions) &&
network_required_ && !online) {
SYSLOG(WARNING)
<< "Connection lost during installation, restarting launcher.";
......@@ -642,7 +642,7 @@ void KioskLaunchController::LaunchApp() {
if (g_block_app_launch_for_testing)
return;
DCHECK(app_state_ == AppState::INSTALLED);
DCHECK(app_state_ == AppState::kInstalled);
// We need to change the session state so we are able to create browser
// windows.
session_manager::SessionManager::Get()->SetSessionState(
......
......@@ -85,11 +85,11 @@ class KioskLaunchController
std::unique_ptr<KioskAppLauncher> app_launcher);
bool waiting_for_network() const {
return app_state_ == AppState::INIT_NETWORK;
return app_state_ == AppState::kInitNetwork;
}
bool network_wait_timedout() const { return network_wait_timedout_; }
bool showing_network_dialog() const {
return network_ui_state_ == NetworkUIState::SHOWING;
return network_ui_state_ == NetworkUIState::kShowing;
}
void Start(const KioskAppId& kiosk_app_id, bool auto_launch);
......@@ -98,19 +98,19 @@ class KioskLaunchController
friend class KioskLaunchControllerTest;
enum AppState {
CREATING_PROFILE, // Profile is being created.
INIT_NETWORK, // Waiting for the network to initialize.
INSTALLING_APP, // App is being installed.
INSTALLING_EXTENSIONS, // Force-installed extensions are being installed.
INSTALLED, // Everything is installed, waiting for the splash screen timer
kCreatingProfile = 0, // Profile is being created.
kInitNetwork, // Waiting for the network to initialize.
kInstallingApp, // App is being installed.
kInstallingExtensions, // Force-installed extensions are being installed.
kInstalled, // Everything is installed, waiting for the splash screen timer
// to fire.
LAUNCHED // App is being launched.
kLaunched // App is being launched.
};
enum NetworkUIState {
NOT_SHOWING, // Network configure UI is not being shown.
NEED_TO_SHOW, // We need to show the UI as soon as we can.
SHOWING // Network configure UI is being shown.
kNotShowing = 0, // Network configure UI is not being shown.
kNeedToShow, // We need to show the UI as soon as we can.
kShowing // Network configure UI is being shown.
};
KioskLaunchController();
......@@ -168,9 +168,9 @@ class KioskLaunchController
void LaunchApp();
// Current state of the controller.
AppState app_state_ = AppState::CREATING_PROFILE;
AppState app_state_ = AppState::kCreatingProfile;
// Current state of network configure dialog.
NetworkUIState network_ui_state_ = NetworkUIState::NOT_SHOWING;
NetworkUIState network_ui_state_ = NetworkUIState::kNotShowing;
LoginDisplayHost* const host_; // Not owned, destructed upon shutdown.
AppLaunchSplashScreenView* splash_screen_view_ = nullptr; // Owned by OobeUI.
......
......@@ -124,55 +124,55 @@ class KioskLaunchControllerTest
IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest, RegularFlow) {
controller()->Start(kiosk_app_id(), false);
ExpectState(AppState::CREATING_PROFILE, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kCreatingProfile, NetworkUIState::kNotShowing);
EXPECT_CALL(*launcher(), Initialize()).Times(1);
profile_controls()->OnProfileLoaded(profile());
launch_controls()->InitializeNetwork();
ExpectState(AppState::INIT_NETWORK, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kInitNetwork, NetworkUIState::kNotShowing);
EXPECT_CALL(*launcher(), ContinueWithNetworkReady()).Times(1);
SetOnline(true);
launch_controls()->OnAppInstalling();
launch_controls()->OnAppPrepared();
ExpectState(AppState::INSTALLED, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kInstalled, NetworkUIState::kNotShowing);
EXPECT_CALL(*launcher(), LaunchApp()).Times(1);
FireSplashScreenTimer();
launch_controls()->OnAppLaunched();
ExpectState(AppState::LAUNCHED, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
}
IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest, AlreadyInstalled) {
controller()->Start(kiosk_app_id(), false);
ExpectState(AppState::CREATING_PROFILE, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kCreatingProfile, NetworkUIState::kNotShowing);
EXPECT_CALL(*launcher(), Initialize()).Times(1);
profile_controls()->OnProfileLoaded(profile());
launch_controls()->OnAppPrepared();
ExpectState(AppState::INSTALLED, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kInstalled, NetworkUIState::kNotShowing);
EXPECT_CALL(*launcher(), LaunchApp()).Times(1);
FireSplashScreenTimer();
launch_controls()->OnAppLaunched();
ExpectState(AppState::LAUNCHED, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
}
IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest,
ConfigureNetworkBeforeProfile) {
controller()->Start(kiosk_app_id(), false);
ExpectState(AppState::CREATING_PROFILE, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kCreatingProfile, NetworkUIState::kNotShowing);
// User presses the hotkey.
view_controls()->OnNetworkConfigRequested();
ExpectState(AppState::CREATING_PROFILE, NetworkUIState::NEED_TO_SHOW);
ExpectState(AppState::kCreatingProfile, NetworkUIState::kNeedToShow);
EXPECT_CALL(*launcher(), Initialize()).Times(1);
profile_controls()->OnProfileLoaded(profile());
......@@ -180,7 +180,7 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest,
// response now.
launch_controls()->InitializeNetwork();
ExpectState(AppState::INIT_NETWORK, NetworkUIState::SHOWING);
ExpectState(AppState::kInitNetwork, NetworkUIState::kShowing);
EXPECT_CALL(*launcher(), RestartLauncher()).Times(1);
view_controls()->OnNetworkConfigFinished();
......@@ -191,7 +191,7 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest,
// network configure ui was shown.
launch_controls()->OnAppLaunched();
ExpectState(AppState::LAUNCHED, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
}
......@@ -199,13 +199,13 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest,
ConfigureNetworkDuringInstallation) {
SetOnline(false);
controller()->Start(kiosk_app_id(), false);
ExpectState(AppState::CREATING_PROFILE, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kCreatingProfile, NetworkUIState::kNotShowing);
EXPECT_CALL(*launcher(), Initialize()).Times(1);
profile_controls()->OnProfileLoaded(profile());
launch_controls()->InitializeNetwork();
ExpectState(AppState::INIT_NETWORK, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kInitNetwork, NetworkUIState::kNotShowing);
EXPECT_CALL(*launcher(), ContinueWithNetworkReady()).Times(1);
SetOnline(true);
......@@ -216,59 +216,59 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest,
view_controls()->OnNetworkConfigRequested();
// Launcher restart causes network to be requested again.
launch_controls()->InitializeNetwork();
ExpectState(AppState::INIT_NETWORK, NetworkUIState::SHOWING);
ExpectState(AppState::kInitNetwork, NetworkUIState::kShowing);
EXPECT_CALL(*launcher(), RestartLauncher()).Times(1);
view_controls()->OnNetworkConfigFinished();
launch_controls()->OnAppInstalling();
ExpectState(AppState::INSTALLING_APP, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kInstallingApp, NetworkUIState::kNotShowing);
launch_controls()->OnAppPrepared();
ExpectState(AppState::INSTALLED, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kInstalled, NetworkUIState::kNotShowing);
EXPECT_CALL(*launcher(), LaunchApp()).Times(1);
FireSplashScreenTimer();
launch_controls()->OnAppLaunched();
ExpectState(AppState::LAUNCHED, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
}
IN_PROC_BROWSER_TEST_P(KioskLaunchControllerTest,
ConnectionLostDuringInstallation) {
controller()->Start(kiosk_app_id(), false);
ExpectState(AppState::CREATING_PROFILE, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kCreatingProfile, NetworkUIState::kNotShowing);
EXPECT_CALL(*launcher(), Initialize()).Times(1);
profile_controls()->OnProfileLoaded(profile());
launch_controls()->InitializeNetwork();
ExpectState(AppState::INIT_NETWORK, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kInitNetwork, NetworkUIState::kNotShowing);
EXPECT_CALL(*launcher(), ContinueWithNetworkReady()).Times(1);
SetOnline(true);
launch_controls()->OnAppInstalling();
ExpectState(AppState::INSTALLING_APP, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kInstallingApp, NetworkUIState::kNotShowing);
SetOnline(false);
launch_controls()->InitializeNetwork();
ExpectState(AppState::INIT_NETWORK, NetworkUIState::SHOWING);
ExpectState(AppState::kInitNetwork, NetworkUIState::kShowing);
EXPECT_CALL(*launcher(), RestartLauncher()).Times(1);
view_controls()->OnNetworkConfigFinished();
launch_controls()->OnAppInstalling();
ExpectState(AppState::INSTALLING_APP, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kInstallingApp, NetworkUIState::kNotShowing);
launch_controls()->OnAppPrepared();
ExpectState(AppState::INSTALLED, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kInstalled, NetworkUIState::kNotShowing);
EXPECT_CALL(*launcher(), LaunchApp()).Times(1);
FireSplashScreenTimer();
launch_controls()->OnAppLaunched();
ExpectState(AppState::LAUNCHED, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
}
......@@ -328,13 +328,13 @@ class KioskLaunchControllerWithExtensionTest
void RunUntilAppPrepared() {
controller()->Start(kiosk_app_id(), false);
ExpectState(AppState::CREATING_PROFILE, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kCreatingProfile, NetworkUIState::kNotShowing);
EXPECT_CALL(*launcher(), Initialize()).Times(1);
profile_controls()->OnProfileLoaded(profile());
launch_controls()->InitializeNetwork();
ExpectState(AppState::INIT_NETWORK, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kInitNetwork, NetworkUIState::kNotShowing);
EXPECT_CALL(*launcher(), ContinueWithNetworkReady()).Times(1);
SetOnline(true);
......@@ -361,29 +361,29 @@ IN_PROC_BROWSER_TEST_P(KioskLaunchControllerWithExtensionTest,
ExtensionLoadedBeforeAppPrepared) {
SetExtensionLoaded();
RunUntilAppPrepared();
ExpectState(AppState::INSTALLED, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kInstalled, NetworkUIState::kNotShowing);
EXPECT_CALL(*launcher(), LaunchApp()).Times(1);
FireSplashScreenTimer();
launch_controls()->OnAppLaunched();
ExpectState(AppState::LAUNCHED, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
}
IN_PROC_BROWSER_TEST_P(KioskLaunchControllerWithExtensionTest,
ExtensionLoadedAfterAppPrepared) {
RunUntilAppPrepared();
ExpectState(AppState::INSTALLING_EXTENSIONS, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kInstallingExtensions, NetworkUIState::kNotShowing);
SetExtensionLoaded();
ExpectState(AppState::INSTALLED, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kInstalled, NetworkUIState::kNotShowing);
EXPECT_CALL(*launcher(), LaunchApp()).Times(1);
FireSplashScreenTimer();
launch_controls()->OnAppLaunched();
ExpectState(AppState::LAUNCHED, NetworkUIState::NOT_SHOWING);
ExpectState(AppState::kLaunched, NetworkUIState::kNotShowing);
EXPECT_TRUE(session_manager::SessionManager::Get()->IsSessionStarted());
}
......
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