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 { ...@@ -48,6 +48,12 @@ class KioskAppManagerBase : public KioskAppDataDelegate {
}; };
using AppList = std::vector<App>; 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();
~KioskAppManagerBase() override; ~KioskAppManagerBase() override;
......
...@@ -65,9 +65,7 @@ class KioskProfileLoader::CryptohomedChecker ...@@ -65,9 +65,7 @@ class KioskProfileLoader::CryptohomedChecker
: public base::SupportsWeakPtr<CryptohomedChecker> { : public base::SupportsWeakPtr<CryptohomedChecker> {
public: public:
explicit CryptohomedChecker(KioskProfileLoader* loader) explicit CryptohomedChecker(KioskProfileLoader* loader)
: loader_(loader), : loader_(loader), retry_count_(0) {}
retry_count_(0) {
}
~CryptohomedChecker() {} ~CryptohomedChecker() {}
void StartCheck() { void StartCheck() {
...@@ -129,14 +127,15 @@ class KioskProfileLoader::CryptohomedChecker ...@@ -129,14 +127,15 @@ class KioskProfileLoader::CryptohomedChecker
DISALLOW_COPY_AND_ASSIGN(CryptohomedChecker); DISALLOW_COPY_AND_ASSIGN(CryptohomedChecker);
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// KioskProfileLoader // KioskProfileLoader
KioskProfileLoader::KioskProfileLoader(const AccountId& app_account_id, KioskProfileLoader::KioskProfileLoader(const AccountId& app_account_id,
KioskAppManagerBase::AppType app_type,
bool use_guest_mount, bool use_guest_mount,
Delegate* delegate) Delegate* delegate)
: account_id_(app_account_id), : account_id_(app_account_id),
app_type_(app_type),
use_guest_mount_(use_guest_mount), use_guest_mount_(use_guest_mount),
delegate_(delegate) {} delegate_(delegate) {}
...@@ -151,7 +150,21 @@ void KioskProfileLoader::Start() { ...@@ -151,7 +150,21 @@ void KioskProfileLoader::Start() {
void KioskProfileLoader::LoginAsKioskAccount() { void KioskProfileLoader::LoginAsKioskAccount() {
login_performer_.reset(new ChromeLoginPerformer(this)); login_performer_.reset(new ChromeLoginPerformer(this));
login_performer_->LoginAsKioskAccount(account_id_, use_guest_mount_); 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) { void KioskProfileLoader::ReportLaunchResult(KioskAppLaunchError::Error error) {
...@@ -200,6 +213,12 @@ void KioskProfileLoader::SetAuthFlowOffline(bool offline) { ...@@ -200,6 +213,12 @@ void KioskProfileLoader::SetAuthFlowOffline(bool offline) {
NOTREACHED(); NOTREACHED();
} }
void KioskProfileLoader::OnOldEncryptionDetected(
const UserContext& user_context,
bool has_incomplete_migration) {
delegate_->OnOldEncryptionDetected(user_context);
}
void KioskProfileLoader::OnProfilePrepared(Profile* profile, void KioskProfileLoader::OnProfilePrepared(Profile* profile,
bool browser_launched) { bool browser_launched) {
// This object could be deleted any time after successfully reporting // This object could be deleted any time after successfully reporting
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.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/login/session/user_session_manager.h"
#include "chromeos/login/auth/login_performer.h" #include "chromeos/login/auth/login_performer.h"
#include "components/account_id/account_id.h" #include "components/account_id/account_id.h"
...@@ -29,12 +30,14 @@ class KioskProfileLoader : public LoginPerformer::Delegate, ...@@ -29,12 +30,14 @@ class KioskProfileLoader : public LoginPerformer::Delegate,
public: public:
virtual void OnProfileLoaded(Profile* profile) = 0; virtual void OnProfileLoaded(Profile* profile) = 0;
virtual void OnProfileLoadFailed(KioskAppLaunchError::Error error) = 0; virtual void OnProfileLoadFailed(KioskAppLaunchError::Error error) = 0;
virtual void OnOldEncryptionDetected(const UserContext& user_context) = 0;
protected: protected:
virtual ~Delegate() {} virtual ~Delegate() {}
}; };
KioskProfileLoader(const AccountId& app_account_id, KioskProfileLoader(const AccountId& app_account_id,
KioskAppManagerBase::AppType app_type,
bool use_guest_mount, bool use_guest_mount,
Delegate* delegate); Delegate* delegate);
...@@ -55,11 +58,14 @@ class KioskProfileLoader : public LoginPerformer::Delegate, ...@@ -55,11 +58,14 @@ class KioskProfileLoader : public LoginPerformer::Delegate,
void WhiteListCheckFailed(const std::string& email) override; void WhiteListCheckFailed(const std::string& email) override;
void PolicyLoadFailed() override; void PolicyLoadFailed() override;
void SetAuthFlowOffline(bool offline) override; void SetAuthFlowOffline(bool offline) override;
void OnOldEncryptionDetected(const UserContext& user_context,
bool has_incomplete_migration) override;
// UserSessionManagerDelegate implementation: // UserSessionManagerDelegate implementation:
void OnProfilePrepared(Profile* profile, bool browser_launched) override; void OnProfilePrepared(Profile* profile, bool browser_launched) override;
const AccountId account_id_; const AccountId account_id_;
const KioskAppManagerBase::AppType app_type_;
bool use_guest_mount_; bool use_guest_mount_;
Delegate* delegate_; Delegate* delegate_;
std::unique_ptr<CryptohomedChecker> cryptohomed_checker_; std::unique_ptr<CryptohomedChecker> cryptohomed_checker_;
......
...@@ -74,7 +74,7 @@ void WebKioskAppLauncher::OnAppDataObtained( ...@@ -74,7 +74,7 @@ void WebKioskAppLauncher::OnAppDataObtained(
std::unique_ptr<WebApplicationInfo> app_info) { std::unique_ptr<WebApplicationInfo> app_info) {
if (!app_info) { if (!app_info) {
// Notify about failed installation, let the controller decide what to do. // Notify about failed installation, let the controller decide what to do.
delegate_->OnAppInstallFailed(); delegate_->OnAppLaunchFailed(KioskAppLaunchError::UNABLE_TO_INSTALL);
return; return;
} }
...@@ -83,7 +83,7 @@ void WebKioskAppLauncher::OnAppDataObtained( ...@@ -83,7 +83,7 @@ void WebKioskAppLauncher::OnAppDataObtained(
if (url::Origin::Create(GetCurrentApp()->install_url()) != if (url::Origin::Create(GetCurrentApp()->install_url()) !=
url::Origin::Create(app_info->app_url)) { url::Origin::Create(app_info->app_url)) {
VLOG(1) << "Origin of the app does not match the origin of install url"; VLOG(1) << "Origin of the app does not match the origin of install url";
delegate_->OnAppLaunchFailed(); delegate_->OnAppLaunchFailed(KioskAppLaunchError::UNABLE_TO_LAUNCH);
return; return;
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.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_constants.h"
#include "chrome/browser/web_applications/components/web_app_id.h" #include "chrome/browser/web_applications/components/web_app_id.h"
#include "chrome/browser/web_applications/components/web_app_install_utils.h" #include "chrome/browser/web_applications/components/web_app_install_utils.h"
...@@ -41,9 +42,8 @@ class WebKioskAppLauncher { ...@@ -41,9 +42,8 @@ class WebKioskAppLauncher {
virtual void InitializeNetwork() = 0; virtual void InitializeNetwork() = 0;
virtual void OnAppStartedInstalling() = 0; virtual void OnAppStartedInstalling() = 0;
virtual void OnAppPrepared() = 0; virtual void OnAppPrepared() = 0;
virtual void OnAppInstallFailed() = 0;
virtual void OnAppLaunched() = 0; virtual void OnAppLaunched() = 0;
virtual void OnAppLaunchFailed() = 0; virtual void OnAppLaunchFailed(KioskAppLaunchError::Error error) = 0;
protected: protected:
virtual ~Delegate() {} virtual ~Delegate() {}
......
...@@ -35,9 +35,8 @@ class MockAppLauncherDelegate : public WebKioskAppLauncher::Delegate { ...@@ -35,9 +35,8 @@ class MockAppLauncherDelegate : public WebKioskAppLauncher::Delegate {
MOCK_METHOD0(InitializeNetwork, void()); MOCK_METHOD0(InitializeNetwork, void());
MOCK_METHOD0(OnAppStartedInstalling, void()); MOCK_METHOD0(OnAppStartedInstalling, void());
MOCK_METHOD0(OnAppPrepared, void()); MOCK_METHOD0(OnAppPrepared, void());
MOCK_METHOD0(OnAppInstallFailed, void());
MOCK_METHOD0(OnAppLaunched, void()); MOCK_METHOD0(OnAppLaunched, void());
MOCK_METHOD0(OnAppLaunchFailed, void()); MOCK_METHOD1(OnAppLaunchFailed, void(KioskAppLaunchError::Error));
}; };
const char kAppEmail[] = "lala@example.com"; const char kAppEmail[] = "lala@example.com";
...@@ -236,7 +235,8 @@ TEST_F(WebKioskAppLauncherTest, NormalFlowBadLaunchUrl) { ...@@ -236,7 +235,8 @@ TEST_F(WebKioskAppLauncherTest, NormalFlowBadLaunchUrl) {
base::RunLoop loop2; base::RunLoop loop2;
EXPECT_CALL(*delegate(), OnAppStartedInstalling()); EXPECT_CALL(*delegate(), OnAppStartedInstalling());
EXPECT_CALL(*delegate(), OnAppLaunchFailed()) EXPECT_CALL(*delegate(),
OnAppLaunchFailed((KioskAppLaunchError::Error::UNABLE_TO_LAUNCH)))
.WillOnce(RunClosure(loop2.QuitClosure())); .WillOnce(RunClosure(loop2.QuitClosure()));
launcher()->ContinueWithNetworkReady(); launcher()->ContinueWithNetworkReady();
loop2.Run(); loop2.Run();
...@@ -303,7 +303,8 @@ TEST_F(WebKioskAppLauncherTest, UrlNotLoaded) { ...@@ -303,7 +303,8 @@ TEST_F(WebKioskAppLauncherTest, UrlNotLoaded) {
base::RunLoop loop2; base::RunLoop loop2;
EXPECT_CALL(*delegate(), OnAppStartedInstalling()); EXPECT_CALL(*delegate(), OnAppStartedInstalling());
EXPECT_CALL(*delegate(), OnAppInstallFailed()) EXPECT_CALL(*delegate(),
OnAppLaunchFailed(KioskAppLaunchError::Error::UNABLE_TO_INSTALL))
.WillOnce(RunClosure(loop2.QuitClosure())); .WillOnce(RunClosure(loop2.QuitClosure()));
launcher()->ContinueWithNetworkReady(); launcher()->ContinueWithNetworkReady();
loop2.Run(); loop2.Run();
......
...@@ -197,8 +197,8 @@ void AppLaunchController::StartAppLaunch(bool is_auto_launch) { ...@@ -197,8 +197,8 @@ void AppLaunchController::StartAppLaunch(bool is_auto_launch) {
? extensions::FeatureSessionType::AUTOLAUNCHED_KIOSK ? extensions::FeatureSessionType::AUTOLAUNCHED_KIOSK
: extensions::FeatureSessionType::KIOSK); : extensions::FeatureSessionType::KIOSK);
kiosk_profile_loader_.reset( kiosk_profile_loader_.reset(new KioskProfileLoader(
new KioskProfileLoader(app.account_id, false, this)); app.account_id, KioskAppManager::AppType::CHROME_APP, false, this));
kiosk_profile_loader_->Start(); kiosk_profile_loader_->Start();
} }
...@@ -327,6 +327,11 @@ void AppLaunchController::OnProfileLoadFailed( ...@@ -327,6 +327,11 @@ void AppLaunchController::OnProfileLoadFailed(
OnLaunchFailed(error); OnLaunchFailed(error);
} }
void AppLaunchController::OnOldEncryptionDetected(
const UserContext& user_context) {
NOTREACHED();
}
void AppLaunchController::ClearNetworkWaitTimer() { void AppLaunchController::ClearNetworkWaitTimer() {
waiting_for_network_ = false; waiting_for_network_ = false;
network_wait_timer_.Stop(); network_wait_timer_.Stop();
......
...@@ -99,6 +99,7 @@ class AppLaunchController : public KioskProfileLoader::Delegate, ...@@ -99,6 +99,7 @@ class AppLaunchController : public KioskProfileLoader::Delegate,
// KioskProfileLoader::Delegate overrides: // KioskProfileLoader::Delegate overrides:
void OnProfileLoaded(Profile* profile) override; void OnProfileLoaded(Profile* profile) override;
void OnProfileLoadFailed(KioskAppLaunchError::Error error) override; void OnProfileLoadFailed(KioskAppLaunchError::Error error) override;
void OnOldEncryptionDetected(const UserContext& user_context) override;
// StartupAppLauncher::Delegate overrides: // StartupAppLauncher::Delegate overrides:
void InitializeNetwork() override; void InitializeNetwork() override;
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_manager.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/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/screens/encryption_migration_screen.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h" #include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/login/ui/webui_login_view.h" #include "chrome/browser/chromeos/login/ui/webui_login_view.h"
...@@ -54,8 +53,9 @@ void ArcKioskController::StartArcKiosk(const AccountId& account_id) { ...@@ -54,8 +53,9 @@ void ArcKioskController::StartArcKiosk(const AccountId& account_id) {
base::BindOnce(&ArcKioskController::CloseSplashScreen, base::BindOnce(&ArcKioskController::CloseSplashScreen,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
login_performer_ = std::make_unique<ChromeLoginPerformer>(this); kiosk_profile_loader_ = std::make_unique<KioskProfileLoader>(
login_performer_->LoginAsArcKioskAccount(account_id); account_id, ArcKioskAppManager::AppType::ARC_APP, false, this);
kiosk_profile_loader_->Start();
} }
void ArcKioskController::OnCancelAppLaunch() { void ArcKioskController::OnCancelAppLaunch() {
...@@ -86,61 +86,11 @@ void ArcKioskController::CloseSplashScreen() { ...@@ -86,61 +86,11 @@ void ArcKioskController::CloseSplashScreen() {
session_manager::SessionManager::Get()->SessionStarted(); session_manager::SessionManager::Get()->SessionStarted();
} }
void ArcKioskController::OnAuthFailure(const AuthFailure& error) { void ArcKioskController::OnProfileLoaded(Profile* profile) {
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) {
DVLOG(1) << "Profile loaded... Starting app launch."; DVLOG(1) << "Profile loaded... Starting app launch.";
profile_ = profile; profile_ = profile;
// This object could be deleted any time after successfully reporting // This object could be deleted any time after successfully reporting
// a profile load, so invalidate the delegate now. // a profile load, so invalidate the delegate now.
UserSessionManager::GetInstance()->DelegateDeleted(this);
ArcKioskAppService::Get(profile_)->SetDelegate(this); ArcKioskAppService::Get(profile_)->SetDelegate(this);
// This is needed to trigger input method extensions being loaded. // This is needed to trigger input method extensions being loaded.
...@@ -157,6 +107,23 @@ void ArcKioskController::OnProfilePrepared(Profile* profile, ...@@ -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() { void ArcKioskController::OnAppDataUpdated() {
// Invokes Show() to update the app title and icon. // Invokes Show() to update the app title and icon.
arc_kiosk_splash_screen_view_->Show(); arc_kiosk_splash_screen_view_->Show();
......
...@@ -8,10 +8,10 @@ ...@@ -8,10 +8,10 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.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/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/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 "chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.h"
#include "chromeos/login/auth/login_performer.h"
class AccountId; class AccountId;
class Profile; class Profile;
...@@ -29,8 +29,7 @@ class UserContext; ...@@ -29,8 +29,7 @@ class UserContext;
// Controller for the ARC kiosk launch process, responsible for // Controller for the ARC kiosk launch process, responsible for
// coordinating loading the ARC kiosk profile, and // coordinating loading the ARC kiosk profile, and
// updating the splash screen UI. // updating the splash screen UI.
class ArcKioskController : public LoginPerformer::Delegate, class ArcKioskController : public KioskProfileLoader::Delegate,
public UserSessionManagerDelegate,
public ArcKioskAppService::Delegate, public ArcKioskAppService::Delegate,
public AppLaunchSplashScreenView::Delegate { public AppLaunchSplashScreenView::Delegate {
public: public:
...@@ -45,17 +44,10 @@ class ArcKioskController : public LoginPerformer::Delegate, ...@@ -45,17 +44,10 @@ class ArcKioskController : public LoginPerformer::Delegate,
void CleanUp(); void CleanUp();
void CloseSplashScreen(); 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: // 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: // ArcKioskAppService::Delegate implementation:
void OnAppDataUpdated() override; void OnAppDataUpdated() override;
...@@ -78,7 +70,7 @@ class ArcKioskController : public LoginPerformer::Delegate, ...@@ -78,7 +70,7 @@ class ArcKioskController : public LoginPerformer::Delegate,
Profile* profile_ = nullptr; Profile* profile_ = nullptr;
// Used to execute login operations. // 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. // A timer to ensure the app splash is shown for a minimum amount of time.
base::OneShotTimer splash_wait_timer_; base::OneShotTimer splash_wait_timer_;
......
...@@ -53,7 +53,8 @@ void DemoAppLauncher::StartDemoAppLaunch() { ...@@ -53,7 +53,8 @@ void DemoAppLauncher::StartDemoAppLaunch() {
DVLOG(1) << "Launching demo app..."; DVLOG(1) << "Launching demo app...";
// user_id = DemoAppUserId, force_emphemeral = true, delegate = this. // user_id = DemoAppUserId, force_emphemeral = true, delegate = this.
kiosk_profile_loader_.reset( 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(); kiosk_profile_loader_->Start();
} }
...@@ -115,4 +116,8 @@ void DemoAppLauncher::OnProfileLoadFailed(KioskAppLaunchError::Error error) { ...@@ -115,4 +116,8 @@ void DemoAppLauncher::OnProfileLoadFailed(KioskAppLaunchError::Error error) {
<< KioskAppLaunchError::GetErrorMessage(error); << KioskAppLaunchError::GetErrorMessage(error);
} }
void DemoAppLauncher::OnOldEncryptionDetected(const UserContext& user_context) {
NOTREACHED();
}
} // namespace chromeos } // namespace chromeos
...@@ -39,6 +39,7 @@ class DemoAppLauncher : public KioskProfileLoader::Delegate { ...@@ -39,6 +39,7 @@ class DemoAppLauncher : public KioskProfileLoader::Delegate {
// KioskProfileLoader::Delegate overrides: // KioskProfileLoader::Delegate overrides:
void OnProfileLoaded(Profile* profile) override; void OnProfileLoaded(Profile* profile) override;
void OnProfileLoadFailed(KioskAppLaunchError::Error error) override; void OnProfileLoadFailed(KioskAppLaunchError::Error error) override;
void OnOldEncryptionDetected(const UserContext& user_context) override;
std::unique_ptr<KioskProfileLoader> kiosk_profile_loader_; std::unique_ptr<KioskProfileLoader> kiosk_profile_loader_;
......
...@@ -6,19 +6,15 @@ ...@@ -6,19 +6,15 @@
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/syslog_logging.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/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_data.h"
#include "chrome/browser/chromeos/app_mode/web_app/web_kiosk_app_manager.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/ui/login_display_host.h"
#include "chrome/browser/chromeos/login/wizard_controller.h" #include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client.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/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 "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
#include "chromeos/login/auth/user_context.h" #include "chromeos/login/auth/user_context.h"
#include "components/account_id/account_id.h" #include "components/account_id/account_id.h"
...@@ -60,8 +56,9 @@ void WebKioskController::StartWebKiosk(const AccountId& account_id) { ...@@ -60,8 +56,9 @@ void WebKioskController::StartWebKiosk(const AccountId& account_id) {
base::BindOnce(&WebKioskController::OnTimerFire, base::BindOnce(&WebKioskController::OnTimerFire,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
login_performer_ = std::make_unique<ChromeLoginPerformer>(this); kiosk_profile_loader_.reset(new KioskProfileLoader(
login_performer_->LoginAsWebKioskAccount(account_id_); account_id, WebKioskAppManager::AppType::WEB_APP, false, this));
kiosk_profile_loader_->Start();
} }
KioskAppManagerBase::App WebKioskController::GetAppData() { KioskAppManagerBase::App WebKioskController::GetAppData() {
...@@ -176,33 +173,6 @@ void WebKioskController::CloseSplashScreen() { ...@@ -176,33 +173,6 @@ void WebKioskController::CloseSplashScreen() {
host_->Finalize(base::OnceClosure()); 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() { void WebKioskController::InitializeNetwork() {
if (!web_kiosk_splash_screen_view_) if (!web_kiosk_splash_screen_view_)
return; return;
...@@ -233,30 +203,8 @@ void WebKioskController::OnNetworkWaitTimedOut() { ...@@ -233,30 +203,8 @@ void WebKioskController::OnNetworkWaitTimedOut() {
ShowNetworkConfigureUI(); ShowNetworkConfigureUI();
} }
void WebKioskController::PolicyLoadFailed() { void WebKioskController::OnProfileLoaded(Profile* profile) {
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) {
DVLOG(1) << "Profile loaded... Starting app launch."; 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. // This is needed to trigger input method extensions being loaded.
profile->InitChromeOSPreferences(); profile->InitChromeOSPreferences();
...@@ -271,6 +219,15 @@ void WebKioskController::OnProfilePrepared(Profile* profile, ...@@ -271,6 +219,15 @@ void WebKioskController::OnProfilePrepared(Profile* profile,
ShowNetworkConfigureUI(); ShowNetworkConfigureUI();
} }
void WebKioskController::OnProfileLoadFailed(KioskAppLaunchError::Error error) {
OnAppLaunchFailed(error);
}
void WebKioskController::OnOldEncryptionDetected(
const UserContext& user_context) {
NOTREACHED();
}
void WebKioskController::OnAppStartedInstalling() { void WebKioskController::OnAppStartedInstalling() {
app_state_ = AppState::INSTALLING; app_state_ = AppState::INSTALLING;
if (!web_kiosk_splash_screen_view_) if (!web_kiosk_splash_screen_view_)
...@@ -326,8 +283,23 @@ void WebKioskController::OnAppLaunched() { ...@@ -326,8 +283,23 @@ void WebKioskController::OnAppLaunched() {
CloseSplashScreen(); CloseSplashScreen();
} }
void WebKioskController::OnAppLaunchFailed() { void WebKioskController::OnAppLaunchFailed(KioskAppLaunchError::Error error) {
KioskAppLaunchError::Save(KioskAppLaunchError::UNABLE_TO_LAUNCH); 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(); CleanUp();
chrome::AttemptUserExit(); chrome::AttemptUserExit();
} }
......
...@@ -7,11 +7,11 @@ ...@@ -7,11 +7,11 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.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_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/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 "chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.h"
#include "chromeos/login/auth/login_performer.h"
class AccountId; class AccountId;
class Profile; class Profile;
...@@ -24,7 +24,6 @@ namespace chromeos { ...@@ -24,7 +24,6 @@ namespace chromeos {
class LoginDisplayHost; class LoginDisplayHost;
class OobeUI; class OobeUI;
class UserContext;
// Controller for the web kiosk launch process, responsible for loading the web // Controller for the web kiosk launch process, responsible for loading the web
// kiosk profile, and updating the splash screen UI. // kiosk profile, and updating the splash screen UI.
...@@ -58,9 +57,8 @@ class UserContext; ...@@ -58,9 +57,8 @@ class UserContext;
// It is all encompassed within the combination of two states -- AppState and // It is all encompassed within the combination of two states -- AppState and
// NetworkUI state. // NetworkUI state.
class WebKioskController : public LoginPerformer::Delegate, class WebKioskController : public AppLaunchSplashScreenView::Delegate,
public UserSessionManagerDelegate, public KioskProfileLoader::Delegate,
public AppLaunchSplashScreenView::Delegate,
public WebKioskAppLauncher::Delegate { public WebKioskAppLauncher::Delegate {
public: public:
WebKioskController(LoginDisplayHost* host, OobeUI* oobe_ui); WebKioskController(LoginDisplayHost* host, OobeUI* oobe_ui);
...@@ -78,17 +76,10 @@ class WebKioskController : public LoginPerformer::Delegate, ...@@ -78,17 +76,10 @@ class WebKioskController : public LoginPerformer::Delegate,
// Used during testing. // Used during testing.
WebKioskController(); WebKioskController();
// LoginPerformer::Delegate: // KioskProfileLoader::Delegate:
void OnAuthFailure(const AuthFailure& error) override; void OnProfileLoaded(Profile* profile) override;
void OnAuthSuccess(const UserContext& user_context) override; void OnProfileLoadFailed(KioskAppLaunchError::Error error) override;
void WhiteListCheckFailed(const std::string& email) override; void OnOldEncryptionDetected(const UserContext& user_context) 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;
// AppLaunchSplashScreenView::Delegate: // AppLaunchSplashScreenView::Delegate:
void OnCancelAppLaunch() override; void OnCancelAppLaunch() override;
...@@ -102,10 +93,10 @@ class WebKioskController : public LoginPerformer::Delegate, ...@@ -102,10 +93,10 @@ class WebKioskController : public LoginPerformer::Delegate,
void InitializeNetwork() override; void InitializeNetwork() override;
void OnAppStartedInstalling() override; void OnAppStartedInstalling() override;
void OnAppPrepared() override; void OnAppPrepared() override;
void OnAppInstallFailed() override;
void OnAppLaunched() override; void OnAppLaunched() override;
void OnAppLaunchFailed() override; void OnAppLaunchFailed(KioskAppLaunchError::Error error) override;
void OnAppInstallFailed();
void CleanUp(); void CleanUp();
void OnTimerFire(); void OnTimerFire();
void CloseSplashScreen(); void CloseSplashScreen();
...@@ -152,8 +143,8 @@ class WebKioskController : public LoginPerformer::Delegate, ...@@ -152,8 +143,8 @@ class WebKioskController : public LoginPerformer::Delegate,
// Used to prepare and launch the actual web kiosk app, is created after // Used to prepare and launch the actual web kiosk app, is created after
// profile initialization. // profile initialization.
std::unique_ptr<WebKioskAppLauncher> app_launcher_; std::unique_ptr<WebKioskAppLauncher> app_launcher_;
// Used to execute login operations. // Used to login into kiosk user profile.
std::unique_ptr<LoginPerformer> login_performer_; std::unique_ptr<KioskProfileLoader> kiosk_profile_loader_;
// A timer to ensure the app splash is shown for a minimum amount of time. // A timer to ensure the app splash is shown for a minimum amount of time.
base::OneShotTimer splash_wait_timer_; base::OneShotTimer splash_wait_timer_;
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/chromeos/app_mode/web_app/mock_web_kiosk_app_launcher.h" #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/chromeos/login/web_kiosk_controller.h"
#include "chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client_test_helper.h" #include "chrome/browser/ui/ash/keyboard/chrome_keyboard_controller_client_test_helper.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
...@@ -45,8 +44,8 @@ class WebKioskControllerTest : public InProcessBrowserTest { ...@@ -45,8 +44,8 @@ class WebKioskControllerTest : public InProcessBrowserTest {
return static_cast<WebKioskAppLauncher::Delegate*>(controller_.get()); return static_cast<WebKioskAppLauncher::Delegate*>(controller_.get());
} }
UserSessionManagerDelegate* session_controls() { KioskProfileLoader::Delegate* profile_controls() {
return static_cast<UserSessionManagerDelegate*>(controller_.get()); return static_cast<KioskProfileLoader::Delegate*>(controller_.get());
} }
AppLaunchSplashScreenView::Delegate* view_controls() { AppLaunchSplashScreenView::Delegate* view_controls() {
...@@ -83,7 +82,7 @@ IN_PROC_BROWSER_TEST_F(WebKioskControllerTest, RegularFlow) { ...@@ -83,7 +82,7 @@ IN_PROC_BROWSER_TEST_F(WebKioskControllerTest, RegularFlow) {
ExpectState(AppState::CREATING_PROFILE, NetworkUIState::NOT_SHOWING); ExpectState(AppState::CREATING_PROFILE, NetworkUIState::NOT_SHOWING);
EXPECT_CALL(*launcher(), Initialize(_)).Times(1); EXPECT_CALL(*launcher(), Initialize(_)).Times(1);
session_controls()->OnProfilePrepared(profile(), false); profile_controls()->OnProfileLoaded(profile());
launch_controls()->InitializeNetwork(); launch_controls()->InitializeNetwork();
ExpectState(AppState::INIT_NETWORK, NetworkUIState::NOT_SHOWING); ExpectState(AppState::INIT_NETWORK, NetworkUIState::NOT_SHOWING);
...@@ -108,7 +107,7 @@ IN_PROC_BROWSER_TEST_F(WebKioskControllerTest, AlreadyInstalled) { ...@@ -108,7 +107,7 @@ IN_PROC_BROWSER_TEST_F(WebKioskControllerTest, AlreadyInstalled) {
ExpectState(AppState::CREATING_PROFILE, NetworkUIState::NOT_SHOWING); ExpectState(AppState::CREATING_PROFILE, NetworkUIState::NOT_SHOWING);
EXPECT_CALL(*launcher(), Initialize(_)).Times(1); EXPECT_CALL(*launcher(), Initialize(_)).Times(1);
session_controls()->OnProfilePrepared(profile(), false); profile_controls()->OnProfileLoaded(profile());
launch_controls()->OnAppPrepared(); launch_controls()->OnAppPrepared();
ExpectState(AppState::INSTALLED, NetworkUIState::NOT_SHOWING); ExpectState(AppState::INSTALLED, NetworkUIState::NOT_SHOWING);
...@@ -130,7 +129,7 @@ IN_PROC_BROWSER_TEST_F(WebKioskControllerTest, ConfigureNetworkBeforeProfile) { ...@@ -130,7 +129,7 @@ IN_PROC_BROWSER_TEST_F(WebKioskControllerTest, ConfigureNetworkBeforeProfile) {
ExpectState(AppState::CREATING_PROFILE, NetworkUIState::NEED_TO_SHOW); ExpectState(AppState::CREATING_PROFILE, NetworkUIState::NEED_TO_SHOW);
EXPECT_CALL(*launcher(), Initialize(_)).Times(1); 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 // WebKioskAppLauncher::Initialize call is synchronous, we have to call the
// response now. // response now.
launch_controls()->InitializeNetwork(); launch_controls()->InitializeNetwork();
...@@ -156,7 +155,7 @@ IN_PROC_BROWSER_TEST_F(WebKioskControllerTest, ...@@ -156,7 +155,7 @@ IN_PROC_BROWSER_TEST_F(WebKioskControllerTest,
ExpectState(AppState::CREATING_PROFILE, NetworkUIState::NOT_SHOWING); ExpectState(AppState::CREATING_PROFILE, NetworkUIState::NOT_SHOWING);
EXPECT_CALL(*launcher(), Initialize(_)).Times(1); EXPECT_CALL(*launcher(), Initialize(_)).Times(1);
session_controls()->OnProfilePrepared(profile(), false); profile_controls()->OnProfileLoaded(profile());
launch_controls()->InitializeNetwork(); launch_controls()->InitializeNetwork();
ExpectState(AppState::INIT_NETWORK, NetworkUIState::NOT_SHOWING); ExpectState(AppState::INIT_NETWORK, NetworkUIState::NOT_SHOWING);
...@@ -193,7 +192,7 @@ IN_PROC_BROWSER_TEST_F(WebKioskControllerTest, ...@@ -193,7 +192,7 @@ IN_PROC_BROWSER_TEST_F(WebKioskControllerTest,
ExpectState(AppState::CREATING_PROFILE, NetworkUIState::NOT_SHOWING); ExpectState(AppState::CREATING_PROFILE, NetworkUIState::NOT_SHOWING);
EXPECT_CALL(*launcher(), Initialize(_)).Times(1); EXPECT_CALL(*launcher(), Initialize(_)).Times(1);
session_controls()->OnProfilePrepared(profile(), false); profile_controls()->OnProfileLoaded(profile());
launch_controls()->InitializeNetwork(); launch_controls()->InitializeNetwork();
ExpectState(AppState::INIT_NETWORK, NetworkUIState::NOT_SHOWING); 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