Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_ | 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_ | 6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_launcher.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" | 10 #include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_manager.h" |
| 11 #include "chrome/browser/profiles/profile.h" | |
|
Luis Héctor Chávez
2016/12/16 16:33:46
nit: You can remove this (as well as L16) since yo
Sergey Poromov
2016/12/16 17:00:30
Can't get rid of including profile.h as I need to
hidehiko
2016/12/19 13:53:33
You can use forward decl in the header file, and t
Sergey Poromov
2016/12/19 17:28:38
In that case I get
../../chrome/browser/chromeos/a
hidehiko
2016/12/19 17:39:18
Profile lives in a global namespace.
https://cs.ch
Sergey Poromov
2016/12/20 10:56:51
I realized that the problem was originally because
| |
| 11 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 12 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 13 #include "components/arc/kiosk/arc_kiosk_bridge.h" | |
| 12 #include "components/keyed_service/core/keyed_service.h" | 14 #include "components/keyed_service/core/keyed_service.h" |
| 13 #include "components/prefs/pref_change_registrar.h" | 15 #include "components/prefs/pref_change_registrar.h" |
| 14 #include "content/public/browser/browser_context.h" | 16 #include "content/public/browser/browser_context.h" |
| 15 | 17 |
| 16 namespace chromeos { | 18 namespace chromeos { |
| 17 | 19 |
| 18 // Keeps track of ARC session state and auto-launches kiosk app when it's ready. | 20 // 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: | 21 // App is started when the following conditions are satisfied: |
| 20 // 1. App id is registered in ArcAppListPrefs and set to "ready" state. | 22 // 1. App id is registered in ArcAppListPrefs and set to "ready" state. |
| 21 // 2. Got empty policy compliance report from Android | 23 // 2. Got empty policy compliance report from Android |
| 22 // 3. App is not yet started | 24 // 3. App is not yet started |
| 23 // Also, the app is stopped when one of above conditions changes. | 25 // Also, the app is stopped when one of above conditions changes. |
| 24 class ArcKioskAppService | 26 class ArcKioskAppService |
| 25 : public KeyedService, | 27 : public KeyedService, |
| 26 public ArcAppListPrefs::Observer, | 28 public ArcAppListPrefs::Observer, |
| 27 public ArcKioskAppManager::ArcKioskAppManagerObserver { | 29 public ArcKioskAppManager::ArcKioskAppManagerObserver, |
| 30 public arc::ArcKioskBridge::Delegate { | |
| 28 public: | 31 public: |
| 29 static ArcKioskAppService* Create(Profile* profile, ArcAppListPrefs* prefs); | 32 static ArcKioskAppService* Create(Profile* profile); |
| 30 static ArcKioskAppService* Get(content::BrowserContext* context); | 33 static ArcKioskAppService* Get(content::BrowserContext* context); |
| 31 | 34 |
| 35 // KeyedService overrides | |
| 36 void Shutdown() override; | |
| 37 | |
| 32 // ArcAppListPrefs::Observer overrides | 38 // ArcAppListPrefs::Observer overrides |
| 33 void OnAppRegistered(const std::string& app_id, | 39 void OnAppRegistered(const std::string& app_id, |
| 34 const ArcAppListPrefs::AppInfo& app_info) override; | 40 const ArcAppListPrefs::AppInfo& app_info) override; |
| 35 void OnAppReadyChanged(const std::string& id, bool ready) override; | 41 void OnAppReadyChanged(const std::string& id, bool ready) override; |
| 36 void OnTaskCreated(int32_t task_id, | 42 void OnTaskCreated(int32_t task_id, |
| 37 const std::string& package_name, | 43 const std::string& package_name, |
| 38 const std::string& activity, | 44 const std::string& activity, |
| 39 const std::string& intent) override; | 45 const std::string& intent) override; |
| 40 void OnTaskDestroyed(int32_t task_id) override; | 46 void OnTaskDestroyed(int32_t task_id) override; |
| 41 void OnPackageListInitialRefreshed() override; | 47 void OnPackageListInitialRefreshed() override; |
| 42 | 48 |
| 43 // ArcKioskAppManager::Observer overrides | 49 // ArcKioskAppManager::Observer overrides |
| 44 void OnArcKioskAppsChanged() override; | 50 void OnArcKioskAppsChanged() override; |
| 45 | 51 |
| 52 // ArcKioskBridge::Delegate overrides | |
| 53 void OnMaintenanceSessionCreated() override; | |
| 54 void OnMaintenanceSessionFinished() override; | |
| 55 | |
| 46 private: | 56 private: |
| 47 ArcKioskAppService(Profile* profile, ArcAppListPrefs* prefs); | 57 explicit ArcKioskAppService(Profile* profile); |
| 48 ~ArcKioskAppService() override; | 58 ~ArcKioskAppService() override; |
| 49 | 59 |
| 50 std::string GetAppId(); | 60 std::string GetAppId(); |
| 51 // Called when app should be started or stopped. | 61 // Called when app should be started or stopped. |
| 52 void PreconditionsChanged(); | 62 void PreconditionsChanged(); |
| 53 | 63 |
| 54 Profile* const profile_; | 64 Profile* const profile_; |
| 55 ArcAppListPrefs* const prefs_; | 65 bool maintenance_session_running_; |
| 56 ArcKioskAppManager* app_manager_; | 66 ArcKioskAppManager* app_manager_; |
| 57 std::string app_id_; | 67 std::string app_id_; |
| 58 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info_; | 68 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info_; |
| 59 int32_t task_id_ = -1; | 69 int32_t task_id_ = -1; |
| 60 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; | 70 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; |
| 61 // Keeps track whether the app is already launched | 71 // Keeps track whether the app is already launched |
| 62 std::unique_ptr<ArcKioskAppLauncher> app_launcher_; | 72 std::unique_ptr<ArcKioskAppLauncher> app_launcher_; |
| 63 | 73 |
| 64 DISALLOW_COPY_AND_ASSIGN(ArcKioskAppService); | 74 DISALLOW_COPY_AND_ASSIGN(ArcKioskAppService); |
| 65 }; | 75 }; |
| 66 | 76 |
| 67 } // namespace chromeos | 77 } // namespace chromeos |
| 68 | 78 |
| 69 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_ | 79 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_ |
| OLD | NEW |