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

Unified 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, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/arc_kiosk_controller.cc
diff --git a/chrome/browser/chromeos/login/arc_kiosk_controller.cc b/chrome/browser/chromeos/login/arc_kiosk_controller.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ff7be12ac529de7a81d680475831b1804b1a2a41
--- /dev/null
+++ b/chrome/browser/chromeos/login/arc_kiosk_controller.cc
@@ -0,0 +1,127 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/login/arc_kiosk_controller.h"
+
+#include "base/time/time.h"
+#include "base/timer/timer.h"
+#include "chrome/browser/chromeos/login/auth/chrome_login_performer.h"
+#include "chrome/browser/chromeos/login/ui/login_display_host.h"
+#include "chrome/browser/chromeos/login/ui/webui_login_view.h"
+#include "chrome/browser/lifetime/application_lifetime.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
+#include "chromeos/login/auth/user_context.h"
+#include "components/session_manager/core/session_manager.h"
+#include "components/signin/core/account_id/account_id.h"
+
+namespace chromeos {
+
+// ARC++ Kiosk splash screen minimum show time.
+constexpr base::TimeDelta kArcKioskSplashScreenMinTime =
+ base::TimeDelta::FromSeconds(3);
+
+ArcKioskController::ArcKioskController(LoginDisplayHost* host, OobeUI* oobe_ui)
+ : host_(host),
+ arc_kiosk_splash_screen_actor_(oobe_ui->GetArcKioskSplashScreenActor()) {}
+
+ArcKioskController::~ArcKioskController() {
+ arc_kiosk_splash_screen_actor_->SetDelegate(nullptr);
+}
+
+void ArcKioskController::StartArcKiosk(const AccountId& account_id) {
+ DVLOG(1) << "Starting ARC Kiosk...";
+
+ host_->GetWebUILoginView()->SetUIEnabled(true);
+
+ arc_kiosk_splash_screen_actor_->SetDelegate(this);
+ arc_kiosk_splash_screen_actor_->Show();
+ 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
+ &ArcKioskController::CloseSplashScreen);
+
+ login_performer_ = base::MakeUnique<ChromeLoginPerformer>(this);
+ login_performer_->LoginAsArcKioskAccount(account_id);
+}
+
+void ArcKioskController::CleanUp() {
+ splash_wait_timer_.Stop();
+ // Delegate is registered only when |profile_| is set.
+ if (profile_)
+ ArcKioskAppService::Get(profile_)->SetDelegate(nullptr);
+ if (host_)
+ host_->Finalize();
+}
+
+void ArcKioskController::CloseSplashScreen() {
+ if (!launched_)
+ return;
+ CleanUp();
+ session_manager::SessionManager::Get()->SessionStarted();
+}
+
+void ArcKioskController::OnAuthFailure(const AuthFailure& error) {
+ LOG(ERROR) << "ARC Kiosk launch failed. Will now shut down, error="
+ << error.GetErrorString();
+ chrome::AttemptUserExit();
+ CleanUp();
+}
+
+void ArcKioskController::OnAuthSuccess(const UserContext& user_context) {
+ // LoginPerformer instance will delete itself in case of successful auth.
+ login_performer_->set_delegate(nullptr);
+ ignore_result(login_performer_.release());
+
+ UserSessionManager::GetInstance()->StartSession(
+ user_context, UserSessionManager::PRIMARY_USER_SESSION,
+ false, // has_auth_cookies
+ false, // Start session for user.
+ this);
+}
+
+void ArcKioskController::WhiteListCheckFailed(const std::string& email) {
+ NOTREACHED();
+}
+
+void ArcKioskController::PolicyLoadFailed() {
+ LOG(ERROR) << "Policy load failed. Will now shut down";
+ chrome::AttemptUserExit();
+ CleanUp();
+}
+
+void ArcKioskController::SetAuthFlowOffline(bool offline) {
+ NOTREACHED();
+}
+
+void ArcKioskController::OnProfilePrepared(Profile* profile,
+ bool browser_launched) {
+ DVLOG(1) << "Profile loaded... Starting app launch.";
+ profile_ = profile;
+ // This object could be deleted any time after successfully reporting
+ // a profile load, so invalidate the delegate now.
+ UserSessionManager::GetInstance()->DelegateDeleted(this);
+ ArcKioskAppService::Get(profile_)->SetDelegate(this);
+ arc_kiosk_splash_screen_actor_->UpdateArcKioskState(
+ ArcKioskSplashScreenActor::ArcKioskState::WAITING_APP_LAUNCH);
+}
+
+void ArcKioskController::OnAppStarted() {
+ DVLOG(1) << "ARC Kiosk launch succeeded, wait for app window.";
+ arc_kiosk_splash_screen_actor_->UpdateArcKioskState(
+ ArcKioskSplashScreenActor::ArcKioskState::WAITING_APP_WINDOW);
+}
+
+void ArcKioskController::OnAppWindowLaunched() {
+ DVLOG(1) << "App window created, closing splash screen.";
+ launched_ = true;
+ if (splash_wait_timer_.IsRunning())
+ return;
+ CloseSplashScreen();
+}
+
+void ArcKioskController::OnCancelArcKioskLaunch() {
+ chrome::AttemptUserExit();
+ CleanUp();
+}
+
+} // namespace chromeos
« 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