| 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 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // 2) If a 16px icon was requested, the favicon for extension's launch URL. | 49 // 2) If a 16px icon was requested, the favicon for extension's launch URL. |
| 50 // 3) The default extension / application icon if there are still no matches. | 50 // 3) The default extension / application icon if there are still no matches. |
| 51 // | 51 // |
| 52 class ExtensionIconSource : public content::URLDataSource, | 52 class ExtensionIconSource : public content::URLDataSource, |
| 53 public base::SupportsWeakPtr<ExtensionIconSource> { | 53 public base::SupportsWeakPtr<ExtensionIconSource> { |
| 54 public: | 54 public: |
| 55 explicit ExtensionIconSource(Profile* profile); | 55 explicit ExtensionIconSource(Profile* profile); |
| 56 | 56 |
| 57 // 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 |
| 58 // 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 |
| 59 // desaturated version of the icon. |exists|, if non-NULL, will be set to true | 59 // desaturated version of the icon. |
| 60 // if the icon exists; false if it will lead to a default or not-present | |
| 61 // image. | |
| 62 static GURL GetIconURL(const Extension* extension, | 60 static GURL GetIconURL(const Extension* extension, |
| 63 int icon_size, | 61 int icon_size, |
| 64 ExtensionIconSet::MatchType match, | 62 ExtensionIconSet::MatchType match, |
| 65 bool grayscale, | 63 bool grayscale); |
| 66 bool* exists); | |
| 67 | 64 |
| 68 // A public utility function for accessing the bitmap of the image specified | 65 // A public utility function for accessing the bitmap of the image specified |
| 69 // by |resource_id|. | 66 // by |resource_id|. |
| 70 static SkBitmap* LoadImageByResourceId(int resource_id); | 67 static SkBitmap* LoadImageByResourceId(int resource_id); |
| 71 | 68 |
| 72 // content::URLDataSource implementation. | 69 // content::URLDataSource implementation. |
| 73 std::string GetSource() const override; | 70 std::string GetSource() const override; |
| 74 std::string GetMimeType(const std::string&) const override; | 71 std::string GetMimeType(const std::string&) const override; |
| 75 void StartDataRequest( | 72 void StartDataRequest( |
| 76 const std::string& path, | 73 const std::string& path, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 std::unique_ptr<SkBitmap> default_extension_data_; | 153 std::unique_ptr<SkBitmap> default_extension_data_; |
| 157 | 154 |
| 158 base::CancelableTaskTracker cancelable_task_tracker_; | 155 base::CancelableTaskTracker cancelable_task_tracker_; |
| 159 | 156 |
| 160 DISALLOW_COPY_AND_ASSIGN(ExtensionIconSource); | 157 DISALLOW_COPY_AND_ASSIGN(ExtensionIconSource); |
| 161 }; | 158 }; |
| 162 | 159 |
| 163 } // namespace extensions | 160 } // namespace extensions |
| 164 | 161 |
| 165 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_ICON_SOURCE_H_ | 162 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_ICON_SOURCE_H_ |
| OLD | NEW |