OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_APP_LIST_ARC_APP_PREFS_H_ | |
6 #define CHROME_BROWSER_UI_APP_LIST_ARC_APP_PREFS_H_ | |
7 | |
8 #include <set> | |
9 #include <vector> | |
10 | |
11 #include "base/files/file_path.h" | |
12 #include "base/macros.h" | |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/observer_list.h" | |
15 #include "chromeos/dbus/arc_bridge_client.h" | |
16 #include "components/keyed_service/core/keyed_service.h" | |
17 #include "ui/base/layout.h" | |
18 | |
19 class PrefService; | |
20 | |
21 namespace content { | |
22 class BrowserContext; | |
23 } | |
24 | |
25 namespace user_prefs { | |
26 class PrefRegistrySyncable; | |
27 } | |
28 | |
29 class ArcAppPrefs : public KeyedService, | |
30 private chromeos::ArcBridgeClient::AppObserver { | |
31 public: | |
32 struct IconInfo { | |
33 ui::ScaleFactor scale_factor; | |
34 base::FilePath path; | |
35 }; | |
36 | |
37 struct AppInfo { | |
38 std::string name; | |
39 std::string package; | |
40 std::string activity; | |
41 bool enabled; | |
elijahtaylor1
2015/10/28 06:32:39
maybe call this "ready" here and elsewhere to matc
khmel1
2015/10/29 08:12:18
Good point. Done
| |
42 std::vector<IconInfo> icons; | |
43 }; | |
44 | |
45 class Observer { | |
46 public: | |
47 virtual void OnAppRegistered(const std::string& app_id, | |
48 const AppInfo& app_info) = 0; | |
49 virtual void OnAppEnabled(const std::string& id, bool enabled) = 0; | |
50 virtual void OnAppIconUpdated(const std::string& id, | |
51 const IconInfo& icon) = 0; | |
52 }; | |
53 | |
54 static ArcAppPrefs* Create(content::BrowserContext* browser_context, | |
55 const base::FilePath& base_path, | |
56 PrefService* prefs); | |
57 // Convenience function to get the ArcAppPrefs for a BrowserContext. | |
58 static ArcAppPrefs* Get(content::BrowserContext* context); | |
59 static std::string GetAppId(const std::string& package, | |
60 const std::string& activity); | |
61 | |
62 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | |
63 | |
64 ~ArcAppPrefs() override; | |
65 | |
66 std::vector<std::string> GetAppIds() const; | |
67 scoped_ptr<AppInfo> GetApp(const std::string& app_id) const; | |
68 | |
69 bool IsRegistered(const std::string& app_id); | |
70 | |
71 void AddObserver(Observer* observer); | |
72 void RemoveObserver(Observer* observer); | |
73 | |
74 private: | |
75 content::BrowserContext* browser_context_; | |
76 // Owned by the BrowserContext. | |
77 PrefService* prefs_; | |
78 base::ObserverList<Observer> observer_list_; | |
79 base::FilePath base_path_; | |
80 std::set<std::string> enable_apps_; | |
81 | |
82 // See the Create methods. | |
83 ArcAppPrefs(content::BrowserContext* browser_context, | |
84 const base::FilePath& base_path, | |
85 PrefService* prefs); | |
86 | |
87 // ArcBridgeClient::AppObserver | |
88 void OnAppReady(const chromeos::ArcBridgeClient::AppInfo& app) override; | |
89 void OnAppsRefreshed( | |
90 const std::vector<chromeos::ArcBridgeClient::AppInfo>& apps) override; | |
91 | |
92 // Install an icon to file system in the special folder of the profile | |
93 // directory. | |
94 void InstallIcon(const std::string& app_id, | |
95 ui::ScaleFactor scale_factor, | |
96 const std::vector<uint8>& contentPng); | |
97 void InstallIconFromFileThread(const std::string& app_id, | |
98 ui::ScaleFactor scale_factor, | |
99 const std::vector<uint8>& contentPng); | |
100 void OnIconInstalled(const std::string& app_id, | |
101 const IconInfo& icon_info); | |
102 | |
103 DISALLOW_COPY_AND_ASSIGN(ArcAppPrefs); | |
104 }; | |
105 | |
106 #endif // CHROME_BROWSER_UI_APP_LIST_ARC_APP_PREFS_H_ | |
OLD | NEW |