Chromium Code Reviews| Index: chrome/browser/chromeos/login/arc_kiosk_controller.cc |
| diff --git a/chrome/browser/chromeos/login/arc_kiosk_controller.cc b/chrome/browser/chromeos/login/arc_kiosk_controller.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..07895fe4dc7ba2db15d0fc7aa4bed9d1a04a61f5 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/login/arc_kiosk_controller.cc |
| @@ -0,0 +1,106 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/chromeos/login/arc_kiosk_controller.h" |
| + |
| +#include "chrome/browser/chromeos/login/auth/chrome_login_performer.h" |
| +#include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| +#include "chrome/browser/chromeos/login/ui/webui_login_view.h" |
| +#include "chrome/browser/lifetime/application_lifetime.h" |
| +#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| +#include "components/session_manager/core/session_manager.h" |
| + |
| +namespace chromeos { |
| + |
| +ArcKioskController::ArcKioskController(LoginDisplayHost* host, OobeUI* oobe_ui) |
| + : host_(host), |
| + oobe_ui_(oobe_ui), |
| + arc_kiosk_splash_screen_actor_(oobe_ui_->GetArcKioskSplashScreenActor()) { |
| +} |
| + |
| +ArcKioskController::~ArcKioskController() { |
| + arc_kiosk_splash_screen_actor_->SetDelegate(nullptr); |
| +} |
| + |
| +void ArcKioskController::StartArcKiosk(const AccountId& account_id) { |
| + DVLOG(1) << "Starting ARC Kiosk..."; |
| + |
| + host_->GetWebUILoginView()->SetUIEnabled(true); |
| + |
| + arc_kiosk_splash_screen_actor_->SetDelegate(this); |
| + arc_kiosk_splash_screen_actor_->Show(); |
| + |
| + login_performer_.reset(new ChromeLoginPerformer(this)); |
|
Luis Héctor Chávez
2017/01/24 18:40:24
nit: login_performer_ = base::MakeUnique<ChromeLog
Sergey Poromov
2017/01/25 14:29:21
Done.
|
| + login_performer_->LoginAsArcKioskAccount(account_id); |
| +} |
| + |
| +void ArcKioskController::CleanUp() { |
| + ArcKioskAppService::Get(profile_)->SetDelegate(nullptr); |
|
Luis Héctor Chávez
2017/01/24 18:40:24
Can |profile_| be nullptr?
Sergey Poromov
2017/01/25 14:29:21
Done.
|
| + if (host_) |
| + host_->Finalize(); |
| +} |
| + |
| +void ArcKioskController::OnAuthFailure(const AuthFailure& error) { |
| + LOG(ERROR) << "ARC Kiosk launch failed. Will now shut down, error=" |
| + << error.GetErrorString(); |
| + chrome::AttemptUserExit(); |
| + CleanUp(); |
| +} |
| + |
| +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"; |
| + chrome::AttemptUserExit(); |
| + CleanUp(); |
| +} |
| + |
| +void ArcKioskController::SetAuthFlowOffline(bool offline) { |
| + NOTREACHED(); |
| +} |
| + |
| +void ArcKioskController::OnProfilePrepared(Profile* profile, |
| + bool browser_launched) { |
| + 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); |
| + arc_kiosk_splash_screen_actor_->UpdateArcKioskState( |
| + ArcKioskSplashScreenActor::ARC_KIOSK_STATE_WAITING_APP_LAUNCH); |
| +} |
| + |
| +void ArcKioskController::OnAppStarted() { |
| + DVLOG(1) << "ARC Kiosk launch succeeded, wait for app window."; |
| + arc_kiosk_splash_screen_actor_->UpdateArcKioskState( |
| + ArcKioskSplashScreenActor::ARC_KIOSK_STATE_WAITING_APP_WINDOW); |
| +} |
| + |
| +void ArcKioskController::OnAppWindowLaunched() { |
| + DVLOG(1) << "App window created, closing splash screen."; |
| + CleanUp(); |
| + session_manager::SessionManager::Get()->SessionStarted(); |
| +} |
| + |
| +void ArcKioskController::OnCancelArcKioskLaunch() { |
| + chrome::AttemptUserExit(); |
| + CleanUp(); |
| +} |
| + |
| +} // namespace chromeos |