| 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 CHROME_BROWSER_MANIFEST_MANIFEST_ICON_SELECTOR_H_ |
| 6 #define CHROME_BROWSER_MANIFEST_MANIFEST_ICON_SELECTOR_H_ | 6 #define CHROME_BROWSER_MANIFEST_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" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 int ideal_icon_size_in_dp, | 42 int ideal_icon_size_in_dp, |
| 43 int minimum_icon_size_in_dp); | 43 int minimum_icon_size_in_dp); |
| 44 | 44 |
| 45 static int ConvertIconSizeFromDpToPx(int icon_size_in_dp); | 45 static int ConvertIconSizeFromDpToPx(int icon_size_in_dp); |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 ManifestIconSelector(int ideal_icon_size_in_px, | 48 ManifestIconSelector(int ideal_icon_size_in_px, |
| 49 int minimum_icon_size_in_px); | 49 int minimum_icon_size_in_px); |
| 50 virtual ~ManifestIconSelector() {} | 50 virtual ~ManifestIconSelector() {} |
| 51 | 51 |
| 52 // Returns the square icon that is the smallest icon larger than |
| 53 // ideal_icon_size_in_px_ (if it exists), or the largest icon smaller than |
| 54 // ideal_icon_size_in_px_ otherwise. |
| 55 int FindClosestIconToIdealSize( |
| 56 const std::vector<content::Manifest::Icon>& icons) const; |
| 57 |
| 52 // Runs the algorithm to find the best matching icon in the icons listed in | 58 // Runs the algorithm to find the best matching icon in the icons listed in |
| 53 // the Manifest. | 59 // the Manifest. |
| 54 // Returns the icon url if a suitable icon is found. An empty URL otherwise. | 60 // Returns the icon url if a suitable icon is found. An empty URL otherwise. |
| 55 int FindBestMatchingIcon(const std::vector<content::Manifest::Icon>& icons); | 61 int FindBestMatchingIcon( |
| 56 | 62 const std::vector<content::Manifest::Icon>& icons) const; |
| 57 // Runs an algorithm only based on icon declared sizes. It will try to find | |
| 58 // size that is the closest to preferred_icon_size_in_pixels_ but bigger than | |
| 59 // preferred_icon_size_in_pixels_ if possible. | |
| 60 // Returns the index of a suitable icon if one is found. -1 otherwise. | |
| 61 int FindBestMatchingIconForDensity( | |
| 62 const std::vector<content::Manifest::Icon>& icons, | |
| 63 float density); | |
| 64 | 63 |
| 65 // Returns whether the |preferred_icon_size_in_pixels_| is in |sizes|. | 64 // Returns whether the |preferred_icon_size_in_pixels_| is in |sizes|. |
| 66 bool IconSizesContainsPreferredSize(const std::vector<gfx::Size>& sizes); | 65 bool IconSizesContainsPreferredSize( |
| 66 const std::vector<gfx::Size>& sizes) const; |
| 67 | 67 |
| 68 // Returns whether a size bigger than |minimun_icon_size_in_pixels_| is in | 68 // Returns whether a size bigger than |minimun_icon_size_in_pixels_| is in |
| 69 // |sizes|. | 69 // |sizes|. |
| 70 bool IconSizesContainsBiggerThanMinimumSize( | 70 bool IconSizesContainsBiggerThanMinimumSize( |
| 71 const std::vector<gfx::Size>& sizes); | 71 const std::vector<gfx::Size>& sizes) const; |
| 72 | 72 |
| 73 // Returns an array containing the items in |icons| without the unsupported | 73 // Returns an array containing the items in |icons| without the unsupported |
| 74 // image MIME types. | 74 // image MIME types. |
| 75 static std::vector<content::Manifest::Icon> FilterIconsByType( | 75 static std::vector<content::Manifest::Icon> FilterIconsByType( |
| 76 const std::vector<content::Manifest::Icon>& icons); | 76 const std::vector<content::Manifest::Icon>& icons); |
| 77 | 77 |
| 78 // Returns whether the 'any' (ie. gfx::Size(0,0)) is in |sizes|. | 78 // Returns whether the 'any' (ie. gfx::Size(0,0)) is in |sizes|. |
| 79 static bool IconSizesContainsAny(const std::vector<gfx::Size>& sizes); | 79 static bool IconSizesContainsAny(const std::vector<gfx::Size>& sizes); |
| 80 | 80 |
| 81 const int ideal_icon_size_in_px_; | 81 const int ideal_icon_size_in_px_; |
| 82 const int minimum_icon_size_in_px_; | 82 const int minimum_icon_size_in_px_; |
| 83 const float density_; | |
| 84 | 83 |
| 85 friend class ManifestIconSelectorTest; | 84 friend class ManifestIconSelectorTest; |
| 86 | 85 |
| 87 DISALLOW_COPY_AND_ASSIGN(ManifestIconSelector); | 86 DISALLOW_COPY_AND_ASSIGN(ManifestIconSelector); |
| 88 }; | 87 }; |
| 89 | 88 |
| 90 #endif // CHROME_BROWSER_MANIFEST_MANIFEST_ICON_SELECTOR_H_ | 89 #endif // CHROME_BROWSER_MANIFEST_MANIFEST_ICON_SELECTOR_H_ |
| OLD | NEW |