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

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