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

Side by Side Diff: chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_manager.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_MANAGER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_MANAGER_H_ 6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_MANAGER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_data.h"
14 #include "chrome/browser/chromeos/policy/device_local_account.h" 15 #include "chrome/browser/chromeos/policy/device_local_account.h"
15 #include "chrome/browser/chromeos/settings/cros_settings.h" 16 #include "chrome/browser/chromeos/settings/cros_settings.h"
16 #include "components/signin/core/account_id/account_id.h" 17 #include "components/signin/core/account_id/account_id.h"
17 18
18 class PrefRegistrySimple; 19 class PrefRegistrySimple;
19 20
20 namespace chromeos { 21 namespace chromeos {
21 22
22 // Keeps track of Android apps that are to be launched in kiosk mode. 23 // Keeps track of Android apps that are to be launched in kiosk mode.
23 // For removed apps deletes appropriate cryptohome. The information about 24 // For removed apps deletes appropriate cryptohome. The information about
24 // kiosk apps are received from CrosSettings. For each app, the system 25 // kiosk apps are received from CrosSettings. For each app, the system
25 // creates a user in whose context the app then runs. 26 // creates a user in whose context the app then runs.
26 class ArcKioskAppManager { 27 class ArcKioskAppManager {
27 public: 28 public:
28 // Struct to hold full info about ARC Kiosk app. In future 29 using Apps = std::vector<ArcKioskAppData*>;
29 // this structure may contain many extra fields, e.g. icon.
30 class ArcKioskApp {
31 public:
32 ArcKioskApp(const policy::ArcKioskAppBasicInfo& app_info,
33 const AccountId& account_id,
34 const std::string& name);
35 ArcKioskApp(const ArcKioskApp& other);
36 ~ArcKioskApp();
37
38 bool operator==(const std::string& app_id) const;
39 bool operator==(const policy::ArcKioskAppBasicInfo& app_info) const;
40
41 const policy::ArcKioskAppBasicInfo& app_info() const { return app_info_; }
42 const AccountId& account_id() const { return account_id_; }
43 const std::string& name() const { return name_; }
44
45 private:
46 policy::ArcKioskAppBasicInfo app_info_;
47 AccountId account_id_;
48 std::string name_;
49 };
50
51 using ArcKioskApps = std::vector<ArcKioskApp>;
52 30
53 class ArcKioskAppManagerObserver { 31 class ArcKioskAppManagerObserver {
54 public: 32 public:
55 virtual void OnArcKioskAppsChanged() {} 33 virtual void OnArcKioskAppsChanged() {}
56 34
57 protected: 35 protected:
58 virtual ~ArcKioskAppManagerObserver() = default; 36 virtual ~ArcKioskAppManagerObserver() = default;
59 }; 37 };
60 38
39 static const char kArcKioskDictionaryName[];
40
61 static ArcKioskAppManager* Get(); 41 static ArcKioskAppManager* Get();
62 42
63 ArcKioskAppManager(); 43 ArcKioskAppManager();
64 ~ArcKioskAppManager(); 44 ~ArcKioskAppManager();
65 45
66 // Registers kiosk app entries in local state. 46 // Registers kiosk app entries in local state.
67 static void RegisterPrefs(PrefRegistrySimple* registry); 47 static void RegisterPrefs(PrefRegistrySimple* registry);
68 48
69 // Removes cryptohomes which could not be removed during the previous session. 49 // Removes cryptohomes which could not be removed during the previous session.
70 static void RemoveObsoleteCryptohomes(); 50 static void RemoveObsoleteCryptohomes();
71 51
72 // Returns auto launched account id. If there is none, account is invalid, 52 // Returns auto launched account id. If there is none, account is invalid,
73 // thus is_valid() returns empty AccountId. 53 // thus is_valid() returns empty AccountId.
74 const AccountId& GetAutoLaunchAccountId() const; 54 const AccountId& GetAutoLaunchAccountId() const;
75 55
76 // Returns app that should be started for given account id. 56 // Returns app that should be started for given account id.
77 const ArcKioskApp* GetAppByAccountId(const AccountId& account_id); 57 const ArcKioskAppData* GetAppByAccountId(const AccountId& account_id);
78 58
79 const ArcKioskApps& GetAllApps() const { return apps_; } 59 void GetAllApps(Apps* apps) const;
60
61 void UpdateNameAndIcon(const std::string& app_id,
62 const std::string& name,
63 const gfx::ImageSkia& icon);
80 64
81 void AddObserver(ArcKioskAppManagerObserver* observer); 65 void AddObserver(ArcKioskAppManagerObserver* observer);
82 void RemoveObserver(ArcKioskAppManagerObserver* observer); 66 void RemoveObserver(ArcKioskAppManagerObserver* observer);
83 67
84 bool current_app_was_auto_launched_with_zero_delay() const { 68 bool current_app_was_auto_launched_with_zero_delay() const {
85 return auto_launched_with_zero_delay_; 69 return auto_launched_with_zero_delay_;
86 } 70 }
87 71
88 private: 72 private:
89 // Updates apps_ based on CrosSettings. 73 // Updates apps_ based on CrosSettings.
90 void UpdateApps(); 74 void UpdateApps();
91 75
92 // Removes cryptohomes of the removed apps. Terminates the session if 76 // Removes cryptohomes of the removed apps. Terminates the session if
93 // a removed app is running. 77 // a removed app is running.
94 void ClearRemovedApps(const ArcKioskApps& old_apps); 78 void ClearRemovedApps(
79 const std::map<std::string, std::unique_ptr<ArcKioskAppData>>& old_apps);
95 80
96 ArcKioskApps apps_; 81 std::vector<std::unique_ptr<ArcKioskAppData>> apps_;
97 AccountId auto_launch_account_id_; 82 AccountId auto_launch_account_id_;
98 bool auto_launched_with_zero_delay_ = false; 83 bool auto_launched_with_zero_delay_ = false;
99 base::ObserverList<ArcKioskAppManagerObserver, true> observers_; 84 base::ObserverList<ArcKioskAppManagerObserver, true> observers_;
100 85
101 std::unique_ptr<CrosSettings::ObserverSubscription> 86 std::unique_ptr<CrosSettings::ObserverSubscription>
102 local_accounts_subscription_; 87 local_accounts_subscription_;
103 std::unique_ptr<CrosSettings::ObserverSubscription> 88 std::unique_ptr<CrosSettings::ObserverSubscription>
104 local_account_auto_login_id_subscription_; 89 local_account_auto_login_id_subscription_;
105 90
106 DISALLOW_COPY_AND_ASSIGN(ArcKioskAppManager); 91 DISALLOW_COPY_AND_ASSIGN(ArcKioskAppManager);
107 }; 92 };
108 93
109 } // namespace chromeos 94 } // namespace chromeos
110 95
111 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_MANAGER_H_ 96 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_ARC_ARC_KIOSK_APP_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698