OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_WEBUI_EXTENSIONS_EXTENSION_ICON_SOURCE_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_ICON_SOURCE_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_ICON_SOURCE_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_ICON_SOURCE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "chrome/browser/extensions/image_loading_tracker.h" | 13 #include "chrome/browser/extensions/image_loading_tracker.h" |
14 #include "chrome/browser/favicon/favicon_service.h" | 14 #include "chrome/browser/favicon/favicon_service.h" |
15 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 15 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
16 #include "chrome/common/extensions/extension_icon_set.h" | 16 #include "chrome/common/extensions/extension_icon_set.h" |
17 #include "third_party/skia/include/core/SkBitmap.h" | 17 #include "third_party/skia/include/core/SkBitmap.h" |
18 | 18 |
19 class ExtensionIconSet; | 19 class ExtensionIconSet; |
20 class Profile; | 20 class Profile; |
21 | 21 |
| 22 namespace extensions { |
| 23 class Extension; |
| 24 } |
| 25 |
22 // ExtensionIconSource serves extension icons through network level chrome: | 26 // ExtensionIconSource serves extension icons through network level chrome: |
23 // requests. Icons can be retrieved for any installed extension or app. | 27 // requests. Icons can be retrieved for any installed extension or app. |
24 // | 28 // |
25 // The format for requesting an icon is as follows: | 29 // The format for requesting an icon is as follows: |
26 // chrome://extension-icon/<extension_id>/<icon_size>/<match_type>?[options] | 30 // chrome://extension-icon/<extension_id>/<icon_size>/<match_type>?[options] |
27 // | 31 // |
28 // Parameters (<> required, [] optional): | 32 // Parameters (<> required, [] optional): |
29 // <extension_id> = the id of the extension | 33 // <extension_id> = the id of the extension |
30 // <icon_size> = the size of the icon, as the integer value of the | 34 // <icon_size> = the size of the icon, as the integer value of the |
31 // corresponding Extension:Icons enum. | 35 // corresponding Extension:Icons enum. |
(...skipping 16 matching lines...) Expand all Loading... |
48 class ExtensionIconSource : public ChromeURLDataManager::DataSource, | 52 class ExtensionIconSource : public ChromeURLDataManager::DataSource, |
49 public ImageLoadingTracker::Observer { | 53 public ImageLoadingTracker::Observer { |
50 public: | 54 public: |
51 explicit ExtensionIconSource(Profile* profile); | 55 explicit ExtensionIconSource(Profile* profile); |
52 | 56 |
53 // Gets the URL of the |extension| icon in the given |icon_size|, falling back | 57 // Gets the URL of the |extension| icon in the given |icon_size|, falling back |
54 // based on the |match| type. If |grayscale|, the URL will be for the | 58 // based on the |match| type. If |grayscale|, the URL will be for the |
55 // desaturated version of the icon. |exists|, if non-NULL, will be set to true | 59 // desaturated version of the icon. |exists|, if non-NULL, will be set to true |
56 // if the icon exists; false if it will lead to a default or not-present | 60 // if the icon exists; false if it will lead to a default or not-present |
57 // image. | 61 // image. |
58 static GURL GetIconURL(const Extension* extension, | 62 static GURL GetIconURL(const extensions::Extension* extension, |
59 int icon_size, | 63 int icon_size, |
60 ExtensionIconSet::MatchType match, | 64 ExtensionIconSet::MatchType match, |
61 bool grayscale, | 65 bool grayscale, |
62 bool* exists); | 66 bool* exists); |
63 | 67 |
64 // A public utility function for accessing the bitmap of the image specified | 68 // A public utility function for accessing the bitmap of the image specified |
65 // by |resource_id|. | 69 // by |resource_id|. |
66 static SkBitmap* LoadImageByResourceId(int resource_id); | 70 static SkBitmap* LoadImageByResourceId(int resource_id); |
67 | 71 |
68 // ChromeURLDataManager::DataSource | 72 // ChromeURLDataManager::DataSource |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // Parses and savse an ExtensionIconRequest for the URL |path| for the | 128 // Parses and savse an ExtensionIconRequest for the URL |path| for the |
125 // specified |request_id|. | 129 // specified |request_id|. |
126 bool ParseData(const std::string& path, int request_id); | 130 bool ParseData(const std::string& path, int request_id); |
127 | 131 |
128 // Sends the default response to |request_id|, used for invalid requests. | 132 // Sends the default response to |request_id|, used for invalid requests. |
129 void SendDefaultResponse(int request_id); | 133 void SendDefaultResponse(int request_id); |
130 | 134 |
131 // Stores the parameters associated with the |request_id|, making them | 135 // Stores the parameters associated with the |request_id|, making them |
132 // as an ExtensionIconRequest via GetData. | 136 // as an ExtensionIconRequest via GetData. |
133 void SetData(int request_id, | 137 void SetData(int request_id, |
134 const Extension* extension, | 138 const extensions::Extension* extension, |
135 bool grayscale, | 139 bool grayscale, |
136 int size, | 140 int size, |
137 ExtensionIconSet::MatchType match); | 141 ExtensionIconSet::MatchType match); |
138 | 142 |
139 // Returns the ExtensionIconRequest for the given |request_id|. | 143 // Returns the ExtensionIconRequest for the given |request_id|. |
140 ExtensionIconRequest* GetData(int request_id); | 144 ExtensionIconRequest* GetData(int request_id); |
141 | 145 |
142 // Removes temporary data associated with |request_id|. | 146 // Removes temporary data associated with |request_id|. |
143 void ClearData(int request_id); | 147 void ClearData(int request_id); |
144 | 148 |
(...skipping 14 matching lines...) Expand all Loading... |
159 scoped_ptr<SkBitmap> default_app_data_; | 163 scoped_ptr<SkBitmap> default_app_data_; |
160 | 164 |
161 scoped_ptr<SkBitmap> default_extension_data_; | 165 scoped_ptr<SkBitmap> default_extension_data_; |
162 | 166 |
163 CancelableRequestConsumerT<int, 0> cancelable_consumer_; | 167 CancelableRequestConsumerT<int, 0> cancelable_consumer_; |
164 | 168 |
165 DISALLOW_COPY_AND_ASSIGN(ExtensionIconSource); | 169 DISALLOW_COPY_AND_ASSIGN(ExtensionIconSource); |
166 }; | 170 }; |
167 | 171 |
168 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_ICON_SOURCE_H_ | 172 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_ICON_SOURCE_H_ |
OLD | NEW |