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 "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
10 #include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_launcher.h" | 10 #include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_launcher.h" |
11 #include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_manager.h" | 11 #include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_manager.h" |
12 #include "chrome/browser/ui/app_list/arc/arc_app_icon.h" | |
13 #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" |
14 #include "components/arc/kiosk/arc_kiosk_bridge.h" | 13 #include "components/arc/kiosk/arc_kiosk_bridge.h" |
15 #include "components/keyed_service/core/keyed_service.h" | 14 #include "components/keyed_service/core/keyed_service.h" |
16 #include "components/prefs/pref_change_registrar.h" | 15 #include "components/prefs/pref_change_registrar.h" |
17 | 16 |
18 class Profile; | 17 class Profile; |
19 | 18 |
20 namespace content { | 19 namespace content { |
21 class BrowserContext; | 20 class BrowserContext; |
22 } // namespace content | 21 } // namespace content |
23 | 22 |
24 namespace chromeos { | 23 namespace chromeos { |
25 | 24 |
26 class ArcKioskNotificationBlocker; | 25 class ArcKioskNotificationBlocker; |
27 | 26 |
28 // Keeps track of ARC session state and auto-launches kiosk app when it's ready. | 27 // Keeps track of ARC session state and auto-launches kiosk app when it's ready. |
29 // App is started when the following conditions are satisfied: | 28 // App is started when the following conditions are satisfied: |
30 // 1. App id is registered in ArcAppListPrefs and set to "ready" state. | 29 // 1. App id is registered in ArcAppListPrefs and set to "ready" state. |
31 // 2. Got empty policy compliance report from Android | 30 // 2. Got empty policy compliance report from Android |
32 // 3. App is not yet started | 31 // 3. App is not yet started |
33 // Also, the app is stopped when one of above conditions changes. | 32 // Also, the app is stopped when one of above conditions changes. |
34 class ArcKioskAppService | 33 class ArcKioskAppService |
35 : public KeyedService, | 34 : public KeyedService, |
36 public ArcAppListPrefs::Observer, | 35 public ArcAppListPrefs::Observer, |
37 public ArcKioskAppManager::ArcKioskAppManagerObserver, | 36 public ArcKioskAppManager::ArcKioskAppManagerObserver, |
38 public arc::ArcKioskBridge::Delegate, | 37 public arc::ArcKioskBridge::Delegate, |
39 public ArcKioskAppLauncher::Delegate, | 38 public ArcKioskAppLauncher::Delegate { |
40 public ArcAppIcon::Observer { | |
41 public: | 39 public: |
42 class Delegate { | 40 class Delegate { |
43 public: | 41 public: |
44 Delegate() = default; | 42 Delegate() = default; |
45 virtual void OnAppStarted() = 0; | 43 virtual void OnAppStarted() = 0; |
46 virtual void OnAppWindowLaunched() = 0; | 44 virtual void OnAppWindowLaunched() = 0; |
47 | 45 |
48 protected: | 46 protected: |
49 virtual ~Delegate() = default; | 47 virtual ~Delegate() = default; |
50 | 48 |
(...skipping 23 matching lines...) Expand all Loading... |
74 // ArcKioskAppManager::Observer overrides | 72 // ArcKioskAppManager::Observer overrides |
75 void OnArcKioskAppsChanged() override; | 73 void OnArcKioskAppsChanged() override; |
76 | 74 |
77 // ArcKioskBridge::Delegate overrides | 75 // ArcKioskBridge::Delegate overrides |
78 void OnMaintenanceSessionCreated() override; | 76 void OnMaintenanceSessionCreated() override; |
79 void OnMaintenanceSessionFinished() override; | 77 void OnMaintenanceSessionFinished() override; |
80 | 78 |
81 // ArcKioskAppLauncher::Delegate overrides | 79 // ArcKioskAppLauncher::Delegate overrides |
82 void OnAppWindowLaunched() override; | 80 void OnAppWindowLaunched() override; |
83 | 81 |
84 // ArcAppIcon::Observer overrides | |
85 void OnIconUpdated(ArcAppIcon* icon) override; | |
86 | |
87 private: | 82 private: |
88 explicit ArcKioskAppService(Profile* profile); | 83 explicit ArcKioskAppService(Profile* profile); |
89 ~ArcKioskAppService() override; | 84 ~ArcKioskAppService() override; |
90 | 85 |
91 std::string GetAppId(); | 86 std::string GetAppId(); |
92 // Called when app should be started or stopped. | 87 // Called when app should be started or stopped. |
93 void PreconditionsChanged(); | 88 void PreconditionsChanged(); |
94 // Updates local cache with proper name and icon. | |
95 void RequestNameAndIconUpdate(); | |
96 | 89 |
97 Profile* const profile_; | 90 Profile* const profile_; |
98 bool maintenance_session_running_ = false; | 91 bool maintenance_session_running_ = false; |
99 base::OneShotTimer maintenance_timeout_timer_; | 92 base::OneShotTimer maintenance_timeout_timer_; |
100 ArcKioskAppManager* app_manager_; | 93 ArcKioskAppManager* app_manager_; |
101 std::string app_id_; | 94 std::string app_id_; |
102 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info_; | 95 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info_; |
103 std::unique_ptr<ArcAppIcon> app_icon_; | |
104 int32_t task_id_ = -1; | 96 int32_t task_id_ = -1; |
105 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; | 97 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; |
106 // Keeps track whether the app is already launched | 98 // Keeps track whether the app is already launched |
107 std::unique_ptr<ArcKioskAppLauncher> app_launcher_; | 99 std::unique_ptr<ArcKioskAppLauncher> app_launcher_; |
108 std::unique_ptr<ArcKioskNotificationBlocker> notification_blocker_; | 100 std::unique_ptr<ArcKioskNotificationBlocker> notification_blocker_; |
109 // Not owning the delegate, delegate removes itself in destructor | 101 // Not owning the delegate, delegate removes itself in destructor |
110 Delegate* delegate_ = nullptr; | 102 Delegate* delegate_ = nullptr; |
111 | 103 |
112 DISALLOW_COPY_AND_ASSIGN(ArcKioskAppService); | 104 DISALLOW_COPY_AND_ASSIGN(ArcKioskAppService); |
113 }; | 105 }; |
114 | 106 |
115 } // namespace chromeos | 107 } // namespace chromeos |
116 | 108 |
117 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_ | 109 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_ |
OLD | NEW |