Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_launcher.h" | |
| 10 #include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_manager.h" | |
| 11 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | |
| 12 #include "components/keyed_service/core/keyed_service.h" | |
| 13 #include "components/prefs/pref_change_registrar.h" | |
| 14 #include "content/public/browser/browser_context.h" | |
| 15 | |
| 16 namespace chromeos { | |
| 17 | |
| 18 // Keeps track of ARC session state and auto-launches kiosk app when it's ready. | |
| 19 // App is started when the following conditions are satisfied: | |
| 20 // 1. App id is registered in ArcAppListPrefs and set to "ready" state. | |
| 21 // 2. Got empty policy compliance report from Android | |
| 22 // 3. App is not yet started | |
| 23 // Also, the app is stopped when one of above conditions changes. | |
| 24 class ArcKioskAppService | |
| 25 : public KeyedService, | |
| 26 public ArcAppListPrefs::Observer, | |
| 27 public ArcKioskAppManager::ArcKioskAppManagerObserver { | |
| 28 public: | |
| 29 static ArcKioskAppService* Create(Profile* profile, ArcAppListPrefs* prefs); | |
| 30 static ArcKioskAppService* Get(content::BrowserContext* context); | |
| 31 | |
| 32 // ArcAppListPrefs::Observer overrides | |
| 33 void OnAppRegistered(const std::string& app_id, | |
| 34 const ArcAppListPrefs::AppInfo& app_info) override; | |
| 35 void OnAppReadyChanged(const std::string& id, bool ready) override; | |
| 36 void OnTaskCreated(int32_t task_id, | |
| 37 const std::string& package_name, | |
| 38 const std::string& activity) override; | |
| 39 void OnTaskDestroyed(int32_t task_id) override; | |
| 40 void OnPackageListInitialRefreshed() override; | |
| 41 | |
| 42 // ArcKioskAppManager::Observer overrides | |
| 43 void OnArcKioskAppsChanged() override; | |
| 44 | |
| 45 private: | |
| 46 ArcKioskAppService(Profile* profile, ArcAppListPrefs* prefs); | |
| 47 ~ArcKioskAppService(); | |
| 48 | |
| 49 std::string GetAppId(); | |
| 50 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.
| |
| 51 | |
| 52 Profile* const profile_; | |
| 53 ArcAppListPrefs* const prefs_; | |
| 54 ArcKioskAppManager* app_manager_; | |
| 55 std::string app_id_; | |
| 56 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info_; | |
| 57 int32_t task_id_ = -1; | |
| 58 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; | |
| 59 // Keeps track whether the app is already launched | |
| 60 std::unique_ptr<ArcKioskAppLauncher> app_launcher_; | |
| 61 | |
| 62 DISALLOW_COPY_AND_ASSIGN(ArcKioskAppService); | |
| 63 }; | |
| 64 | |
| 65 } // namespace chromeos | |
| 66 | |
| 67 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_ | |
| OLD | NEW |