OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_UI_APP_LIST_ARC_ARC_APP_LIST_PREFS_H_ | 5 #ifndef CHROME_BROWSER_UI_APP_LIST_ARC_ARC_APP_LIST_PREFS_H_ |
6 #define CHROME_BROWSER_UI_APP_LIST_ARC_ARC_APP_LIST_PREFS_H_ | 6 #define CHROME_BROWSER_UI_APP_LIST_ARC_ARC_APP_LIST_PREFS_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <memory> | 11 #include <memory> |
12 #include <set> | 12 #include <set> |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
21 #include "chrome/browser/chromeos/arc/arc_auth_service.h" | 21 #include "chrome/browser/chromeos/arc/arc_auth_service.h" |
22 #include "components/arc/arc_bridge_service.h" | 22 #include "components/arc/arc_bridge_service.h" |
23 #include "components/arc/common/app.mojom.h" | 23 #include "components/arc/common/app.mojom.h" |
| 24 #include "components/arc/instance_holder.h" |
24 #include "components/keyed_service/core/keyed_service.h" | 25 #include "components/keyed_service/core/keyed_service.h" |
25 #include "mojo/public/cpp/bindings/binding.h" | 26 #include "mojo/public/cpp/bindings/binding.h" |
26 #include "ui/base/layout.h" | 27 #include "ui/base/layout.h" |
27 | 28 |
28 class PrefService; | 29 class PrefService; |
29 | 30 |
30 namespace arc { | 31 namespace arc { |
31 class ArcBridgeService; | 32 class ArcBridgeService; |
32 } // namespace arc | 33 } // namespace arc |
33 | 34 |
34 namespace content { | 35 namespace content { |
35 class BrowserContext; | 36 class BrowserContext; |
36 } // namespace content | 37 } // namespace content |
37 | 38 |
38 namespace user_prefs { | 39 namespace user_prefs { |
39 class PrefRegistrySyncable; | 40 class PrefRegistrySyncable; |
40 } // namespace user_prefs | 41 } // namespace user_prefs |
41 | 42 |
42 // Declares shareable ARC app specific preferences, that keep information | 43 // Declares shareable ARC app specific preferences, that keep information |
43 // about app attributes (name, package_name, activity) and its state. This | 44 // about app attributes (name, package_name, activity) and its state. This |
44 // information is used to pre-create non-ready app items while ARC bridge | 45 // information is used to pre-create non-ready app items while ARC bridge |
45 // service is not ready to provide information about available ARC apps. | 46 // service is not ready to provide information about available ARC apps. |
46 // NOTE: ArcAppListPrefs is only created for the primary user. | 47 // NOTE: ArcAppListPrefs is only created for the primary user. |
47 class ArcAppListPrefs : public KeyedService, | 48 class ArcAppListPrefs |
48 public arc::mojom::AppHost, | 49 : public KeyedService, |
49 public arc::ArcBridgeService::Observer, | 50 public arc::mojom::AppHost, |
50 public arc::ArcAuthService::Observer { | 51 public arc::ArcBridgeService::Observer, |
| 52 public arc::InstanceHolder<arc::mojom::AppInstance>::Observer, |
| 53 public arc::ArcAuthService::Observer { |
51 public: | 54 public: |
52 struct AppInfo { | 55 struct AppInfo { |
53 AppInfo(const std::string& name, | 56 AppInfo(const std::string& name, |
54 const std::string& package_name, | 57 const std::string& package_name, |
55 const std::string& activity, | 58 const std::string& activity, |
56 const std::string& intent_uri, | 59 const std::string& intent_uri, |
57 const std::string& icon_resource_id, | 60 const std::string& icon_resource_id, |
58 const base::Time& last_launch_time, | 61 const base::Time& last_launch_time, |
59 bool sticky, | 62 bool sticky, |
60 bool notifications_enabled, | 63 bool notifications_enabled, |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 // Removes app with the given app_id. | 202 // Removes app with the given app_id. |
200 void RemoveApp(const std::string& app_id); | 203 void RemoveApp(const std::string& app_id); |
201 | 204 |
202 private: | 205 private: |
203 friend class ChromeLauncherControllerImplTest; | 206 friend class ChromeLauncherControllerImplTest; |
204 | 207 |
205 // See the Create methods. | 208 // See the Create methods. |
206 ArcAppListPrefs(const base::FilePath& base_path, PrefService* prefs); | 209 ArcAppListPrefs(const base::FilePath& base_path, PrefService* prefs); |
207 | 210 |
208 // arc::ArcBridgeService::Observer: | 211 // arc::ArcBridgeService::Observer: |
209 void OnStateChanged(arc::ArcBridgeService::State state) override; | 212 void OnBridgeStopped() override; |
210 void OnAppInstanceReady() override; | 213 |
211 void OnAppInstanceClosed() override; | 214 // arc::InstanceHolder<arc::mojom::AppInstance>::Observer: |
| 215 void OnInstanceReady() override; |
| 216 void OnInstanceClosed() override; |
212 | 217 |
213 // arc::mojom::AppHost: | 218 // arc::mojom::AppHost: |
214 void OnAppListRefreshed(mojo::Array<arc::mojom::AppInfoPtr> apps) override; | 219 void OnAppListRefreshed(mojo::Array<arc::mojom::AppInfoPtr> apps) override; |
215 void OnAppAdded(arc::mojom::AppInfoPtr app) override; | 220 void OnAppAdded(arc::mojom::AppInfoPtr app) override; |
216 void OnInstallShortcut(arc::mojom::ShortcutInfoPtr app) override; | 221 void OnInstallShortcut(arc::mojom::ShortcutInfoPtr app) override; |
217 void OnPackageRemoved(const mojo::String& package_name) override; | 222 void OnPackageRemoved(const mojo::String& package_name) override; |
218 void OnAppIcon(const mojo::String& package_name, | 223 void OnAppIcon(const mojo::String& package_name, |
219 const mojo::String& activity, | 224 const mojo::String& activity, |
220 arc::mojom::ScaleFactor scale_factor, | 225 arc::mojom::ScaleFactor scale_factor, |
221 mojo::Array<uint8_t> icon_png_data) override; | 226 mojo::Array<uint8_t> icon_png_data) override; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 bool apps_restored_ = false; | 288 bool apps_restored_ = false; |
284 | 289 |
285 mojo::Binding<arc::mojom::AppHost> binding_; | 290 mojo::Binding<arc::mojom::AppHost> binding_; |
286 | 291 |
287 base::WeakPtrFactory<ArcAppListPrefs> weak_ptr_factory_; | 292 base::WeakPtrFactory<ArcAppListPrefs> weak_ptr_factory_; |
288 | 293 |
289 DISALLOW_COPY_AND_ASSIGN(ArcAppListPrefs); | 294 DISALLOW_COPY_AND_ASSIGN(ArcAppListPrefs); |
290 }; | 295 }; |
291 | 296 |
292 #endif // CHROME_BROWSER_UI_APP_LIST_ARC_ARC_APP_LIST_PREFS_H_ | 297 #endif // CHROME_BROWSER_UI_APP_LIST_ARC_ARC_APP_LIST_PREFS_H_ |
OLD | NEW |