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

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

Issue 2524673003: arc: Stop/start ARC++ kiosk app when maintenance session started/finished. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits and includes Created 4 years 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 "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"
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
17 namespace content {
18 class BrowserContext;
19 } // namespace content
15 20
16 namespace chromeos { 21 namespace chromeos {
17 22
18 // Keeps track of ARC session state and auto-launches kiosk app when it's ready. 23 // 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: 24 // App is started when the following conditions are satisfied:
20 // 1. App id is registered in ArcAppListPrefs and set to "ready" state. 25 // 1. App id is registered in ArcAppListPrefs and set to "ready" state.
21 // 2. Got empty policy compliance report from Android 26 // 2. Got empty policy compliance report from Android
22 // 3. App is not yet started 27 // 3. App is not yet started
23 // Also, the app is stopped when one of above conditions changes. 28 // Also, the app is stopped when one of above conditions changes.
24 class ArcKioskAppService 29 class ArcKioskAppService
25 : public KeyedService, 30 : public KeyedService,
26 public ArcAppListPrefs::Observer, 31 public ArcAppListPrefs::Observer,
27 public ArcKioskAppManager::ArcKioskAppManagerObserver { 32 public ArcKioskAppManager::ArcKioskAppManagerObserver,
33 public arc::ArcKioskBridge::Delegate {
28 public: 34 public:
29 static ArcKioskAppService* Create(Profile* profile, ArcAppListPrefs* prefs); 35 static ArcKioskAppService* Create(Profile* profile);
30 static ArcKioskAppService* Get(content::BrowserContext* context); 36 static ArcKioskAppService* Get(content::BrowserContext* context);
31 37
38 // KeyedService overrides
39 void Shutdown() override;
40
32 // ArcAppListPrefs::Observer overrides 41 // ArcAppListPrefs::Observer overrides
33 void OnAppRegistered(const std::string& app_id, 42 void OnAppRegistered(const std::string& app_id,
34 const ArcAppListPrefs::AppInfo& app_info) override; 43 const ArcAppListPrefs::AppInfo& app_info) override;
35 void OnAppReadyChanged(const std::string& id, bool ready) override; 44 void OnAppReadyChanged(const std::string& id, bool ready) override;
36 void OnTaskCreated(int32_t task_id, 45 void OnTaskCreated(int32_t task_id,
37 const std::string& package_name, 46 const std::string& package_name,
38 const std::string& activity, 47 const std::string& activity,
39 const std::string& intent) override; 48 const std::string& intent) override;
40 void OnTaskDestroyed(int32_t task_id) override; 49 void OnTaskDestroyed(int32_t task_id) override;
41 void OnPackageListInitialRefreshed() override; 50 void OnPackageListInitialRefreshed() override;
42 51
43 // ArcKioskAppManager::Observer overrides 52 // ArcKioskAppManager::Observer overrides
44 void OnArcKioskAppsChanged() override; 53 void OnArcKioskAppsChanged() override;
45 54
55 // ArcKioskBridge::Delegate overrides
56 void OnMaintenanceSessionCreated() override;
57 void OnMaintenanceSessionFinished() override;
58
46 private: 59 private:
47 ArcKioskAppService(Profile* profile, ArcAppListPrefs* prefs); 60 explicit ArcKioskAppService(Profile* profile);
48 ~ArcKioskAppService() override; 61 ~ArcKioskAppService() override;
49 62
50 std::string GetAppId(); 63 std::string GetAppId();
51 // Called when app should be started or stopped. 64 // Called when app should be started or stopped.
52 void PreconditionsChanged(); 65 void PreconditionsChanged();
53 66
54 Profile* const profile_; 67 Profile* const profile_;
55 ArcAppListPrefs* const prefs_; 68 bool maintenance_session_running_ = false;
56 ArcKioskAppManager* app_manager_; 69 ArcKioskAppManager* app_manager_;
57 std::string app_id_; 70 std::string app_id_;
58 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info_; 71 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info_;
59 int32_t task_id_ = -1; 72 int32_t task_id_ = -1;
60 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; 73 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;
61 // Keeps track whether the app is already launched 74 // Keeps track whether the app is already launched
62 std::unique_ptr<ArcKioskAppLauncher> app_launcher_; 75 std::unique_ptr<ArcKioskAppLauncher> app_launcher_;
63 76
64 DISALLOW_COPY_AND_ASSIGN(ArcKioskAppService); 77 DISALLOW_COPY_AND_ASSIGN(ArcKioskAppService);
65 }; 78 };
66 79
67 } // namespace chromeos 80 } // namespace chromeos
68 81
69 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_ 82 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698