Chromium Code Reviews| OLD | NEW | 
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/chromeos/login/arc_kiosk_controller.h" | |
| 6 | |
| 7 #include "chrome/browser/chromeos/login/auth/chrome_login_performer.h" | |
| 8 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | |
| 9 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" | |
| 10 #include "chrome/browser/lifetime/application_lifetime.h" | |
| 11 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | |
| 12 #include "components/session_manager/core/session_manager.h" | |
| 13 | |
| 14 namespace chromeos { | |
| 15 | |
| 16 ArcKioskController::ArcKioskController(LoginDisplayHost* host, OobeUI* oobe_ui) | |
| 17 : host_(host), | |
| 18 oobe_ui_(oobe_ui), | |
| 19 arc_kiosk_splash_screen_actor_(oobe_ui_->GetArcKioskSplashScreenActor()) { | |
| 20 } | |
| 21 | |
| 22 ArcKioskController::~ArcKioskController() { | |
| 23 arc_kiosk_splash_screen_actor_->SetDelegate(nullptr); | |
| 24 } | |
| 25 | |
| 26 void ArcKioskController::StartArcKiosk(const AccountId& account_id) { | |
| 27 DVLOG(1) << "Starting ARC Kiosk..."; | |
| 28 | |
| 29 host_->GetWebUILoginView()->SetUIEnabled(true); | |
| 30 | |
| 31 arc_kiosk_splash_screen_actor_->SetDelegate(this); | |
| 32 arc_kiosk_splash_screen_actor_->Show(); | |
| 33 | |
| 34 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.
 
 | |
| 35 login_performer_->LoginAsArcKioskAccount(account_id); | |
| 36 } | |
| 37 | |
| 38 void ArcKioskController::CleanUp() { | |
| 39 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.
 
 | |
| 40 if (host_) | |
| 41 host_->Finalize(); | |
| 42 } | |
| 43 | |
| 44 void ArcKioskController::OnAuthFailure(const AuthFailure& error) { | |
| 45 LOG(ERROR) << "ARC Kiosk launch failed. Will now shut down, error=" | |
| 46 << error.GetErrorString(); | |
| 47 chrome::AttemptUserExit(); | |
| 48 CleanUp(); | |
| 49 } | |
| 50 | |
| 51 void ArcKioskController::OnAuthSuccess(const UserContext& user_context) { | |
| 52 // LoginPerformer instance will delete itself in case of successful auth. | |
| 53 login_performer_->set_delegate(nullptr); | |
| 54 ignore_result(login_performer_.release()); | |
| 55 | |
| 56 UserSessionManager::GetInstance()->StartSession( | |
| 57 user_context, UserSessionManager::PRIMARY_USER_SESSION, | |
| 58 false, // has_auth_cookies | |
| 59 false, // Start session for user. | |
| 60 this); | |
| 61 } | |
| 62 | |
| 63 void ArcKioskController::WhiteListCheckFailed(const std::string& email) { | |
| 64 NOTREACHED(); | |
| 65 } | |
| 66 | |
| 67 void ArcKioskController::PolicyLoadFailed() { | |
| 68 LOG(ERROR) << "Policy load failed. Will now shut down"; | |
| 69 chrome::AttemptUserExit(); | |
| 70 CleanUp(); | |
| 71 } | |
| 72 | |
| 73 void ArcKioskController::SetAuthFlowOffline(bool offline) { | |
| 74 NOTREACHED(); | |
| 75 } | |
| 76 | |
| 77 void ArcKioskController::OnProfilePrepared(Profile* profile, | |
| 78 bool browser_launched) { | |
| 79 DVLOG(1) << "Profile loaded... Starting app launch."; | |
| 80 profile_ = profile; | |
| 81 // This object could be deleted any time after successfully reporting | |
| 82 // a profile load, so invalidate the delegate now. | |
| 83 UserSessionManager::GetInstance()->DelegateDeleted(this); | |
| 84 ArcKioskAppService::Get(profile_)->SetDelegate(this); | |
| 85 arc_kiosk_splash_screen_actor_->UpdateArcKioskState( | |
| 86 ArcKioskSplashScreenActor::ARC_KIOSK_STATE_WAITING_APP_LAUNCH); | |
| 87 } | |
| 88 | |
| 89 void ArcKioskController::OnAppStarted() { | |
| 90 DVLOG(1) << "ARC Kiosk launch succeeded, wait for app window."; | |
| 91 arc_kiosk_splash_screen_actor_->UpdateArcKioskState( | |
| 92 ArcKioskSplashScreenActor::ARC_KIOSK_STATE_WAITING_APP_WINDOW); | |
| 93 } | |
| 94 | |
| 95 void ArcKioskController::OnAppWindowLaunched() { | |
| 96 DVLOG(1) << "App window created, closing splash screen."; | |
| 97 CleanUp(); | |
| 98 session_manager::SessionManager::Get()->SessionStarted(); | |
| 99 } | |
| 100 | |
| 101 void ArcKioskController::OnCancelArcKioskLaunch() { | |
| 102 chrome::AttemptUserExit(); | |
| 103 CleanUp(); | |
| 104 } | |
| 105 | |
| 106 } // namespace chromeos | |
| OLD | NEW |