Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: chrome/browser/chromeos/login/arc_kiosk_controller.cc

Issue 2649103006: arc: Add splash screen for ARC++ Kiosk startup (Closed)
Patch Set: fix build Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "base/time/time.h"
8 #include "chrome/browser/chromeos/login/auth/chrome_login_performer.h"
9 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
10 #include "chrome/browser/chromeos/login/ui/webui_login_view.h"
11 #include "chrome/browser/lifetime/application_lifetime.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
14 #include "chromeos/login/auth/user_context.h"
15 #include "components/session_manager/core/session_manager.h"
16 #include "components/signin/core/account_id/account_id.h"
17
18 namespace chromeos {
19
20 // ARC++ Kiosk splash screen minimum show time in milliseconds.
21 const int kArcKioskSplashScreenMinTimeMS = 3000;
Luis Héctor Chávez 2017/01/25 17:46:39 nit: constexpr base::TimeDelta kArcKioskSplashScr
Sergey Poromov 2017/01/26 17:08:52 Done.
22
23 ArcKioskController::ArcKioskController(LoginDisplayHost* host, OobeUI* oobe_ui)
24 : host_(host),
25 arc_kiosk_splash_screen_actor_(oobe_ui->GetArcKioskSplashScreenActor()) {}
26
27 ArcKioskController::~ArcKioskController() {
28 arc_kiosk_splash_screen_actor_->SetDelegate(nullptr);
29 }
30
31 void ArcKioskController::StartArcKiosk(const AccountId& account_id) {
32 DVLOG(1) << "Starting ARC Kiosk...";
33
34 host_->GetWebUILoginView()->SetUIEnabled(true);
35
36 arc_kiosk_splash_screen_actor_->SetDelegate(this);
37 arc_kiosk_splash_screen_actor_->Show();
38 launch_splash_start_time_ = base::TimeTicks::Now().ToInternalValue();
39
40 login_performer_ = base::MakeUnique<ChromeLoginPerformer>(this);
41 login_performer_->LoginAsArcKioskAccount(account_id);
42 }
43
44 void ArcKioskController::CleanUp() {
45 splash_wait_timer_.Stop();
46 // Delegate is registered only when |profile_| is set.
47 if (profile_)
48 ArcKioskAppService::Get(profile_)->SetDelegate(nullptr);
49 if (host_)
50 host_->Finalize();
51 }
52
53 void ArcKioskController::OnAuthFailure(const AuthFailure& error) {
54 LOG(ERROR) << "ARC Kiosk launch failed. Will now shut down, error="
55 << error.GetErrorString();
56 chrome::AttemptUserExit();
57 CleanUp();
58 }
59
60 void ArcKioskController::OnAuthSuccess(const UserContext& user_context) {
61 // LoginPerformer instance will delete itself in case of successful auth.
62 login_performer_->set_delegate(nullptr);
63 ignore_result(login_performer_.release());
64
65 UserSessionManager::GetInstance()->StartSession(
66 user_context, UserSessionManager::PRIMARY_USER_SESSION,
67 false, // has_auth_cookies
68 false, // Start session for user.
69 this);
70 }
71
72 void ArcKioskController::WhiteListCheckFailed(const std::string& email) {
73 NOTREACHED();
74 }
75
76 void ArcKioskController::PolicyLoadFailed() {
77 LOG(ERROR) << "Policy load failed. Will now shut down";
78 chrome::AttemptUserExit();
79 CleanUp();
80 }
81
82 void ArcKioskController::SetAuthFlowOffline(bool offline) {
83 NOTREACHED();
84 }
85
86 void ArcKioskController::OnProfilePrepared(Profile* profile,
87 bool browser_launched) {
88 DVLOG(1) << "Profile loaded... Starting app launch.";
89 profile_ = profile;
90 // This object could be deleted any time after successfully reporting
91 // a profile load, so invalidate the delegate now.
92 UserSessionManager::GetInstance()->DelegateDeleted(this);
93 ArcKioskAppService::Get(profile_)->SetDelegate(this);
94 arc_kiosk_splash_screen_actor_->UpdateArcKioskState(
95 ArcKioskSplashScreenActor::ARC_KIOSK_STATE_WAITING_APP_LAUNCH);
96 }
97
98 void ArcKioskController::OnAppStarted() {
99 DVLOG(1) << "ARC Kiosk launch succeeded, wait for app window.";
100 arc_kiosk_splash_screen_actor_->UpdateArcKioskState(
101 ArcKioskSplashScreenActor::ARC_KIOSK_STATE_WAITING_APP_WINDOW);
102 }
103
104 void ArcKioskController::OnAppWindowLaunched() {
105 DVLOG(1) << "App window created, closing splash screen.";
106
107 if (splash_wait_timer_.IsRunning())
108 return;
109 const int64_t time_taken_ms =
Luis Héctor Chávez 2017/01/25 17:46:40 nit: const base::TimeDelta delta = base::TimeTick
Sergey Poromov 2017/01/26 17:08:52 Done.
110 (base::TimeTicks::Now() -
111 base::TimeTicks::FromInternalValue(launch_splash_start_time_))
112 .InMilliseconds();
113 if (time_taken_ms < kArcKioskSplashScreenMinTimeMS) {
114 // Do not remove splash screen for a few more seconds
115 // to give the user ability to exit ARC++ kiosk.
116 splash_wait_timer_.Start(
Luis Héctor Chávez 2017/01/25 17:46:40 I wonder if it's cleaner overall to unconditionall
Sergey Poromov 2017/01/26 17:08:52 Done.
117 FROM_HERE, base::TimeDelta::FromMilliseconds(
118 kArcKioskSplashScreenMinTimeMS - time_taken_ms),
119 this, &ArcKioskController::OnAppWindowLaunched);
120 return;
121 }
122
123 CleanUp();
124 session_manager::SessionManager::Get()->SessionStarted();
125 }
126
127 void ArcKioskController::OnCancelArcKioskLaunch() {
128 chrome::AttemptUserExit();
129 CleanUp();
130 }
131
132 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698