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

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: rebase 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
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
16 class Profile;
17
18 namespace content {
19 class BrowserContext;
20 } // namespace content
15 21
16 namespace chromeos { 22 namespace chromeos {
17 23
18 // Keeps track of ARC session state and auto-launches kiosk app when it's ready. 24 // 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: 25 // App is started when the following conditions are satisfied:
20 // 1. App id is registered in ArcAppListPrefs and set to "ready" state. 26 // 1. App id is registered in ArcAppListPrefs and set to "ready" state.
21 // 2. Got empty policy compliance report from Android 27 // 2. Got empty policy compliance report from Android
22 // 3. App is not yet started 28 // 3. App is not yet started
23 // Also, the app is stopped when one of above conditions changes. 29 // Also, the app is stopped when one of above conditions changes.
24 class ArcKioskAppService 30 class ArcKioskAppService
25 : public KeyedService, 31 : public KeyedService,
26 public ArcAppListPrefs::Observer, 32 public ArcAppListPrefs::Observer,
27 public ArcKioskAppManager::ArcKioskAppManagerObserver { 33 public ArcKioskAppManager::ArcKioskAppManagerObserver,
34 public arc::ArcKioskBridge::Delegate {
28 public: 35 public:
29 static ArcKioskAppService* Create(Profile* profile, ArcAppListPrefs* prefs); 36 static ArcKioskAppService* Create(Profile* profile);
30 static ArcKioskAppService* Get(content::BrowserContext* context); 37 static ArcKioskAppService* Get(content::BrowserContext* context);
31 38
39 // KeyedService overrides
40 void Shutdown() override;
41
32 // ArcAppListPrefs::Observer overrides 42 // ArcAppListPrefs::Observer overrides
33 void OnAppRegistered(const std::string& app_id, 43 void OnAppRegistered(const std::string& app_id,
34 const ArcAppListPrefs::AppInfo& app_info) override; 44 const ArcAppListPrefs::AppInfo& app_info) override;
35 void OnAppReadyChanged(const std::string& id, bool ready) override; 45 void OnAppReadyChanged(const std::string& id, bool ready) override;
36 void OnTaskCreated(int32_t task_id, 46 void OnTaskCreated(int32_t task_id,
37 const std::string& package_name, 47 const std::string& package_name,
38 const std::string& activity, 48 const std::string& activity,
39 const std::string& intent) override; 49 const std::string& intent) override;
40 void OnTaskDestroyed(int32_t task_id) override; 50 void OnTaskDestroyed(int32_t task_id) override;
41 void OnPackageListInitialRefreshed() override; 51 void OnPackageListInitialRefreshed() override;
42 52
43 // ArcKioskAppManager::Observer overrides 53 // ArcKioskAppManager::Observer overrides
44 void OnArcKioskAppsChanged() override; 54 void OnArcKioskAppsChanged() override;
45 55
56 // ArcKioskBridge::Delegate overrides
57 void OnMaintenanceSessionCreated() override;
58 void OnMaintenanceSessionFinished() override;
59
46 private: 60 private:
47 ArcKioskAppService(Profile* profile, ArcAppListPrefs* prefs); 61 explicit ArcKioskAppService(Profile* profile);
48 ~ArcKioskAppService() override; 62 ~ArcKioskAppService() override;
49 63
50 std::string GetAppId(); 64 std::string GetAppId();
51 // Called when app should be started or stopped. 65 // Called when app should be started or stopped.
52 void PreconditionsChanged(); 66 void PreconditionsChanged();
53 67
54 Profile* const profile_; 68 Profile* const profile_;
55 ArcAppListPrefs* const prefs_; 69 bool maintenance_session_running_ = false;
56 ArcKioskAppManager* app_manager_; 70 ArcKioskAppManager* app_manager_;
57 std::string app_id_; 71 std::string app_id_;
58 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info_; 72 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info_;
59 int32_t task_id_ = -1; 73 int32_t task_id_ = -1;
60 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; 74 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;
61 // Keeps track whether the app is already launched 75 // Keeps track whether the app is already launched
62 std::unique_ptr<ArcKioskAppLauncher> app_launcher_; 76 std::unique_ptr<ArcKioskAppLauncher> app_launcher_;
63 77
64 DISALLOW_COPY_AND_ASSIGN(ArcKioskAppService); 78 DISALLOW_COPY_AND_ASSIGN(ArcKioskAppService);
65 }; 79 };
66 80
67 } // namespace chromeos 81 } // namespace chromeos
68 82
69 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_ 83 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698