OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_KIOSK_APP_DATA_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_DATA_H_ |
6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_DATA_H_ | 6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_DATA_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "chrome/browser/extensions/webstore_data_fetcher_delegate.h" | 14 #include "chrome/browser/extensions/webstore_data_fetcher_delegate.h" |
| 15 #include "components/user_manager/user_id.h" |
15 #include "ui/gfx/image/image_skia.h" | 16 #include "ui/gfx/image/image_skia.h" |
16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
17 | 18 |
18 class Profile; | 19 class Profile; |
19 | 20 |
20 namespace extensions { | 21 namespace extensions { |
21 class Extension; | 22 class Extension; |
22 class WebstoreDataFetcher; | 23 class WebstoreDataFetcher; |
23 } | 24 } |
24 | 25 |
(...skipping 16 matching lines...) Expand all Loading... |
41 public: | 42 public: |
42 enum Status { | 43 enum Status { |
43 STATUS_INIT, // Data initialized with app id. | 44 STATUS_INIT, // Data initialized with app id. |
44 STATUS_LOADING, // Loading data from cache or web store. | 45 STATUS_LOADING, // Loading data from cache or web store. |
45 STATUS_LOADED, // Data loaded. | 46 STATUS_LOADED, // Data loaded. |
46 STATUS_ERROR, // Failed to load data. | 47 STATUS_ERROR, // Failed to load data. |
47 }; | 48 }; |
48 | 49 |
49 KioskAppData(KioskAppDataDelegate* delegate, | 50 KioskAppData(KioskAppDataDelegate* delegate, |
50 const std::string& app_id, | 51 const std::string& app_id, |
51 const std::string& user_id, | 52 const user_manager::UserID& user_id, |
52 const GURL& update_url); | 53 const GURL& update_url); |
53 ~KioskAppData() override; | 54 ~KioskAppData() override; |
54 | 55 |
55 // Loads app data from cache. If there is no cached data, fetches it | 56 // Loads app data from cache. If there is no cached data, fetches it |
56 // from web store. | 57 // from web store. |
57 void Load(); | 58 void Load(); |
58 | 59 |
59 // Clears locally cached data. | 60 // Clears locally cached data. |
60 void ClearCache(); | 61 void ClearCache(); |
61 | 62 |
62 // Loads app data from the app installed in the given profile. | 63 // Loads app data from the app installed in the given profile. |
63 void LoadFromInstalledApp(Profile* profile, const extensions::Extension* app); | 64 void LoadFromInstalledApp(Profile* profile, const extensions::Extension* app); |
64 | 65 |
65 // Sets full path of the cache crx. The crx would be used to extract meta | 66 // Sets full path of the cache crx. The crx would be used to extract meta |
66 // data for private apps. | 67 // data for private apps. |
67 void SetCachedCrx(const base::FilePath& crx_file); | 68 void SetCachedCrx(const base::FilePath& crx_file); |
68 | 69 |
69 // Returns true if web store data fetching is in progress. | 70 // Returns true if web store data fetching is in progress. |
70 bool IsLoading() const; | 71 bool IsLoading() const; |
71 | 72 |
72 // Returns true if the update url points to Webstore. | 73 // Returns true if the update url points to Webstore. |
73 bool IsFromWebStore() const; | 74 bool IsFromWebStore() const; |
74 | 75 |
75 const std::string& app_id() const { return app_id_; } | 76 const std::string& app_id() const { return app_id_; } |
76 const std::string& user_id() const { return user_id_; } | 77 const user_manager::UserID& user_id() const { return user_id_; } |
77 const std::string& name() const { return name_; } | 78 const std::string& name() const { return name_; } |
78 const GURL& update_url() const { return update_url_; } | 79 const GURL& update_url() const { return update_url_; } |
79 const gfx::ImageSkia& icon() const { return icon_; } | 80 const gfx::ImageSkia& icon() const { return icon_; } |
80 Status status() const { return status_; } | 81 Status status() const { return status_; } |
81 | 82 |
82 private: | 83 private: |
83 class CrxLoader; | 84 class CrxLoader; |
84 class IconLoader; | 85 class IconLoader; |
85 class WebstoreDataParser; | 86 class WebstoreDataParser; |
86 | 87 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // Extracts meta data from crx file when loading from Webstore and local | 129 // Extracts meta data from crx file when loading from Webstore and local |
129 // cache fails. | 130 // cache fails. |
130 void MaybeLoadFromCrx(); | 131 void MaybeLoadFromCrx(); |
131 | 132 |
132 void OnCrxLoadFinished(const CrxLoader* crx_loader); | 133 void OnCrxLoadFinished(const CrxLoader* crx_loader); |
133 | 134 |
134 KioskAppDataDelegate* delegate_; // not owned. | 135 KioskAppDataDelegate* delegate_; // not owned. |
135 Status status_; | 136 Status status_; |
136 | 137 |
137 std::string app_id_; | 138 std::string app_id_; |
138 std::string user_id_; | 139 user_manager::UserID user_id_; |
139 std::string name_; | 140 std::string name_; |
140 GURL update_url_; | 141 GURL update_url_; |
141 gfx::ImageSkia icon_; | 142 gfx::ImageSkia icon_; |
142 | 143 |
143 scoped_ptr<extensions::WebstoreDataFetcher> webstore_fetcher_; | 144 scoped_ptr<extensions::WebstoreDataFetcher> webstore_fetcher_; |
144 base::FilePath icon_path_; | 145 base::FilePath icon_path_; |
145 | 146 |
146 base::FilePath crx_file_; | 147 base::FilePath crx_file_; |
147 | 148 |
148 DISALLOW_COPY_AND_ASSIGN(KioskAppData); | 149 DISALLOW_COPY_AND_ASSIGN(KioskAppData); |
149 }; | 150 }; |
150 | 151 |
151 } // namespace chromeos | 152 } // namespace chromeos |
152 | 153 |
153 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_DATA_H_ | 154 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_DATA_H_ |
OLD | NEW |