| 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() override; |
| 48 |
| 49 std::string GetAppId(); |
| 50 // Called when app should be started or stopped. |
| 51 void PreconditionsChanged(); |
| 52 |
| 53 Profile* const profile_; |
| 54 ArcAppListPrefs* const prefs_; |
| 55 ArcKioskAppManager* app_manager_; |
| 56 std::string app_id_; |
| 57 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info_; |
| 58 int32_t task_id_ = -1; |
| 59 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; |
| 60 // Keeps track whether the app is already launched |
| 61 std::unique_ptr<ArcKioskAppLauncher> app_launcher_; |
| 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(ArcKioskAppService); |
| 64 }; |
| 65 |
| 66 } // namespace chromeos |
| 67 |
| 68 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_ |
| OLD | NEW |