OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/login/arc_kiosk_controller.h" | 5 #include "chrome/browser/chromeos/login/arc_kiosk_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
10 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" | 10 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" |
11 #include "chrome/browser/chromeos/login/auth/chrome_login_performer.h" | 11 #include "chrome/browser/chromeos/login/auth/chrome_login_performer.h" |
12 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 12 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
13 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" | 13 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" |
14 #include "chrome/browser/lifetime/application_lifetime.h" | 14 #include "chrome/browser/lifetime/application_lifetime.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 16 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
17 #include "chromeos/login/auth/user_context.h" | 17 #include "chromeos/login/auth/user_context.h" |
18 #include "components/session_manager/core/session_manager.h" | 18 #include "components/session_manager/core/session_manager.h" |
19 #include "components/signin/core/account_id/account_id.h" | 19 #include "components/signin/core/account_id/account_id.h" |
20 | 20 |
21 namespace chromeos { | 21 namespace chromeos { |
22 | 22 |
23 // ARC Kiosk splash screen minimum show time. | 23 // ARC Kiosk splash screen minimum show time. |
24 constexpr base::TimeDelta kArcKioskSplashScreenMinTime = | 24 constexpr base::TimeDelta kArcKioskSplashScreenMinTime = |
25 base::TimeDelta::FromSeconds(3); | 25 base::TimeDelta::FromSeconds(3); |
26 | 26 |
27 ArcKioskController::ArcKioskController(LoginDisplayHost* host, OobeUI* oobe_ui) | 27 ArcKioskController::ArcKioskController(LoginDisplayHost* host, OobeUI* oobe_ui) |
28 : host_(host), | 28 : host_(host), |
29 arc_kiosk_splash_screen_actor_(oobe_ui->GetArcKioskSplashScreenActor()), | 29 arc_kiosk_splash_screen_view_(oobe_ui->GetArcKioskSplashScreenView()), |
30 weak_ptr_factory_(this) {} | 30 weak_ptr_factory_(this) {} |
31 | 31 |
32 ArcKioskController::~ArcKioskController() { | 32 ArcKioskController::~ArcKioskController() { |
33 arc_kiosk_splash_screen_actor_->SetDelegate(nullptr); | 33 arc_kiosk_splash_screen_view_->SetDelegate(nullptr); |
34 } | 34 } |
35 | 35 |
36 void ArcKioskController::StartArcKiosk(const AccountId& account_id) { | 36 void ArcKioskController::StartArcKiosk(const AccountId& account_id) { |
37 DVLOG(1) << "Starting ARC Kiosk for account: " << account_id.GetUserEmail(); | 37 DVLOG(1) << "Starting ARC Kiosk for account: " << account_id.GetUserEmail(); |
38 | 38 |
39 host_->GetWebUILoginView()->SetUIEnabled(true); | 39 host_->GetWebUILoginView()->SetUIEnabled(true); |
40 | 40 |
41 arc_kiosk_splash_screen_actor_->SetDelegate(this); | 41 arc_kiosk_splash_screen_view_->SetDelegate(this); |
42 arc_kiosk_splash_screen_actor_->Show(); | 42 arc_kiosk_splash_screen_view_->Show(); |
43 splash_wait_timer_.Start(FROM_HERE, kArcKioskSplashScreenMinTime, | 43 splash_wait_timer_.Start(FROM_HERE, kArcKioskSplashScreenMinTime, |
44 base::Bind(&ArcKioskController::CloseSplashScreen, | 44 base::Bind(&ArcKioskController::CloseSplashScreen, |
45 weak_ptr_factory_.GetWeakPtr())); | 45 weak_ptr_factory_.GetWeakPtr())); |
46 | 46 |
47 login_performer_ = base::MakeUnique<ChromeLoginPerformer>(this); | 47 login_performer_ = base::MakeUnique<ChromeLoginPerformer>(this); |
48 login_performer_->LoginAsArcKioskAccount(account_id); | 48 login_performer_->LoginAsArcKioskAccount(account_id); |
49 } | 49 } |
50 | 50 |
51 void ArcKioskController::CleanUp() { | 51 void ArcKioskController::CleanUp() { |
52 splash_wait_timer_.Stop(); | 52 splash_wait_timer_.Stop(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 } | 100 } |
101 | 101 |
102 void ArcKioskController::OnProfilePrepared(Profile* profile, | 102 void ArcKioskController::OnProfilePrepared(Profile* profile, |
103 bool browser_launched) { | 103 bool browser_launched) { |
104 DVLOG(1) << "Profile loaded... Starting app launch."; | 104 DVLOG(1) << "Profile loaded... Starting app launch."; |
105 profile_ = profile; | 105 profile_ = profile; |
106 // This object could be deleted any time after successfully reporting | 106 // This object could be deleted any time after successfully reporting |
107 // a profile load, so invalidate the delegate now. | 107 // a profile load, so invalidate the delegate now. |
108 UserSessionManager::GetInstance()->DelegateDeleted(this); | 108 UserSessionManager::GetInstance()->DelegateDeleted(this); |
109 ArcKioskAppService::Get(profile_)->SetDelegate(this); | 109 ArcKioskAppService::Get(profile_)->SetDelegate(this); |
110 arc_kiosk_splash_screen_actor_->UpdateArcKioskState( | 110 arc_kiosk_splash_screen_view_->UpdateArcKioskState( |
111 ArcKioskSplashScreenActor::ArcKioskState::WAITING_APP_LAUNCH); | 111 ArcKioskSplashScreenView::ArcKioskState::WAITING_APP_LAUNCH); |
112 } | 112 } |
113 | 113 |
114 void ArcKioskController::OnAppStarted() { | 114 void ArcKioskController::OnAppStarted() { |
115 DVLOG(1) << "ARC Kiosk launch succeeded, wait for app window."; | 115 DVLOG(1) << "ARC Kiosk launch succeeded, wait for app window."; |
116 arc_kiosk_splash_screen_actor_->UpdateArcKioskState( | 116 arc_kiosk_splash_screen_view_->UpdateArcKioskState( |
117 ArcKioskSplashScreenActor::ArcKioskState::WAITING_APP_WINDOW); | 117 ArcKioskSplashScreenView::ArcKioskState::WAITING_APP_WINDOW); |
118 } | 118 } |
119 | 119 |
120 void ArcKioskController::OnAppWindowLaunched() { | 120 void ArcKioskController::OnAppWindowLaunched() { |
121 DVLOG(1) << "App window created, closing splash screen."; | 121 DVLOG(1) << "App window created, closing splash screen."; |
122 launched_ = true; | 122 launched_ = true; |
123 // If timer is running, do not remove splash screen for a few | 123 // If timer is running, do not remove splash screen for a few |
124 // more seconds to give the user ability to exit ARC kiosk. | 124 // more seconds to give the user ability to exit ARC kiosk. |
125 if (splash_wait_timer_.IsRunning()) | 125 if (splash_wait_timer_.IsRunning()) |
126 return; | 126 return; |
127 CloseSplashScreen(); | 127 CloseSplashScreen(); |
128 } | 128 } |
129 | 129 |
130 void ArcKioskController::OnCancelArcKioskLaunch() { | 130 void ArcKioskController::OnCancelArcKioskLaunch() { |
131 KioskAppLaunchError::Save(KioskAppLaunchError::USER_CANCEL); | 131 KioskAppLaunchError::Save(KioskAppLaunchError::USER_CANCEL); |
132 CleanUp(); | 132 CleanUp(); |
133 chrome::AttemptUserExit(); | 133 chrome::AttemptUserExit(); |
134 } | 134 } |
135 | 135 |
136 } // namespace chromeos | 136 } // namespace chromeos |
OLD | NEW |