Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(408)

Side by Side Diff: chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.h

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

Powered by Google App Engine
This is Rietveld 408576698