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

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: Add ArcKioskBridge::Delegate. 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/ui/app_list/arc/arc_app_list_prefs.h" 11 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
Luis Héctor Chávez 2016/12/01 20:13:33 nit: can you remove this?
Sergey Poromov 2016/12/16 16:12:05 The class still overrides ArcAppListPrefs::Observe
12 #include "components/arc/kiosk/arc_kiosk_bridge.h"
12 #include "components/keyed_service/core/keyed_service.h" 13 #include "components/keyed_service/core/keyed_service.h"
13 #include "components/prefs/pref_change_registrar.h" 14 #include "components/prefs/pref_change_registrar.h"
14 #include "content/public/browser/browser_context.h"
15 15
16 namespace chromeos { 16 namespace chromeos {
17 17
18 // Keeps track of ARC session state and auto-launches kiosk app when it's ready. 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: 19 // App is started when the following conditions are satisfied:
20 // 1. App id is registered in ArcAppListPrefs and set to "ready" state. 20 // 1. App id is registered in ArcAppListPrefs and set to "ready" state.
21 // 2. Got empty policy compliance report from Android 21 // 2. Got empty policy compliance report from Android
22 // 3. App is not yet started 22 // 3. App is not yet started
23 // Also, the app is stopped when one of above conditions changes. 23 // Also, the app is stopped when one of above conditions changes.
24 class ArcKioskAppService 24 class ArcKioskAppService
25 : public KeyedService, 25 : public KeyedService,
26 public ArcAppListPrefs::Observer, 26 public ArcAppListPrefs::Observer,
27 public ArcKioskAppManager::ArcKioskAppManagerObserver { 27 public ArcKioskAppManager::ArcKioskAppManagerObserver,
28 public arc::ArcKioskBridge::Delegate {
28 public: 29 public:
29 static ArcKioskAppService* Create(Profile* profile, ArcAppListPrefs* prefs); 30 static ArcKioskAppService* Create(Profile* profile);
30 static ArcKioskAppService* Get(content::BrowserContext* context); 31 static ArcKioskAppService* Get(Profile* context);
31 32
32 // ArcAppListPrefs::Observer overrides 33 // ArcAppListPrefs::Observer overrides
33 void OnAppRegistered(const std::string& app_id, 34 void OnAppRegistered(const std::string& app_id,
34 const ArcAppListPrefs::AppInfo& app_info) override; 35 const ArcAppListPrefs::AppInfo& app_info) override;
35 void OnAppReadyChanged(const std::string& id, bool ready) override; 36 void OnAppReadyChanged(const std::string& id, bool ready) override;
36 void OnTaskCreated(int32_t task_id, 37 void OnTaskCreated(int32_t task_id,
37 const std::string& package_name, 38 const std::string& package_name,
38 const std::string& activity) override; 39 const std::string& activity) override;
39 void OnTaskDestroyed(int32_t task_id) override; 40 void OnTaskDestroyed(int32_t task_id) override;
40 void OnPackageListInitialRefreshed() override; 41 void OnPackageListInitialRefreshed() override;
41 42
42 // ArcKioskAppManager::Observer overrides 43 // ArcKioskAppManager::Observer overrides
43 void OnArcKioskAppsChanged() override; 44 void OnArcKioskAppsChanged() override;
44 45
46 // ArcKioskBridge::Delegate overrides
47 void OnMaintenanceSessionCreated() override;
48 void OnMaintenanceSessionFinished() override;
49
45 private: 50 private:
46 ArcKioskAppService(Profile* profile, ArcAppListPrefs* prefs); 51 explicit ArcKioskAppService(Profile* profile);
47 ~ArcKioskAppService() override; 52 ~ArcKioskAppService() override;
48 53
49 std::string GetAppId(); 54 std::string GetAppId();
50 // Called when app should be started or stopped. 55 // Called when app should be started or stopped.
51 void PreconditionsChanged(); 56 void PreconditionsChanged();
52 57
53 Profile* const profile_; 58 Profile* const profile_;
54 ArcAppListPrefs* const prefs_; 59 ArcAppListPrefs* const prefs_;
Luis Héctor Chávez 2016/12/01 20:13:33 nit: can you remove this?
Sergey Poromov 2016/12/16 16:12:05 Done.
60 bool maintenance_session_running_;
55 ArcKioskAppManager* app_manager_; 61 ArcKioskAppManager* app_manager_;
56 std::string app_id_; 62 std::string app_id_;
57 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info_; 63 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info_;
58 int32_t task_id_ = -1; 64 int32_t task_id_ = -1;
59 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; 65 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;
60 // Keeps track whether the app is already launched 66 // Keeps track whether the app is already launched
61 std::unique_ptr<ArcKioskAppLauncher> app_launcher_; 67 std::unique_ptr<ArcKioskAppLauncher> app_launcher_;
62 68
63 DISALLOW_COPY_AND_ASSIGN(ArcKioskAppService); 69 DISALLOW_COPY_AND_ASSIGN(ArcKioskAppService);
64 }; 70 };
65 71
66 } // namespace chromeos 72 } // namespace chromeos
67 73
68 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_ 74 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698