 Chromium Code Reviews
 Chromium Code Reviews Issue 2496903003:
  arc: Add Arc Kiosk app service and ability to launch kiosk apps.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@policy_comp_parse
    
  
    Issue 2496903003:
  arc: Add Arc Kiosk app service and ability to launch kiosk apps.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@policy_comp_parse| Index: chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.h | 
| diff --git a/chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.h b/chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.h | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..92c998daa2c48fbfac3c4027249259be5b24f40b | 
| --- /dev/null | 
| +++ b/chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.h | 
| @@ -0,0 +1,67 @@ | 
| +// Copyright 2016 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. | 
| + | 
| +#ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_ | 
| +#define CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_ | 
| + | 
| +#include "base/macros.h" | 
| +#include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_launcher.h" | 
| +#include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_manager.h" | 
| +#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 
| +#include "components/keyed_service/core/keyed_service.h" | 
| +#include "components/prefs/pref_change_registrar.h" | 
| +#include "content/public/browser/browser_context.h" | 
| + | 
| +namespace chromeos { | 
| + | 
| +// Keeps track of ARC session state and auto-launches kiosk app when it's ready. | 
| +// App is started when the following conditions are satisfied: | 
| +// 1. App id is registered in ArcAppListPrefs and set to "ready" state. | 
| +// 2. Got empty policy compliance report from Android | 
| +// 3. App is not yet started | 
| +// Also, the app is stopped when one of above conditions changes. | 
| +class ArcKioskAppService | 
| + : public KeyedService, | 
| + public ArcAppListPrefs::Observer, | 
| + public ArcKioskAppManager::ArcKioskAppManagerObserver { | 
| + public: | 
| + static ArcKioskAppService* Create(Profile* profile, ArcAppListPrefs* prefs); | 
| + static ArcKioskAppService* Get(content::BrowserContext* context); | 
| + | 
| + // ArcAppListPrefs::Observer overrides | 
| + void OnAppRegistered(const std::string& app_id, | 
| + const ArcAppListPrefs::AppInfo& app_info) override; | 
| + void OnAppReadyChanged(const std::string& id, bool ready) override; | 
| + void OnTaskCreated(int32_t task_id, | 
| + const std::string& package_name, | 
| + const std::string& activity) override; | 
| + void OnTaskDestroyed(int32_t task_id) override; | 
| + void OnPackageListInitialRefreshed() override; | 
| + | 
| + // ArcKioskAppManager::Observer overrides | 
| + void OnArcKioskAppsChanged() override; | 
| + | 
| + private: | 
| + ArcKioskAppService(Profile* profile, ArcAppListPrefs* prefs); | 
| + ~ArcKioskAppService(); | 
| + | 
| + std::string GetAppId(); | 
| + void MaybeStartOrStopKioskApp(); | 
| 
Luis Héctor Chávez
2016/11/16 16:37:12
Consider renaming it "PreconditionsChanged" to red
 
Sergey Poromov
2016/11/16 17:42:14
Done.
 | 
| + | 
| + Profile* const profile_; | 
| + ArcAppListPrefs* const prefs_; | 
| + ArcKioskAppManager* app_manager_; | 
| + std::string app_id_; | 
| + std::unique_ptr<ArcAppListPrefs::AppInfo> app_info_; | 
| + int32_t task_id_ = -1; | 
| + std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; | 
| + // Keeps track whether the app is already launched | 
| + std::unique_ptr<ArcKioskAppLauncher> app_launcher_; | 
| + | 
| + DISALLOW_COPY_AND_ASSIGN(ArcKioskAppService); | 
| +}; | 
| + | 
| +} // namespace chromeos | 
| + | 
| +#endif // CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_ |