| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_MANIFEST_MANIFEST_ICON_SELECTOR_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_MANIFEST_ICON_SELECTOR_H_ |
| 6 #define CHROME_BROWSER_MANIFEST_MANIFEST_ICON_SELECTOR_H_ | 6 #define CONTENT_PUBLIC_BROWSER_MANIFEST_ICON_SELECTOR_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "content/public/common/manifest.h" | 9 #include "content/public/common/manifest.h" |
| 10 #include "url/gurl.h" | 10 #include "url/gurl.h" |
| 11 | 11 |
| 12 namespace content { |
| 13 |
| 12 // Selects the square icon with the supported image MIME types and the specified | 14 // Selects the square icon with the supported image MIME types and the specified |
| 13 // icon purpose that most closely matches the size constraints. | 15 // icon purpose that most closely matches the size constraints. |
| 14 // This follows very basic heuristics -- improvements are welcome. | 16 // This follows very basic heuristics -- improvements are welcome. |
| 15 class ManifestIconSelector { | 17 class CONTENT_EXPORT ManifestIconSelector { |
| 16 public: | 18 public: |
| 17 // Runs the algorithm to find the best matching icon in the icons listed in | 19 // Runs the algorithm to find the best matching icon in the icons listed in |
| 18 // the Manifest. Size is defined in pixels. | 20 // the Manifest. Size is defined in pixels. |
| 19 // | 21 // |
| 20 // Any icon returned will be close as possible to |ideal_icon_size_in_px| | 22 // Any icon returned will be close as possible to |ideal_icon_size_in_px| |
| 21 // with a size not less than |minimum_icon_size_in_px|. Additionally, it must | 23 // with a size not less than |minimum_icon_size_in_px|. Additionally, it must |
| 22 // be square, have supported image MIME types, and have icon purpose | 24 // be square, have supported image MIME types, and have icon purpose |
| 23 // |purpose|. | 25 // |purpose|. |
| 24 // | 26 // |
| 25 // Returns the icon url if a suitable icon is found. An empty URL otherwise. | 27 // Returns the icon url if a suitable icon is found. An empty URL otherwise. |
| 26 static GURL FindBestMatchingIcon( | 28 static GURL FindBestMatchingIcon( |
| 27 const std::vector<content::Manifest::Icon>& icons, | 29 const std::vector<content::Manifest::Icon>& icons, |
| 28 int ideal_icon_size_in_px, | 30 int ideal_icon_size_in_px, |
| 29 int minimum_icon_size_in_px, | 31 int minimum_icon_size_in_px, |
| 30 content::Manifest::Icon::IconPurpose purpose); | 32 content::Manifest::Icon::IconPurpose purpose); |
| 31 | 33 |
| 32 private: | 34 private: |
| 33 DISALLOW_IMPLICIT_CONSTRUCTORS(ManifestIconSelector); | 35 DISALLOW_IMPLICIT_CONSTRUCTORS(ManifestIconSelector); |
| 34 }; | 36 }; |
| 35 | 37 |
| 36 #endif // CHROME_BROWSER_MANIFEST_MANIFEST_ICON_SELECTOR_H_ | 38 } // namespace content |
| 39 |
| 40 #endif // CONTENT_PUBLIC_BROWSER_MANIFEST_ICON_SELECTOR_H_ |
| OLD | NEW |