Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3282)

Unified Diff: chrome/browser/manifest/manifest_icon_selector.h

Issue 1285063003: manifest: rework icon selector to include small icon cut-off (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix final comments Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/manifest/manifest_icon_selector.h
diff --git a/chrome/browser/manifest/manifest_icon_selector.h b/chrome/browser/manifest/manifest_icon_selector.h
index c0c582d729c26cf2440f97cedfa247aed36ea4f5..8bad2144871d30cba2c6bfb0f064117bf6bee222 100644
--- a/chrome/browser/manifest/manifest_icon_selector.h
+++ b/chrome/browser/manifest/manifest_icon_selector.h
@@ -33,6 +33,9 @@ class ManifestIconSelector {
// If/when this class is generalized, it may be a good idea to switch this to
// taking in pixels, instead.
//
+ // The icon returned will have a minimum size of an image one density bucket
+ // smaller than the device denisity * preferred_icon_size_in_dp.
+ //
// Returns the icon url if a suitable icon is found. An empty URL otherwise.
static GURL FindBestMatchingIcon(
const std::vector<content::Manifest::Icon>& icons,
@@ -40,27 +43,33 @@ class ManifestIconSelector {
const gfx::Screen* screen);
private:
- explicit ManifestIconSelector(float preferred_icon_size_in_pixels);
+ ManifestIconSelector(float preferred_icon_size_in_pixels,
+ float minimum_icon_size_in_pixels);
virtual ~ManifestIconSelector() {}
// Runs the algorithm to find the best matching icon in the icons listed in
// the Manifest.
// Returns the icon url if a suitable icon is found. An empty URL otherwise.
- GURL FindBestMatchingIcon(
+ int FindBestMatchingIcon(
const std::vector<content::Manifest::Icon>& icons,
float density);
// Runs an algorithm only based on icon declared sizes. It will try to find
// size that is the closest to preferred_icon_size_in_pixels_ but bigger than
// preferred_icon_size_in_pixels_ if possible.
- // Returns the icon url if a suitable icon is found. An empty URL otherwise.
- GURL FindBestMatchingIconForDensity(
+ // Returns the index of a suitable icon if one is found. -1 otherwise.
+ int FindBestMatchingIconForDensity(
const std::vector<content::Manifest::Icon>& icons,
float density);
// Returns whether the |preferred_icon_size_in_pixels_| is in |sizes|.
bool IconSizesContainsPreferredSize(const std::vector<gfx::Size>& sizes);
+ // Returns whether a size bigger than |minimun_icon_size_in_pixels_| is in
+ // |sizes|.
+ bool IconSizesContainsBiggerThanMinimumSize(
+ const std::vector<gfx::Size>& sizes);
+
// Returns an array containing the items in |icons| without the unsupported
// image MIME types.
static std::vector<content::Manifest::Icon> FilterIconsByType(
@@ -70,6 +79,7 @@ class ManifestIconSelector {
static bool IconSizesContainsAny(const std::vector<gfx::Size>& sizes);
const int preferred_icon_size_in_pixels_;
+ const int minimum_icon_size_in_pixels_;
friend class ManifestIconSelectorTest;

Powered by Google App Engine
This is Rietveld 408576698