Commit 1466a515 authored by Anatoliy Potapchuk's avatar Anatoliy Potapchuk Committed by Commit Bot

[Kiosk] Make all kiosk launchers use KioskProfileLoader

This will help us deduplicate some parts of kiosk session startup code.

Bug: 1086414
Change-Id: I783ab28fa7fb2b2c9c7e7410a5802d2a98b94686
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2215845Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Commit-Queue: Anatoliy Potapchuk <apotapchuk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774085}
parent 59171772
......@@ -48,6 +48,12 @@ class KioskAppManagerBase : public KioskAppDataDelegate {
};
using AppList = std::vector<App>;
enum class AppType {
ARC_APP, // Arc Kiosk.
CHROME_APP, // Chrome App based kiosk.
WEB_APP, // Web App based kiosk.
};
KioskAppManagerBase();
~KioskAppManagerBase() override;
......
......@@ -65,9 +65,7 @@ class KioskProfileLoader::CryptohomedChecker
: public base::SupportsWeakPtr<CryptohomedChecker> {
public:
explicit CryptohomedChecker(KioskProfileLoader* loader)
: loader_(loader),
retry_count_(0) {
}
: loader_(loader), retry_count_(0) {}
~CryptohomedChecker() {}
void StartCheck() {
......@@ -129,14 +127,15 @@ class KioskProfileLoader::CryptohomedChecker
DISALLOW_COPY_AND_ASSIGN(CryptohomedChecker);
};
////////////////////////////////////////////////////////////////////////////////
// KioskProfileLoader
KioskProfileLoader::KioskProfileLoader(const AccountId& app_account_id,
KioskAppManagerBase::AppType app_type,
bool use_guest_mount,
Delegate* delegate)
: account_id_(app_account_id),
app_type_(app_type),
use_guest_mount_(use_guest_mount),
delegate_(delegate) {}
......@@ -151,7 +150,21 @@ void KioskProfileLoader::Start() {
void KioskProfileLoader::LoginAsKioskAccount() {
login_performer_.reset(new ChromeLoginPerformer(this));
switch (app_type_) {
case KioskAppManagerBase::AppType::ARC_APP:
// Arc kiosks do not support ephemeral mount.
DCHECK(!use_guest_mount_);
login_performer_->LoginAsArcKioskAccount(account_id_);
return;
case KioskAppManagerBase::AppType::CHROME_APP:
login_performer_->LoginAsKioskAccount(account_id_, use_guest_mount_);
return;
case KioskAppManagerBase::AppType::WEB_APP:
// Web kiosks do not support ephemeral mount.
DCHECK(!use_guest_mount_);
login_performer_->LoginAsWebKioskAccount(account_id_);
return;
}
}
void KioskProfileLoader::ReportLaunchResult(KioskAppLaunchError::Error error) {
......@@ -200,6 +213,12 @@ void KioskProfileLoader::SetAuthFlowOffline(bool offline) {
NOTREACHED();
}
void KioskProfileLoader::OnOldEncryptionDetected(
const UserContext& user_context,
bool has_incomplete_migration) {
delegate_->OnOldEncryptionDetected(user_context);
}
void KioskProfileLoader::OnProfilePrepared(Profile* profile,
bool browser_launched) {
// This object could be deleted any time after successfully reporting
......
......@@ -11,6 +11,7 @@
#include "base/callback.h"
#include "base/macros.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_manager_base.h"
#include "chrome/browser/chromeos/login/session/user_session_manager.h"
#include "chromeos/login/auth/login_performer.h"
#include "components/account_id/account_id.h"
......@@ -29,12 +30,14 @@ class KioskProfileLoader : public LoginPerformer::Delegate,
public:
virtual void OnProfileLoaded(Profile* profile) = 0;
virtual void OnProfileLoadFailed(KioskAppLaunchError::Error error) = 0;
virtual void OnOldEncryptionDetected(const UserContext& user_context) = 0;
protected:
virtual ~Delegate() {}
};
KioskProfileLoader(const AccountId& app_account_id,
KioskAppManagerBase::AppType app_type,
bool use_guest_mount,
Delegate* delegate);
......@@ -55,11 +58,14 @@ class KioskProfileLoader : public LoginPerformer::Delegate,
void WhiteListCheckFailed(const std::string& email) override;
void PolicyLoadFailed() override;
void SetAuthFlowOffline(bool offline) override;
void OnOldEncryptionDetected(const UserContext& user_context,
bool has_incomplete_migration) override;
// UserSessionManagerDelegate implementation:
void OnProfilePrepared(Profile* profile, bool browser_launched) override;
const AccountId account_id_;
const KioskAppManagerBase::AppType app_type_;
bool use_guest_mount_;
Delegate* delegate_;
std::unique_ptr<CryptohomedChecker> cryptohomed_checker_;
......
......@@ -74,7 +74,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_->OnAppInstallFailed();
delegate_->OnAppLaunchFailed(KioskAppLaunchError::UNABLE_TO_INSTALL);
return;
}
......@@ -83,7 +83,7 @@ void WebKioskAppLauncher::OnAppDataObtained(
if (url::Origin::Create(GetCurrentApp()->install_url()) !=
url::Origin::Create(app_info->app_url)) {
VLOG(1) << "Origin of the app does not match the origin of install url";
delegate_->OnAppLaunchFailed();
delegate_->OnAppLaunchFailed(KioskAppLaunchError::UNABLE_TO_LAUNCH);
return;
}
......
......@@ -10,6 +10,7 @@
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h"
#include "chrome/browser/web_applications/components/web_app_constants.h"
#include "chrome/browser/web_applications/components/web_app_id.h"
#include "chrome/browser/web_applications/components/web_app_install_utils.h"
......@@ -41,9 +42,8 @@ class WebKioskAppLauncher {
virtual void InitializeNetwork() = 0;
virtual void OnAppStartedInstalling() = 0;
virtual void OnAppPrepared() = 0;
virtual void OnAppInstallFailed() = 0;
virtual void OnAppLaunched() = 0;
virtual void OnAppLaunchFailed() = 0;
virtual void OnAppLaunchFailed(KioskAppLaunchError::Error error) = 0;
protected:
virtual ~Delegate() {}
......
......@@ -35,9 +35,8 @@ class MockAppLauncherDelegate : public WebKioskAppLauncher::Delegate {
MOCK_METHOD0(InitializeNetwork, void());
MOCK_METHOD0(OnAppStartedInstalling, void());
MOCK_METHOD0(OnAppPrepared, void());
MOCK_METHOD0(OnAppInstallFailed, void());
MOCK_METHOD0(OnAppLaunched, void());
MOCK_METHOD0(OnAppLaunchFailed, void());
MOCK_METHOD1(OnAppLaunchFailed, void(KioskAppLaunchError::Error));
};
const char kAppEmail[] = "lala@example.com";
......@@ -236,7 +235,8 @@ TEST_F(WebKioskAppLauncherTest, NormalFlowBadLaunchUrl) {
base::RunLoop loop2;
EXPECT_CALL(*delegate(), OnAppStartedInstalling());
EXPECT_CALL(*delegate(), OnAppLaunchFailed())
EXPECT_CALL(*delegate(),
OnAppLaunchFailed((KioskAppLaunchError::Error::UNABLE_TO_LAUNCH)))
.WillOnce(RunClosure(loop2.QuitClosure()));
launcher()->ContinueWithNetworkReady();
loop2.Run();
......@@ -303,7 +303,8 @@ TEST_F(WebKioskAppLauncherTest, UrlNotLoaded) {
base::RunLoop loop2;
EXPECT_CALL(*delegate(), OnAppStartedInstalling());
EXPECT_CALL(*delegate(), OnAppInstallFailed())
EXPECT_CALL(*delegate(),
OnAppLaunchFailed(KioskAppLaunchError::Error::UNABLE_TO_INSTALL))
.WillOnce(RunClosure(loop2.QuitClosure()));
launcher()->ContinueWithNetworkReady();
loop2.Run();
......
......@@ -197,8 +197,8 @@ void AppLaunchController::StartAppLaunch(bool is_auto_launch) {
? extensions::FeatureSessionType::AUTOLAUNCHED_KIOSK
: extensions::FeatureSessionType::KIOSK);
kiosk_profile_loader_.reset(
new KioskProfileLoader(app.account_id, false, this));
kiosk_profile_loader_.reset(new KioskProfileLoader(
app.account_id, KioskAppManager::AppType::CHROME_APP, false, this));
kiosk_profile_loader_->Start();
}
......@@ -327,6 +327,11 @@ void AppLaunchController::OnProfileLoadFailed(
OnLaunchFailed(error);
}
void AppLaunchController::OnOldEncryptionDetected(
const UserContext& user_context) {
NOTREACHED();
}
void AppLaunchController::ClearNetworkWaitTimer() {
waiting_for_network_ = false;
network_wait_timer_.Stop();
......
......@@ -99,6 +99,7 @@ class AppLaunchController : public KioskProfileLoader::Delegate,
// KioskProfileLoader::Delegate overrides:
void OnProfileLoaded(Profile* profile) override;
void OnProfileLoadFailed(KioskAppLaunchError::Error error) override;
void OnOldEncryptionDetected(const UserContext& user_context) override;
// StartupAppLauncher::Delegate overrides:
void InitializeNetwork() override;
......
......@@ -11,7 +11,6 @@
#include "base/timer/timer.h"
#include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_manager.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h"
#include "chrome/browser/chromeos/login/auth/chrome_login_performer.h"
#include "chrome/browser/chromeos/login/screens/encryption_migration_screen.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/login/ui/webui_login_view.h"
......@@ -54,8 +53,9 @@ void ArcKioskController::StartArcKiosk(const AccountId& account_id) {
base::BindOnce(&ArcKioskController::CloseSplashScreen,
weak_ptr_factory_.GetWeakPtr()));
login_performer_ = std::make_unique<ChromeLoginPerformer>(this);
login_performer_->LoginAsArcKioskAccount(account_id);
kiosk_profile_loader_ = std::make_unique<KioskProfileLoader>(
account_id, ArcKioskAppManager::AppType::ARC_APP, false, this);
kiosk_profile_loader_->Start();
}
void ArcKioskController::OnCancelAppLaunch() {
......@@ -86,61 +86,11 @@ void ArcKioskController::CloseSplashScreen() {
session_manager::SessionManager::Get()->SessionStarted();
}
void ArcKioskController::OnAuthFailure(const AuthFailure& error) {
LOG(ERROR) << "ARC Kiosk launch failed. Will now shut down, error="
<< error.GetErrorString();
KioskAppLaunchError::Save(KioskAppLaunchError::ARC_AUTH_FAILED);
CleanUp();
chrome::AttemptUserExit();
}
void ArcKioskController::OnAuthSuccess(const UserContext& user_context) {
// LoginPerformer instance will delete itself in case of successful auth.
login_performer_->set_delegate(nullptr);
ignore_result(login_performer_.release());
UserSessionManager::GetInstance()->StartSession(
user_context, UserSessionManager::PRIMARY_USER_SESSION,
false, // has_auth_cookies
false, // Start session for user.
this);
}
void ArcKioskController::WhiteListCheckFailed(const std::string& email) {
NOTREACHED();
}
void ArcKioskController::PolicyLoadFailed() {
LOG(ERROR) << "Policy load failed. Will now shut down";
KioskAppLaunchError::Save(KioskAppLaunchError::POLICY_LOAD_FAILED);
CleanUp();
chrome::AttemptUserExit();
}
void ArcKioskController::SetAuthFlowOffline(bool offline) {
NOTREACHED();
}
void ArcKioskController::OnOldEncryptionDetected(
const UserContext& user_context,
bool has_incomplete_migration) {
host_->StartWizard(EncryptionMigrationScreenView::kScreenId);
EncryptionMigrationScreen* migration_screen =
static_cast<EncryptionMigrationScreen*>(
host_->GetWizardController()->current_screen());
DCHECK(migration_screen);
migration_screen->SetUserContext(user_context);
migration_screen->SetupInitialView();
}
void ArcKioskController::OnProfilePrepared(Profile* profile,
bool browser_launched) {
void ArcKioskController::OnProfileLoaded(Profile* profile) {
DVLOG(1) << "Profile loaded... Starting app launch.";
profile_ = profile;
// This object could be deleted any time after successfully reporting
// a profile load, so invalidate the delegate now.
UserSessionManager::GetInstance()->DelegateDeleted(this);
ArcKioskAppService::Get(profile_)->SetDelegate(this);
// This is needed to trigger input method extensions being loaded.
......@@ -157,6 +107,23 @@ void ArcKioskController::OnProfilePrepared(Profile* profile,
}
}
void ArcKioskController::OnProfileLoadFailed(KioskAppLaunchError::Error error) {
LOG(ERROR) << "ARC Kiosk launch failed. Will now shut down, error=" << error;
CleanUp();
chrome::AttemptUserExit();
}
void ArcKioskController::OnOldEncryptionDetected(
const UserContext& user_context) {
host_->StartWizard(EncryptionMigrationScreenView::kScreenId);
EncryptionMigrationScreen* migration_screen =
static_cast<EncryptionMigrationScreen*>(
host_->GetWizardController()->current_screen());
DCHECK(migration_screen);
migration_screen->SetUserContext(user_context);
migration_screen->SetupInitialView();
}
void ArcKioskController::OnAppDataUpdated() {
// Invokes Show() to update the app title and icon.
arc_kiosk_splash_screen_view_->Show();
......
......@@ -8,10 +8,10 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_manager_base.h"
#include "chrome/browser/chromeos/login/session/user_session_manager.h"
#include "chrome/browser/chromeos/app_mode/kiosk_profile_loader.h"
#include "chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.h"
#include "chromeos/login/auth/login_performer.h"
class AccountId;
class Profile;
......@@ -29,8 +29,7 @@ class UserContext;
// Controller for the ARC kiosk launch process, responsible for
// coordinating loading the ARC kiosk profile, and
// updating the splash screen UI.
class ArcKioskController : public LoginPerformer::Delegate,
public UserSessionManagerDelegate,
class ArcKioskController : public KioskProfileLoader::Delegate,
public ArcKioskAppService::Delegate,
public AppLaunchSplashScreenView::Delegate {
public:
......@@ -45,17 +44,10 @@ class ArcKioskController : public LoginPerformer::Delegate,
void CleanUp();
void CloseSplashScreen();
// LoginPerformer::Delegate implementation:
void OnAuthFailure(const AuthFailure& error) override;
void OnAuthSuccess(const UserContext& user_context) override;
void WhiteListCheckFailed(const std::string& email) override;
void PolicyLoadFailed() override;
void SetAuthFlowOffline(bool offline) override;
void OnOldEncryptionDetected(const UserContext& user_context,
bool has_incomplete_migration) override;
// UserSessionManagerDelegate implementation:
void OnProfilePrepared(Profile* profile, bool browser_launched) override;
void OnProfileLoaded(Profile* profile) override;
void OnProfileLoadFailed(KioskAppLaunchError::Error error) override;
void OnOldEncryptionDetected(const UserContext& user_context) override;
// ArcKioskAppService::Delegate implementation:
void OnAppDataUpdated() override;
......@@ -78,7 +70,7 @@ class ArcKioskController : public LoginPerformer::Delegate,
Profile* profile_ = nullptr;
// Used to execute login operations.
std::unique_ptr<LoginPerformer> login_performer_ = nullptr;
std::unique_ptr<KioskProfileLoader> kiosk_profile_loader_;
// A timer to ensure the app splash is shown for a minimum amount of time.
base::OneShotTimer splash_wait_timer_;
......
......@@ -53,7 +53,8 @@ void DemoAppLauncher::StartDemoAppLaunch() {
DVLOG(1) << "Launching demo app...";
// user_id = DemoAppUserId, force_emphemeral = true, delegate = this.
kiosk_profile_loader_.reset(
new KioskProfileLoader(user_manager::DemoAccountId(), true, this));
new KioskProfileLoader(user_manager::DemoAccountId(),
KioskAppManager::AppType::CHROME_APP, true, this));
kiosk_profile_loader_->Start();
}
......@@ -115,4 +116,8 @@ void DemoAppLauncher::OnProfileLoadFailed(KioskAppLaunchError::Error error) {
<< KioskAppLaunchError::GetErrorMessage(error);
}
void DemoAppLauncher::OnOldEncryptionDetected(const UserContext& user_context) {
NOTREACHED();
}
} // namespace chromeos
......@@ -39,6 +39,7 @@ class DemoAppLauncher : public KioskProfileLoader::Delegate {
// KioskProfileLoader::Delegate overrides:
void OnProfileLoaded(Profile* profile) override;
void OnProfileLoadFailed(KioskAppLaunchError::Error error) override;
void OnOldEncryptionDetected(const UserContext& user_context) override;
std::unique_ptr<KioskProfileLoader> kiosk_profile_loader_;
......
......@@ -6,19 +6,15 @@
#include "base/bind_helpers.h"
#include "base/syslog_logging.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_manager_base.h"
#include "chrome/browser/chromeos/app_mode/web_app/web_kiosk_app_data.h"
#include "chrome/browser/chromeos/app_mode/web_app/web_kiosk_app_manager.h"
#include "chrome/browser/chromeos/login/auth/chrome_login_performer.h"
#include "chrome/browser/chromeos/login/screens/encryption_migration_screen.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client.h"
#include "chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
#include "chromeos/login/auth/user_context.h"
#include "components/account_id/account_id.h"
......@@ -60,8 +56,9 @@ void WebKioskController::StartWebKiosk(const AccountId& account_id) {
base::BindOnce(&WebKioskController::OnTimerFire,
weak_ptr_factory_.GetWeakPtr()));
login_performer_ = std::make_unique<ChromeLoginPerformer>(this);
login_performer_->LoginAsWebKioskAccount(account_id_);
kiosk_profile_loader_.reset(new KioskProfileLoader(
account_id, WebKioskAppManager::AppType::WEB_APP, false, this));
kiosk_profile_loader_->Start();
}
KioskAppManagerBase::App WebKioskController::GetAppData() {
......@@ -176,33 +173,6 @@ void WebKioskController::CloseSplashScreen() {
host_->Finalize(base::OnceClosure());
}
void WebKioskController::OnAuthFailure(const AuthFailure& error) {
SYSLOG(ERROR) << "Web Kiosk launch failed. Will now shut down, error="
<< error.GetErrorString();
KioskAppLaunchError::SaveCryptohomeFailure(error);
CleanUp();
chrome::AttemptUserExit();
}
void WebKioskController::OnAuthSuccess(const UserContext& user_context) {
// During tests login_performer_ is not used.
if (!testing_) {
// LoginPerformer instance will delete itself in case of successful auth.
login_performer_->set_delegate(nullptr);
ignore_result(login_performer_.release());
}
UserSessionManager::GetInstance()->StartSession(
user_context, UserSessionManager::PRIMARY_USER_SESSION,
false, // has_auth_cookies
false, // Start session for user.
this);
}
void WebKioskController::WhiteListCheckFailed(const std::string& email) {
NOTREACHED();
}
void WebKioskController::InitializeNetwork() {
if (!web_kiosk_splash_screen_view_)
return;
......@@ -233,30 +203,8 @@ void WebKioskController::OnNetworkWaitTimedOut() {
ShowNetworkConfigureUI();
}
void WebKioskController::PolicyLoadFailed() {
SYSLOG(ERROR) << "Policy load failed. Will now shut down";
KioskAppLaunchError::Save(KioskAppLaunchError::POLICY_LOAD_FAILED);
CleanUp();
chrome::AttemptUserExit();
}
void WebKioskController::SetAuthFlowOffline(bool offline) {
NOTREACHED();
}
void WebKioskController::OnOldEncryptionDetected(
const UserContext& user_context,
bool has_incomplete_migration) {
NOTREACHED();
}
void WebKioskController::OnProfilePrepared(Profile* profile,
bool browser_launched) {
void WebKioskController::OnProfileLoaded(Profile* profile) {
DVLOG(1) << "Profile loaded... Starting app launch.";
// This object could be deleted any time after successfully reporting
// a profile load, so invalidate the delegate now.
UserSessionManager::GetInstance()->DelegateDeleted(this);
// This is needed to trigger input method extensions being loaded.
profile->InitChromeOSPreferences();
......@@ -271,6 +219,15 @@ void WebKioskController::OnProfilePrepared(Profile* profile,
ShowNetworkConfigureUI();
}
void WebKioskController::OnProfileLoadFailed(KioskAppLaunchError::Error error) {
OnAppLaunchFailed(error);
}
void WebKioskController::OnOldEncryptionDetected(
const UserContext& user_context) {
NOTREACHED();
}
void WebKioskController::OnAppStartedInstalling() {
app_state_ = AppState::INSTALLING;
if (!web_kiosk_splash_screen_view_)
......@@ -326,8 +283,23 @@ void WebKioskController::OnAppLaunched() {
CloseSplashScreen();
}
void WebKioskController::OnAppLaunchFailed() {
KioskAppLaunchError::Save(KioskAppLaunchError::UNABLE_TO_LAUNCH);
void WebKioskController::OnAppLaunchFailed(KioskAppLaunchError::Error error) {
if (error == KioskAppLaunchError::UNABLE_TO_INSTALL) {
OnAppInstallFailed();
return;
}
// Reboot on the recoverable cryptohome errors.
if (error == KioskAppLaunchError::CRYPTOHOMED_NOT_RUNNING ||
error == KioskAppLaunchError::ALREADY_MOUNTED) {
// Do not save the error because saved errors would stop app from launching
// on the next run.
chrome::AttemptRelaunch();
return;
}
// Saves the error and ends the session to go back to login screen.
KioskAppLaunchError::Save(error);
CleanUp();
chrome::AttemptUserExit();
}
......
......@@ -7,11 +7,11 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_manager_base.h"
#include "chrome/browser/chromeos/app_mode/kiosk_profile_loader.h"
#include "chrome/browser/chromeos/app_mode/web_app/web_kiosk_app_launcher.h"
#include "chrome/browser/chromeos/login/session/user_session_manager.h"
#include "chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.h"
#include "chromeos/login/auth/login_performer.h"
class AccountId;
class Profile;
......@@ -24,7 +24,6 @@ namespace chromeos {
class LoginDisplayHost;
class OobeUI;
class UserContext;
// Controller for the web kiosk launch process, responsible for loading the web
// kiosk profile, and updating the splash screen UI.
......@@ -58,9 +57,8 @@ class UserContext;
// It is all encompassed within the combination of two states -- AppState and
// NetworkUI state.
class WebKioskController : public LoginPerformer::Delegate,
public UserSessionManagerDelegate,
public AppLaunchSplashScreenView::Delegate,
class WebKioskController : public AppLaunchSplashScreenView::Delegate,
public KioskProfileLoader::Delegate,
public WebKioskAppLauncher::Delegate {
public:
WebKioskController(LoginDisplayHost* host, OobeUI* oobe_ui);
......@@ -78,17 +76,10 @@ class WebKioskController : public LoginPerformer::Delegate,
// Used during testing.
WebKioskController();
// LoginPerformer::Delegate:
void OnAuthFailure(const AuthFailure& error) override;
void OnAuthSuccess(const UserContext& user_context) override;
void WhiteListCheckFailed(const std::string& email) override;
void PolicyLoadFailed() override;
void SetAuthFlowOffline(bool offline) override;
void OnOldEncryptionDetected(const UserContext& user_context,
bool has_incomplete_migration) override;
// UserSessionManagerDelegate:
void OnProfilePrepared(Profile* profile, bool browser_launched) override;
// KioskProfileLoader::Delegate:
void OnProfileLoaded(Profile* profile) override;
void OnProfileLoadFailed(KioskAppLaunchError::Error error) override;
void OnOldEncryptionDetected(const UserContext& user_context) override;
// AppLaunchSplashScreenView::Delegate:
void OnCancelAppLaunch() override;
......@@ -102,10 +93,10 @@ class WebKioskController : public LoginPerformer::Delegate,
void InitializeNetwork() override;
void OnAppStartedInstalling() override;
void OnAppPrepared() override;
void OnAppInstallFailed() override;
void OnAppLaunched() override;
void OnAppLaunchFailed() override;
void OnAppLaunchFailed(KioskAppLaunchError::Error error) override;
void OnAppInstallFailed();
void CleanUp();
void OnTimerFire();
void CloseSplashScreen();
......@@ -152,8 +143,8 @@ class WebKioskController : public LoginPerformer::Delegate,
// Used to prepare and launch the actual web kiosk app, is created after
// profile initialization.
std::unique_ptr<WebKioskAppLauncher> app_launcher_;
// Used to execute login operations.
std::unique_ptr<LoginPerformer> login_performer_;
// Used to login into kiosk user profile.
std::unique_ptr<KioskProfileLoader> kiosk_profile_loader_;
// A timer to ensure the app splash is shown for a minimum amount of time.
base::OneShotTimer splash_wait_timer_;
......
......@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "chrome/browser/chromeos/app_mode/web_app/mock_web_kiosk_app_launcher.h"
#include "chrome/browser/chromeos/login/session/user_session_manager.h"
#include "chrome/browser/chromeos/login/web_kiosk_controller.h"
#include "chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client_test_helper.h"
#include "chrome/browser/ui/browser.h"
......@@ -45,8 +44,8 @@ class WebKioskControllerTest : public InProcessBrowserTest {
return static_cast<WebKioskAppLauncher::Delegate*>(controller_.get());
}
UserSessionManagerDelegate* session_controls() {
return static_cast<UserSessionManagerDelegate*>(controller_.get());
KioskProfileLoader::Delegate* profile_controls() {
return static_cast<KioskProfileLoader::Delegate*>(controller_.get());
}
AppLaunchSplashScreenView::Delegate* view_controls() {
......@@ -83,7 +82,7 @@ IN_PROC_BROWSER_TEST_F(WebKioskControllerTest, RegularFlow) {
ExpectState(AppState::CREATING_PROFILE, NetworkUIState::NOT_SHOWING);
EXPECT_CALL(*launcher(), Initialize(_)).Times(1);
session_controls()->OnProfilePrepared(profile(), false);
profile_controls()->OnProfileLoaded(profile());
launch_controls()->InitializeNetwork();
ExpectState(AppState::INIT_NETWORK, NetworkUIState::NOT_SHOWING);
......@@ -108,7 +107,7 @@ IN_PROC_BROWSER_TEST_F(WebKioskControllerTest, AlreadyInstalled) {
ExpectState(AppState::CREATING_PROFILE, NetworkUIState::NOT_SHOWING);
EXPECT_CALL(*launcher(), Initialize(_)).Times(1);
session_controls()->OnProfilePrepared(profile(), false);
profile_controls()->OnProfileLoaded(profile());
launch_controls()->OnAppPrepared();
ExpectState(AppState::INSTALLED, NetworkUIState::NOT_SHOWING);
......@@ -130,7 +129,7 @@ IN_PROC_BROWSER_TEST_F(WebKioskControllerTest, ConfigureNetworkBeforeProfile) {
ExpectState(AppState::CREATING_PROFILE, NetworkUIState::NEED_TO_SHOW);
EXPECT_CALL(*launcher(), Initialize(_)).Times(1);
session_controls()->OnProfilePrepared(profile(), false);
profile_controls()->OnProfileLoaded(profile());
// WebKioskAppLauncher::Initialize call is synchronous, we have to call the
// response now.
launch_controls()->InitializeNetwork();
......@@ -156,7 +155,7 @@ IN_PROC_BROWSER_TEST_F(WebKioskControllerTest,
ExpectState(AppState::CREATING_PROFILE, NetworkUIState::NOT_SHOWING);
EXPECT_CALL(*launcher(), Initialize(_)).Times(1);
session_controls()->OnProfilePrepared(profile(), false);
profile_controls()->OnProfileLoaded(profile());
launch_controls()->InitializeNetwork();
ExpectState(AppState::INIT_NETWORK, NetworkUIState::NOT_SHOWING);
......@@ -193,7 +192,7 @@ IN_PROC_BROWSER_TEST_F(WebKioskControllerTest,
ExpectState(AppState::CREATING_PROFILE, NetworkUIState::NOT_SHOWING);
EXPECT_CALL(*launcher(), Initialize(_)).Times(1);
session_controls()->OnProfilePrepared(profile(), false);
profile_controls()->OnProfileLoaded(profile());
launch_controls()->InitializeNetwork();
ExpectState(AppState::INIT_NETWORK, NetworkUIState::NOT_SHOWING);
......
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