Skip to content

Commit

Permalink
cros: Eliminate ArcKioskSplashScreenView::Delegate
Browse files Browse the repository at this point in the history
Also move ArcKioskSplashScreenView into arc_kiosk_splash_screen_handler.h.

Bug: 928555
Change-Id: I5f95c23cb11fa91e5a2380d4ab1e67fe50576971
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1566611
Commit-Queue: Jacob Dufault <jdufault@chromium.org>
Reviewed-by: Toni Baržić <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652353}
  • Loading branch information
jacobdufault-google authored and Commit Bot committed Apr 18, 2019
1 parent 61d3755 commit 08a2676
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 86 deletions.
1 change: 0 additions & 1 deletion chrome/browser/chromeos/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,6 @@ source_set("chromeos") {
"login/screen_manager.h",
"login/screens/app_downloading_screen.cc",
"login/screens/app_downloading_screen.h",
"login/screens/arc_kiosk_splash_screen_view.h",
"login/screens/arc_terms_of_service_screen.cc",
"login/screens/arc_terms_of_service_screen.h",
"login/screens/arc_terms_of_service_screen_view.h",
Expand Down
21 changes: 11 additions & 10 deletions chrome/browser/chromeos/login/arc_kiosk_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chromeos/login/arc_kiosk_splash_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
#include "chromeos/login/auth/user_context.h"
#include "components/account_id/account_id.h"
Expand Down Expand Up @@ -53,6 +54,16 @@ void ArcKioskController::StartArcKiosk(const AccountId& account_id) {
login_performer_->LoginAsArcKioskAccount(account_id);
}

void ArcKioskController::OnCancelArcKioskLaunch() {
KioskAppLaunchError::Save(KioskAppLaunchError::USER_CANCEL);
CleanUp();
chrome::AttemptUserExit();
}

void ArcKioskController::OnDeletingSplashScreenView() {
arc_kiosk_splash_screen_view_ = nullptr;
}

void ArcKioskController::CleanUp() {
splash_wait_timer_.Stop();
// Delegate is registered only when |profile_| is set.
Expand Down Expand Up @@ -149,14 +160,4 @@ void ArcKioskController::OnAppWindowLaunched() {
CloseSplashScreen();
}

void ArcKioskController::OnCancelArcKioskLaunch() {
KioskAppLaunchError::Save(KioskAppLaunchError::USER_CANCEL);
CleanUp();
chrome::AttemptUserExit();
}

void ArcKioskController::OnDeletingSplashScreenView() {
arc_kiosk_splash_screen_view_ = nullptr;
}

} // namespace chromeos
14 changes: 7 additions & 7 deletions chrome/browser/chromeos/login/arc_kiosk_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.h"
#include "chrome/browser/chromeos/login/screens/arc_kiosk_splash_screen_view.h"
#include "chrome/browser/chromeos/login/session/user_session_manager.h"
#include "chromeos/login/auth/login_performer.h"

Expand All @@ -21,6 +20,7 @@ class OneShotTimer;

namespace chromeos {

class ArcKioskSplashScreenView;
class LoginDisplayHost;
class OobeUI;
class UserContext;
Expand All @@ -30,8 +30,7 @@ class UserContext;
// updating the splash screen UI.
class ArcKioskController : public LoginPerformer::Delegate,
public UserSessionManagerDelegate,
public ArcKioskAppService::Delegate,
public ArcKioskSplashScreenView::Delegate {
public ArcKioskAppService::Delegate {
public:
ArcKioskController(LoginDisplayHost* host, OobeUI* oobe_ui);

Expand All @@ -40,6 +39,11 @@ class ArcKioskController : public LoginPerformer::Delegate,
// Starts ARC kiosk splash screen.
void StartArcKiosk(const AccountId& account_id);

// Invoked when the launch bailout shortcut key is pressed.
void OnCancelArcKioskLaunch();
// Invoked when the splash screen view gets being deleted.
void OnDeletingSplashScreenView();

private:
void CleanUp();
void CloseSplashScreen();
Expand All @@ -60,10 +64,6 @@ class ArcKioskController : public LoginPerformer::Delegate,
void OnAppStarted() override;
void OnAppWindowLaunched() override;

// ArcKioskSplashScreenView::Delegate implementation:
void OnCancelArcKioskLaunch() override;
void OnDeletingSplashScreenView() override;

// LoginDisplayHost owns itself.
LoginDisplayHost* const host_;
// Owned by OobeUI.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <memory>

#include "base/values.h"
#include "chrome/browser/chromeos/login/arc_kiosk_controller.h"
#include "chrome/grit/chrome_unscaled_resources.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
Expand All @@ -23,8 +24,8 @@ ArcKioskSplashScreenHandler::ArcKioskSplashScreenHandler(
: BaseScreenHandler(kScreenId, js_calls_container) {}

ArcKioskSplashScreenHandler::~ArcKioskSplashScreenHandler() {
if (delegate_)
delegate_->OnDeletingSplashScreenView();
if (controller_)
controller_->OnDeletingSplashScreenView();
}

void ArcKioskSplashScreenHandler::DeclareLocalizedValues(
Expand Down Expand Up @@ -72,9 +73,8 @@ void ArcKioskSplashScreenHandler::UpdateArcKioskState(ArcKioskState state) {
SetLaunchText(l10n_util::GetStringUTF8(GetProgressMessageFromState(state)));
}

void ArcKioskSplashScreenHandler::SetDelegate(
ArcKioskSplashScreenHandler::Delegate* delegate) {
delegate_ = delegate;
void ArcKioskSplashScreenHandler::SetDelegate(ArcKioskController* controller) {
controller_ = controller;
}

void ArcKioskSplashScreenHandler::PopulateAppInfo(
Expand Down Expand Up @@ -108,11 +108,11 @@ int ArcKioskSplashScreenHandler::GetProgressMessageFromState(
}

void ArcKioskSplashScreenHandler::HandleCancelArcKioskLaunch() {
if (!delegate_) {
if (!controller_) {
LOG(WARNING) << "No delegate set to handle cancel app launch";
return;
}
delegate_->OnCancelArcKioskLaunch();
controller_->OnCancelArcKioskLaunch();
}

} // namespace chromeos
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <string>

#include "base/macros.h"
#include "chrome/browser/chromeos/login/screens/arc_kiosk_splash_screen_view.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"

namespace base {
Expand All @@ -17,6 +16,36 @@ class DictionaryValue;

namespace chromeos {

class ArcKioskController;

// Interface for UI implementations of the ArcKioskSplashScreen.
class ArcKioskSplashScreenView {
public:
enum class ArcKioskState {
STARTING_SESSION,
WAITING_APP_LAUNCH,
WAITING_APP_WINDOW,
};

constexpr static OobeScreen kScreenId = OobeScreen::SCREEN_ARC_KIOSK_SPLASH;

ArcKioskSplashScreenView() = default;

virtual ~ArcKioskSplashScreenView() = default;

// Shows the contents of the screen.
virtual void Show() = 0;

// Set the current ARC kiosk state.
virtual void UpdateArcKioskState(ArcKioskState state) = 0;

// Sets screen this view belongs to.
virtual void SetDelegate(ArcKioskController* controller) = 0;

private:
DISALLOW_COPY_AND_ASSIGN(ArcKioskSplashScreenView);
};

// A class that handles the WebUI hooks for the ARC kiosk splash screen.
class ArcKioskSplashScreenHandler : public BaseScreenHandler,
public ArcKioskSplashScreenView {
Expand All @@ -36,14 +65,14 @@ class ArcKioskSplashScreenHandler : public BaseScreenHandler,
// ArcKioskSplashScreenView implementation:
void Show() override;
void UpdateArcKioskState(ArcKioskState state) override;
void SetDelegate(ArcKioskSplashScreenHandler::Delegate* delegate) override;
void SetDelegate(ArcKioskController* controller) override;

void PopulateAppInfo(base::DictionaryValue* out_info);
void SetLaunchText(const std::string& text);
int GetProgressMessageFromState(ArcKioskState state);
void HandleCancelArcKioskLaunch();

ArcKioskSplashScreenHandler::Delegate* delegate_ = nullptr;
ArcKioskController* controller_ = nullptr;
bool show_on_init_ = false;

DISALLOW_COPY_AND_ASSIGN(ArcKioskSplashScreenHandler);
Expand Down

0 comments on commit 08a2676

Please sign in to comment.