Chromium Code Reviews| Index: chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.cc |
| diff --git a/chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.cc b/chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.cc |
| index 15fac5c20c61733a22f5e192b1492993d9863a3d..4182f0b027d55a162115388e4448ebfb3c01e653 100644 |
| --- a/chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.cc |
| +++ b/chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.cc |
| @@ -24,6 +24,10 @@ ArcKioskAppService* ArcKioskAppService::Get(content::BrowserContext* context) { |
| return ArcKioskAppServiceFactory::GetForBrowserContext(context); |
| } |
| +void ArcKioskAppService::SetDelegate(Delegate* delegate) { |
| + delegate_ = delegate; |
|
Luis Héctor Chávez
2017/01/24 18:40:24
nit: DCHECK(delegate);
Do you also want to DCHECK
Sergey Poromov
2017/01/25 14:29:21
This |delegate| could be null to unregister it.
No
|
| +} |
| + |
| void ArcKioskAppService::Shutdown() { |
| ArcAppListPrefs::Get(profile_)->RemoveObserver(this); |
| app_manager_->RemoveObserver(this); |
| @@ -32,10 +36,14 @@ void ArcKioskAppService::Shutdown() { |
| void ArcKioskAppService::OnAppRegistered( |
| const std::string& app_id, |
| const ArcAppListPrefs::AppInfo& app_info) { |
| + if (!app_id_.empty() && app_id != app_id_) |
| + return; |
| PreconditionsChanged(); |
| } |
| void ArcKioskAppService::OnAppReadyChanged(const std::string& id, bool ready) { |
| + if (!app_id_.empty() && id != app_id_) |
| + return; |
| PreconditionsChanged(); |
| } |
| @@ -56,6 +64,8 @@ void ArcKioskAppService::OnTaskCreated(int32_t task_id, |
| if (app_info_ && package_name == app_info_->package_name && |
| activity == app_info_->activity) { |
| task_id_ = task_id; |
| + if (delegate_) |
| + delegate_->OnAppStarted(); |
| } |
| } |
| @@ -79,6 +89,11 @@ void ArcKioskAppService::OnMaintenanceSessionFinished() { |
| PreconditionsChanged(); |
| } |
| +void ArcKioskAppService::OnAppWindowLaunched() { |
| + if (delegate_) |
| + delegate_->OnAppWindowLaunched(); |
| +} |
| + |
| ArcKioskAppService::ArcKioskAppService(Profile* profile) : profile_(profile) { |
| ArcAppListPrefs::Get(profile_)->AddObserver(this); |
| app_manager_ = ArcKioskAppManager::Get(); |
| @@ -106,7 +121,7 @@ void ArcKioskAppService::PreconditionsChanged() { |
| !maintenance_session_running_) { |
| if (!app_launcher_) |
| app_launcher_.reset(new ArcKioskAppLauncher( |
|
Luis Héctor Chávez
2017/01/24 18:40:24
nit: app_launcher_ = base::MakeUnique<ArcKioskAppL
Sergey Poromov
2017/01/25 14:29:21
Done.
|
| - profile_, ArcAppListPrefs::Get(profile_), app_id_)); |
| + profile_, ArcAppListPrefs::Get(profile_), app_id_, this)); |
| } else if (task_id_ != -1) { |
| arc::CloseTask(task_id_); |
| } |