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

Side by Side 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 test failures 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 unified diff | Download patch
OLDNEW
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/basictypes.h" 8 #include "base/basictypes.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 22 matching lines...) Expand all
33 // If/when this class is generalized, it may be a good idea to switch this to 33 // If/when this class is generalized, it may be a good idea to switch this to
34 // taking in pixels, instead. 34 // taking in pixels, instead.
35 // 35 //
36 // Returns the icon url if a suitable icon is found. An empty URL otherwise. 36 // Returns the icon url if a suitable icon is found. An empty URL otherwise.
37 static GURL FindBestMatchingIcon( 37 static GURL FindBestMatchingIcon(
38 const std::vector<content::Manifest::Icon>& icons, 38 const std::vector<content::Manifest::Icon>& icons,
39 float preferred_icon_size_in_dp, 39 float preferred_icon_size_in_dp,
40 const gfx::Screen* screen); 40 const gfx::Screen* screen);
41 41
42 private: 42 private:
43 explicit ManifestIconSelector(float preferred_icon_size_in_pixels); 43 ManifestIconSelector(float preferred_icon_size_in_pixels,
44 float minimum_icon_size_in_pixels);
mlamouri (slow - plz ping) 2015/08/19 15:02:54 You should update the public method to make it cle
Lalit Maganti 2015/08/20 14:53:49 Done. Yes similar to the mention of pixels, doing
44 virtual ~ManifestIconSelector() {} 45 virtual ~ManifestIconSelector() {}
45 46
46 // Runs the algorithm to find the best matching icon in the icons listed in 47 // Runs the algorithm to find the best matching icon in the icons listed in
47 // the Manifest. 48 // the Manifest.
48 // Returns the icon url if a suitable icon is found. An empty URL otherwise. 49 // Returns the icon url if a suitable icon is found. An empty URL otherwise.
49 GURL FindBestMatchingIcon( 50 GURL FindBestMatchingIcon(
mlamouri (slow - plz ping) 2015/08/19 15:02:53 Maybe this could return an int too?
50 const std::vector<content::Manifest::Icon>& icons, 51 const std::vector<content::Manifest::Icon>& icons,
51 float density); 52 float density);
52 53
53 // Runs an algorithm only based on icon declared sizes. It will try to find 54 // Runs an algorithm only based on icon declared sizes. It will try to find
54 // size that is the closest to preferred_icon_size_in_pixels_ but bigger than 55 // size that is the closest to preferred_icon_size_in_pixels_ but bigger than
55 // preferred_icon_size_in_pixels_ if possible. 56 // preferred_icon_size_in_pixels_ if possible.
56 // Returns the icon url if a suitable icon is found. An empty URL otherwise. 57 // Returns the index of a suitable icon if one is found. -1 otherwise.
57 GURL FindBestMatchingIconForDensity( 58 int FindBestMatchingIconForDensity(
58 const std::vector<content::Manifest::Icon>& icons, 59 const std::vector<content::Manifest::Icon>& icons,
59 float density); 60 float density);
60 61
61 // Returns whether the |preferred_icon_size_in_pixels_| is in |sizes|. 62 // Returns whether the |preferred_icon_size_in_pixels_| is in |sizes|.
62 bool IconSizesContainsPreferredSize(const std::vector<gfx::Size>& sizes); 63 bool IconSizesContainsPreferredSize(const std::vector<gfx::Size>& sizes);
63 64
65 // Returns whether a size bigger than |minimun_icon_size_in_pixels_| is in
66 // |sizes|.
67 bool IconSizesBiggerThanMinimum(const std::vector<gfx::Size>& sizes);
mlamouri (slow - plz ping) 2015/08/19 15:02:54 nit: for consistency, rename to "IconSizesBiggerTh
gone 2015/08/19 22:31:56 did you mean IconSizesContainsBiggerThanMinimum?
Lalit Maganti 2015/08/20 14:53:49 Done.
mlamouri (slow - plz ping) 2015/08/20 22:18:18 I meant IconSizesContainsBiggerThanMinimumSize()
mlamouri (slow - plz ping) 2015/08/21 10:50:54 I think you missed that comment.
Lalit Maganti 2015/08/21 11:18:20 Done. (Yeah I missed it because I usually read com
68
64 // Returns an array containing the items in |icons| without the unsupported 69 // Returns an array containing the items in |icons| without the unsupported
65 // image MIME types. 70 // image MIME types.
66 static std::vector<content::Manifest::Icon> FilterIconsByType( 71 static std::vector<content::Manifest::Icon> FilterIconsByType(
67 const std::vector<content::Manifest::Icon>& icons); 72 const std::vector<content::Manifest::Icon>& icons);
68 73
69 // Returns whether the 'any' (ie. gfx::Size(0,0)) is in |sizes|. 74 // Returns whether the 'any' (ie. gfx::Size(0,0)) is in |sizes|.
70 static bool IconSizesContainsAny(const std::vector<gfx::Size>& sizes); 75 static bool IconSizesContainsAny(const std::vector<gfx::Size>& sizes);
71 76
72 const int preferred_icon_size_in_pixels_; 77 const int preferred_icon_size_in_pixels_;
78 const int minimum_icon_size_in_pixels_;
73 79
74 friend class ManifestIconSelectorTest; 80 friend class ManifestIconSelectorTest;
75 81
76 DISALLOW_COPY_AND_ASSIGN(ManifestIconSelector); 82 DISALLOW_COPY_AND_ASSIGN(ManifestIconSelector);
77 }; 83 };
78 84
79 #endif // CHROME_BROWSER_MANIFEST_MANIFEST_ICON_SELECTOR_H_ 85 #endif // CHROME_BROWSER_MANIFEST_MANIFEST_ICON_SELECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698