| 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> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // | 42 // |
| 43 // We attempt to load icons from the following sources in order: | 43 // We attempt to load icons from the following sources in order: |
| 44 // 1) The icons as listed in the extension / app manifests. | 44 // 1) The icons as listed in the extension / app manifests. |
| 45 // 2) If a 16px icon was requested, the favicon for extension's launch URL. | 45 // 2) If a 16px icon was requested, the favicon for extension's launch URL. |
| 46 // 3) The default extension / application icon if there are still no matches. | 46 // 3) The default extension / application icon if there are still no matches. |
| 47 // | 47 // |
| 48 class ExtensionIconSource : public ChromeURLDataManager::DataSource, | 48 class ExtensionIconSource : public ChromeURLDataManager::DataSource, |
| 49 public ImageLoadingTracker::Observer { | 49 public ImageLoadingTracker::Observer { |
| 50 public: | 50 public: |
| 51 explicit ExtensionIconSource(Profile* profile); | 51 explicit ExtensionIconSource(Profile* profile); |
| 52 virtual ~ExtensionIconSource(); | |
| 53 | 52 |
| 54 // Gets the URL of the |extension| icon in the given |icon_size|, falling back | 53 // Gets the URL of the |extension| icon in the given |icon_size|, falling back |
| 55 // based on the |match| type. If |grayscale|, the URL will be for the | 54 // based on the |match| type. If |grayscale|, the URL will be for the |
| 56 // desaturated version of the icon. |exists|, if non-NULL, will be set to true | 55 // desaturated version of the icon. |exists|, if non-NULL, will be set to true |
| 57 // if the icon exists; false if it will lead to a default or not-present | 56 // if the icon exists; false if it will lead to a default or not-present |
| 58 // image. | 57 // image. |
| 59 static GURL GetIconURL(const Extension* extension, | 58 static GURL GetIconURL(const Extension* extension, |
| 60 int icon_size, | 59 int icon_size, |
| 61 ExtensionIconSet::MatchType match, | 60 ExtensionIconSet::MatchType match, |
| 62 bool grayscale, | 61 bool grayscale, |
| 63 bool* exists); | 62 bool* exists); |
| 64 | 63 |
| 65 // A public utility function for accessing the bitmap of the image specified | 64 // A public utility function for accessing the bitmap of the image specified |
| 66 // by |resource_id|. | 65 // by |resource_id|. |
| 67 static SkBitmap* LoadImageByResourceId(int resource_id); | 66 static SkBitmap* LoadImageByResourceId(int resource_id); |
| 68 | 67 |
| 69 // ChromeURLDataManager::DataSource | 68 // ChromeURLDataManager::DataSource |
| 70 | 69 |
| 71 virtual std::string GetMimeType(const std::string&) const OVERRIDE; | 70 virtual std::string GetMimeType(const std::string&) const OVERRIDE; |
| 72 | 71 |
| 73 virtual void StartDataRequest(const std::string& path, | 72 virtual void StartDataRequest(const std::string& path, |
| 74 bool is_incognito, | 73 bool is_incognito, |
| 75 int request_id) OVERRIDE; | 74 int request_id) OVERRIDE; |
| 76 | 75 |
| 77 private: | 76 private: |
| 78 // Encapsulates the request parameters for |request_id|. | 77 // Encapsulates the request parameters for |request_id|. |
| 79 struct ExtensionIconRequest; | 78 struct ExtensionIconRequest; |
| 80 | 79 |
| 80 virtual ~ExtensionIconSource(); |
| 81 |
| 81 // Returns the bitmap for the webstore icon. | 82 // Returns the bitmap for the webstore icon. |
| 82 const SkBitmap* GetWebStoreImage(); | 83 const SkBitmap* GetWebStoreImage(); |
| 83 | 84 |
| 84 // Returns the bitmap for the default app image. | 85 // Returns the bitmap for the default app image. |
| 85 const SkBitmap* GetDefaultAppImage(); | 86 const SkBitmap* GetDefaultAppImage(); |
| 86 | 87 |
| 87 // Returns the bitmap for the default extension. | 88 // Returns the bitmap for the default extension. |
| 88 const SkBitmap* GetDefaultExtensionImage(); | 89 const SkBitmap* GetDefaultExtensionImage(); |
| 89 | 90 |
| 90 // Performs any remaining transformations (like desaturating the |image|), | 91 // Performs any remaining transformations (like desaturating the |image|), |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 scoped_ptr<SkBitmap> default_app_data_; | 159 scoped_ptr<SkBitmap> default_app_data_; |
| 159 | 160 |
| 160 scoped_ptr<SkBitmap> default_extension_data_; | 161 scoped_ptr<SkBitmap> default_extension_data_; |
| 161 | 162 |
| 162 CancelableRequestConsumerT<int, 0> cancelable_consumer_; | 163 CancelableRequestConsumerT<int, 0> cancelable_consumer_; |
| 163 | 164 |
| 164 DISALLOW_COPY_AND_ASSIGN(ExtensionIconSource); | 165 DISALLOW_COPY_AND_ASSIGN(ExtensionIconSource); |
| 165 }; | 166 }; |
| 166 | 167 |
| 167 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_ICON_SOURCE_H_ | 168 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_ICON_SOURCE_H_ |
| OLD | NEW |