Commit 12e5c890 authored by Anatoliy Potapchuk's avatar Anatoliy Potapchuk Committed by Commit Bot

[Kiosk] Make ArcKioskService behave like KioskAppLauncher

Bug: 1015383
Change-Id: I271647c5c47b568805ee1623c24823f92574737d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2246562
Commit-Queue: Anatoliy Potapchuk <apotapchuk@chromium.org>
Reviewed-by: default avatarAnqing Zhao <anqing@chromium.org>
Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779765}
parent 6164d2ca
......@@ -41,10 +41,6 @@ ArcKioskAppService* ArcKioskAppService::Get(content::BrowserContext* context) {
return ArcKioskAppServiceFactory::GetForBrowserContext(context);
}
void ArcKioskAppService::SetDelegate(Delegate* delegate) {
delegate_ = delegate;
}
void ArcKioskAppService::Shutdown() {
ArcAppListPrefs::Get(profile_)->RemoveObserver(this);
arc::ArcSessionManager::Get()->RemoveObserver(this);
......@@ -86,7 +82,7 @@ void ArcKioskAppService::OnTaskCreated(int32_t task_id,
activity == app_info_->activity) {
task_id_ = task_id;
if (delegate_)
delegate_->OnAppStarted();
delegate_->OnAppLaunched();
}
}
......@@ -119,7 +115,7 @@ void ArcKioskAppService::OnMaintenanceSessionFinished() {
void ArcKioskAppService::OnAppWindowLaunched() {
if (delegate_)
delegate_->OnAppWindowLaunched();
delegate_->OnAppWindowCreated();
}
void ArcKioskAppService::OnIconUpdated(ArcAppIcon* icon) {
......@@ -226,6 +222,7 @@ void ArcKioskAppService::PreconditionsChanged() {
pending_policy_app_installs_.count(app_info_->package_name) == 0) {
if (!app_launcher_) {
VLOG(2) << "Starting kiosk app";
delegate_->OnAppPrepared();
app_launcher_ = std::make_unique<ArcKioskAppLauncher>(
profile_, ArcAppListPrefs::Get(profile_), app_id_, this);
}
......@@ -257,4 +254,10 @@ void ArcKioskAppService::ResetAppLauncher() {
task_id_ = -1;
}
// ArcKioskAppService manages his own state by itself.
void ArcKioskAppService::Initialize() {}
void ArcKioskAppService::ContinueWithNetworkReady() {}
void ArcKioskAppService::RestartLauncher() {}
void ArcKioskAppService::LaunchApp() {}
} // namespace chromeos
......@@ -9,6 +9,7 @@
#include "base/macros.h"
#include "base/timer/timer.h"
#include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_launcher.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_launcher.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_manager_observer.h"
#include "chrome/browser/chromeos/arc/kiosk/arc_kiosk_bridge.h"
#include "chrome/browser/chromeos/arc/policy/arc_policy_bridge.h"
......@@ -40,27 +41,12 @@ class ArcKioskAppService : public KeyedService,
public ArcKioskAppLauncher::Delegate,
public ArcAppIcon::Observer,
public arc::ArcSessionManager::Observer,
public arc::ArcPolicyBridge::Observer {
public arc::ArcPolicyBridge::Observer,
public KioskAppLauncher {
public:
class Delegate {
public:
Delegate() = default;
virtual void OnAppDataUpdated() = 0;
virtual void OnAppStarted() = 0;
virtual void OnAppWindowLaunched() = 0;
protected:
virtual ~Delegate() = default;
private:
DISALLOW_COPY_AND_ASSIGN(Delegate);
};
static ArcKioskAppService* Create(Profile* profile);
static ArcKioskAppService* Get(content::BrowserContext* context);
void SetDelegate(Delegate* delegate);
// KeyedService overrides
void Shutdown() override;
......@@ -97,6 +83,12 @@ class ArcKioskAppService : public KeyedService,
void OnComplianceReportReceived(
const base::Value* compliance_report) override;
// KioskAppLauncher:
void Initialize() override;
void ContinueWithNetworkReady() override;
void RestartLauncher() override;
void LaunchApp() override;
private:
explicit ArcKioskAppService(Profile* profile);
~ArcKioskAppService() override;
......@@ -127,8 +119,6 @@ class ArcKioskAppService : public KeyedService,
bool compliance_report_received_ = false;
// Keeps track whether the app is already launched
std::unique_ptr<ArcKioskAppLauncher> app_launcher_;
// Not owning the delegate, delegate removes itself in destructor
Delegate* delegate_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(ArcKioskAppService);
};
......
......@@ -6,7 +6,13 @@
namespace chromeos {
KioskAppLauncher::KioskAppLauncher() = default;
KioskAppLauncher::KioskAppLauncher(KioskAppLauncher::Delegate* delegate)
: delegate_(delegate) {}
void KioskAppLauncher::SetDelegate(Delegate* delegate) {
delegate_ = delegate;
}
} // namespace chromeos
......@@ -40,6 +40,7 @@ class KioskAppLauncher {
// Whether app launch flow can assume all required apps are installed, and
// skip app installation steps.
virtual bool ShouldSkipAppInstallation() const = 0;
virtual void OnAppDataUpdated() {}
virtual void OnAppInstalling() {}
virtual void OnAppPrepared() {}
virtual void OnAppLaunched() {}
......@@ -49,10 +50,13 @@ class KioskAppLauncher {
protected:
virtual ~Delegate() {}
};
KioskAppLauncher();
explicit KioskAppLauncher(Delegate* delegate);
KioskAppLauncher(const KioskAppLauncher&) = delete;
KioskAppLauncher& operator=(const KioskAppLauncher&) = delete;
virtual ~KioskAppLauncher() = default;
void SetDelegate(Delegate* delegate);
// Determine the initial configuration.
virtual void Initialize() = 0;
// This has to be called after launcher asked to configure network.
......@@ -63,7 +67,7 @@ class KioskAppLauncher {
virtual void LaunchApp() = 0;
protected:
Delegate* const delegate_; // Not owned, owns us.
Delegate* delegate_ = nullptr; // Not owned, owns us.
};
} // namespace chromeos
......
......@@ -130,7 +130,7 @@ void ArcKioskController::OnAppDataUpdated() {
arc_kiosk_splash_screen_view_->Show();
}
void ArcKioskController::OnAppStarted() {
void ArcKioskController::OnAppLaunched() {
DVLOG(1) << "ARC Kiosk launch succeeded, wait for app window.";
if (arc_kiosk_splash_screen_view_) {
......@@ -142,7 +142,7 @@ void ArcKioskController::OnAppStarted() {
}
}
void ArcKioskController::OnAppWindowLaunched() {
void ArcKioskController::OnAppWindowCreated() {
DVLOG(1) << "App window created, closing splash screen.";
launched_ = true;
// If timer is running, do not remove splash screen for a few
......@@ -161,4 +161,19 @@ KioskAppManagerBase::App ArcKioskController::GetAppData() {
return app;
}
// TODO(crbug.com/1015383): Add network handling logic for arc kiosk.
void ArcKioskController::InitializeNetwork() {}
bool ArcKioskController::IsNetworkReady() const {
return true;
}
bool ArcKioskController::IsShowingNetworkConfigScreen() const {
return false;
}
bool ArcKioskController::ShouldSkipAppInstallation() const {
return false;
}
} // namespace chromeos
......@@ -30,11 +30,10 @@ class UserContext;
// coordinating loading the ARC kiosk profile, and
// updating the splash screen UI.
class ArcKioskController : public KioskProfileLoader::Delegate,
public ArcKioskAppService::Delegate,
public KioskAppLauncher::Delegate,
public AppLaunchSplashScreenView::Delegate {
public:
ArcKioskController(LoginDisplayHost* host, OobeUI* oobe_ui);
~ArcKioskController() override;
// Starts ARC kiosk splash screen.
......@@ -44,17 +43,21 @@ class ArcKioskController : public KioskProfileLoader::Delegate,
void CleanUp();
void CloseSplashScreen();
// KioskProfileLoader implementation:
// KioskProfileLoader:
void OnProfileLoaded(Profile* profile) override;
void OnProfileLoadFailed(KioskAppLaunchError::Error error) override;
void OnOldEncryptionDetected(const UserContext& user_context) override;
// ArcKioskAppService::Delegate implementation:
// KioskAppLauncher::Delegate:
void InitializeNetwork() override;
bool IsNetworkReady() const override;
bool IsShowingNetworkConfigScreen() const override;
bool ShouldSkipAppInstallation() const override;
void OnAppDataUpdated() override;
void OnAppStarted() override;
void OnAppWindowLaunched() override;
void OnAppLaunched() override;
void OnAppWindowCreated() override;
// AppLaunchSplashScreenView::Delegate implementation:
// AppLaunchSplashScreenView::Delegate:
KioskAppManagerBase::App GetAppData() override;
void OnCancelAppLaunch() override;
void OnDeletingSplashScreenView() override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment