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

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: lhchavez@ comments 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 "base/timer/timer.h"
9 #include "chrome/browser/chromeos/login/auth/chrome_login_performer.h"
10 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
11 #include "chrome/browser/chromeos/login/ui/webui_login_view.h"
12 #include "chrome/browser/lifetime/application_lifetime.h"
13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
15 #include "chromeos/login/auth/user_context.h"
16 #include "components/session_manager/core/session_manager.h"
17 #include "components/signin/core/account_id/account_id.h"
18
19 namespace chromeos {
20
21 // ARC++ Kiosk splash screen minimum show time.
22 constexpr base::TimeDelta kArcKioskSplashScreenMinTime =
23 base::TimeDelta::FromSeconds(3);
24
25 ArcKioskController::ArcKioskController(LoginDisplayHost* host, OobeUI* oobe_ui)
26 : host_(host),
27 arc_kiosk_splash_screen_actor_(oobe_ui->GetArcKioskSplashScreenActor()) {}
28
29 ArcKioskController::~ArcKioskController() {
30 arc_kiosk_splash_screen_actor_->SetDelegate(nullptr);
31 }
32
33 void ArcKioskController::StartArcKiosk(const AccountId& account_id) {
34 DVLOG(1) << "Starting ARC Kiosk...";
35
36 host_->GetWebUILoginView()->SetUIEnabled(true);
37
38 arc_kiosk_splash_screen_actor_->SetDelegate(this);
39 arc_kiosk_splash_screen_actor_->Show();
40 splash_wait_timer_.Start(FROM_HERE, kArcKioskSplashScreenMinTime, this,
Luis Héctor Chávez 2017/01/26 19:05:49 what about the base::Bind() part? That's important
Sergey Poromov 2017/01/26 21:09:39 Done. Thanks, I missed the part about Bind in your
41 &ArcKioskController::CloseSplashScreen);
42
43 login_performer_ = base::MakeUnique<ChromeLoginPerformer>(this);
44 login_performer_->LoginAsArcKioskAccount(account_id);
45 }
46
47 void ArcKioskController::CleanUp() {
48 splash_wait_timer_.Stop();
49 // Delegate is registered only when |profile_| is set.
50 if (profile_)
51 ArcKioskAppService::Get(profile_)->SetDelegate(nullptr);
52 if (host_)
53 host_->Finalize();
54 }
55
56 void ArcKioskController::CloseSplashScreen() {
57 if (!launched_)
58 return;
59 CleanUp();
60 session_manager::SessionManager::Get()->SessionStarted();
61 }
62
63 void ArcKioskController::OnAuthFailure(const AuthFailure& error) {
64 LOG(ERROR) << "ARC Kiosk launch failed. Will now shut down, error="
65 << error.GetErrorString();
66 chrome::AttemptUserExit();
67 CleanUp();
68 }
69
70 void ArcKioskController::OnAuthSuccess(const UserContext& user_context) {
71 // LoginPerformer instance will delete itself in case of successful auth.
72 login_performer_->set_delegate(nullptr);
73 ignore_result(login_performer_.release());
74
75 UserSessionManager::GetInstance()->StartSession(
76 user_context, UserSessionManager::PRIMARY_USER_SESSION,
77 false, // has_auth_cookies
78 false, // Start session for user.
79 this);
80 }
81
82 void ArcKioskController::WhiteListCheckFailed(const std::string& email) {
83 NOTREACHED();
84 }
85
86 void ArcKioskController::PolicyLoadFailed() {
87 LOG(ERROR) << "Policy load failed. Will now shut down";
88 chrome::AttemptUserExit();
89 CleanUp();
90 }
91
92 void ArcKioskController::SetAuthFlowOffline(bool offline) {
93 NOTREACHED();
94 }
95
96 void ArcKioskController::OnProfilePrepared(Profile* profile,
97 bool browser_launched) {
98 DVLOG(1) << "Profile loaded... Starting app launch.";
99 profile_ = profile;
100 // This object could be deleted any time after successfully reporting
101 // a profile load, so invalidate the delegate now.
102 UserSessionManager::GetInstance()->DelegateDeleted(this);
103 ArcKioskAppService::Get(profile_)->SetDelegate(this);
104 arc_kiosk_splash_screen_actor_->UpdateArcKioskState(
105 ArcKioskSplashScreenActor::ArcKioskState::WAITING_APP_LAUNCH);
106 }
107
108 void ArcKioskController::OnAppStarted() {
109 DVLOG(1) << "ARC Kiosk launch succeeded, wait for app window.";
110 arc_kiosk_splash_screen_actor_->UpdateArcKioskState(
111 ArcKioskSplashScreenActor::ArcKioskState::WAITING_APP_WINDOW);
112 }
113
114 void ArcKioskController::OnAppWindowLaunched() {
115 DVLOG(1) << "App window created, closing splash screen.";
116 launched_ = true;
117 if (splash_wait_timer_.IsRunning())
118 return;
119 CloseSplashScreen();
120 }
121
122 void ArcKioskController::OnCancelArcKioskLaunch() {
123 chrome::AttemptUserExit();
124 CleanUp();
125 }
126
127 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/arc_kiosk_controller.h ('k') | chrome/browser/chromeos/login/existing_user_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698