| 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 "ui/gfx/image/image_skia.h" | 15 #include "ui/gfx/image/image_skia.h" |
| 16 | 16 |
| 17 class Profile; |
| 18 |
| 17 namespace base { | 19 namespace base { |
| 18 class RefCountedString; | 20 class RefCountedString; |
| 19 } | 21 } |
| 20 | 22 |
| 21 namespace extensions { | 23 namespace extensions { |
| 24 class Extension; |
| 22 class WebstoreDataFetcher; | 25 class WebstoreDataFetcher; |
| 23 } | 26 } |
| 24 | 27 |
| 28 namespace gfx { |
| 29 class Image; |
| 30 } |
| 31 |
| 25 namespace net { | 32 namespace net { |
| 26 class URLRequestContextGetter; | 33 class URLRequestContextGetter; |
| 27 } | 34 } |
| 28 | 35 |
| 29 namespace chromeos { | 36 namespace chromeos { |
| 30 | 37 |
| 31 class KioskAppDataDelegate; | 38 class KioskAppDataDelegate; |
| 32 | 39 |
| 33 // Fetches an app's web store data and manages the cached info such as name | 40 // Fetches an app's web store data and manages the cached info such as name |
| 34 // and icon. | 41 // and icon. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 47 const std::string& user_id); | 54 const std::string& user_id); |
| 48 virtual ~KioskAppData(); | 55 virtual ~KioskAppData(); |
| 49 | 56 |
| 50 // Loads app data from cache. If there is no cached data, fetches it | 57 // Loads app data from cache. If there is no cached data, fetches it |
| 51 // from web store. | 58 // from web store. |
| 52 void Load(); | 59 void Load(); |
| 53 | 60 |
| 54 // Clears locally cached data. | 61 // Clears locally cached data. |
| 55 void ClearCache(); | 62 void ClearCache(); |
| 56 | 63 |
| 64 // Loads app data from the app installed in the given profile. |
| 65 void LoadFromInstalledApp(Profile* profile, const extensions::Extension* app); |
| 66 |
| 57 // Returns true if web store data fetching is in progress. | 67 // Returns true if web store data fetching is in progress. |
| 58 bool IsLoading() const; | 68 bool IsLoading() const; |
| 59 | 69 |
| 60 const std::string& app_id() const { return app_id_; } | 70 const std::string& app_id() const { return app_id_; } |
| 61 const std::string& user_id() const { return user_id_; } | 71 const std::string& user_id() const { return user_id_; } |
| 62 const std::string& name() const { return name_; } | 72 const std::string& name() const { return name_; } |
| 63 const gfx::ImageSkia& icon() const { return icon_; } | 73 const gfx::ImageSkia& icon() const { return icon_; } |
| 64 const base::RefCountedString* raw_icon() const { | 74 const base::RefCountedString* raw_icon() const { |
| 65 return raw_icon_.get(); | 75 return raw_icon_.get(); |
| 66 } | 76 } |
| 67 Status status() const { return status_; } | 77 Status status() const { return status_; } |
| 68 | 78 |
| 69 private: | 79 private: |
| 70 class IconLoader; | 80 class IconLoader; |
| 71 class WebstoreDataParser; | 81 class WebstoreDataParser; |
| 72 | 82 |
| 73 void SetStatus(Status status); | 83 void SetStatus(Status status); |
| 74 | 84 |
| 75 // Returns URLRequestContextGetter to use for fetching web store data. | 85 // Returns URLRequestContextGetter to use for fetching web store data. |
| 76 net::URLRequestContextGetter* GetRequestContextGetter(); | 86 net::URLRequestContextGetter* GetRequestContextGetter(); |
| 77 | 87 |
| 78 // Loads the locally cached data. Return false if there is none. | 88 // Loads the locally cached data. Return false if there is none. |
| 79 bool LoadFromCache(); | 89 bool LoadFromCache(); |
| 80 | 90 |
| 81 // Sets the cached data. | 91 // Sets the cached data. |
| 82 void SetCache(const std::string& name, const base::FilePath& icon_path); | 92 void SetCache(const std::string& name, const base::FilePath& icon_path); |
| 83 | 93 |
| 94 // Helper to set the cached data using a SkBitmap icon. |
| 95 void SetCache(const std::string& name, const SkBitmap& icon); |
| 96 |
| 97 // Callback for extensions::ImageLoader. |
| 98 void OnExtensionIconLoaded(const gfx::Image& icon); |
| 99 |
| 84 // Callbacks for IconLoader. | 100 // Callbacks for IconLoader. |
| 85 void OnIconLoadSuccess(const scoped_refptr<base::RefCountedString>& raw_icon, | 101 void OnIconLoadSuccess(const scoped_refptr<base::RefCountedString>& raw_icon, |
| 86 const gfx::ImageSkia& icon); | 102 const gfx::ImageSkia& icon); |
| 87 void OnIconLoadFailure(); | 103 void OnIconLoadFailure(); |
| 88 | 104 |
| 89 // Callbacks for WebstoreDataParser | 105 // Callbacks for WebstoreDataParser |
| 90 void OnWebstoreParseSuccess(const SkBitmap& icon); | 106 void OnWebstoreParseSuccess(const SkBitmap& icon); |
| 91 void OnWebstoreParseFailure(); | 107 void OnWebstoreParseFailure(); |
| 92 | 108 |
| 93 // Starts to fetch data from web store. | 109 // Starts to fetch data from web store. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 118 | 134 |
| 119 scoped_ptr<extensions::WebstoreDataFetcher> webstore_fetcher_; | 135 scoped_ptr<extensions::WebstoreDataFetcher> webstore_fetcher_; |
| 120 base::FilePath icon_path_; | 136 base::FilePath icon_path_; |
| 121 | 137 |
| 122 DISALLOW_COPY_AND_ASSIGN(KioskAppData); | 138 DISALLOW_COPY_AND_ASSIGN(KioskAppData); |
| 123 }; | 139 }; |
| 124 | 140 |
| 125 } // namespace chromeos | 141 } // namespace chromeos |
| 126 | 142 |
| 127 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_DATA_H_ | 143 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_DATA_H_ |
| OLD | NEW |