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

Side by Side Diff: chrome/browser/manifest/manifest_icon_selector.h

Issue 1826753002: Log the expected icon size when no suitable icon for a banner is found. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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/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 24 matching lines...) Expand all
35 // 35 //
36 // Any icon returned will be close as possible to |ideal_icon_size_in_dp| 36 // Any icon returned will be close as possible to |ideal_icon_size_in_dp|
37 // with a size not less than |minimum_icon_size_in_dp|. 37 // with a size not less than |minimum_icon_size_in_dp|.
38 // 38 //
39 // Returns the icon url if a suitable icon is found. An empty URL otherwise. 39 // Returns the icon url if a suitable icon is found. An empty URL otherwise.
40 static GURL FindBestMatchingIcon( 40 static GURL FindBestMatchingIcon(
41 const std::vector<content::Manifest::Icon>& icons, 41 const std::vector<content::Manifest::Icon>& icons,
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);
46
45 private: 47 private:
46 ManifestIconSelector(int ideal_icon_size_in_px, 48 ManifestIconSelector(int ideal_icon_size_in_px,
47 int minimum_icon_size_in_px); 49 int minimum_icon_size_in_px);
48 virtual ~ManifestIconSelector() {} 50 virtual ~ManifestIconSelector() {}
49 51
50 // Runs the algorithm to find the best matching icon in the icons listed in 52 // Runs the algorithm to find the best matching icon in the icons listed in
51 // the Manifest. 53 // the Manifest.
52 // Returns the icon url if a suitable icon is found. An empty URL otherwise. 54 // Returns the icon url if a suitable icon is found. An empty URL otherwise.
53 int FindBestMatchingIcon( 55 int FindBestMatchingIcon(const std::vector<content::Manifest::Icon>& icons);
54 const std::vector<content::Manifest::Icon>& icons,
55 float density);
56 56
57 // Runs an algorithm only based on icon declared sizes. It will try to find 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 58 // size that is the closest to preferred_icon_size_in_pixels_ but bigger than
59 // preferred_icon_size_in_pixels_ if possible. 59 // preferred_icon_size_in_pixels_ if possible.
60 // Returns the index of a suitable icon if one is found. -1 otherwise. 60 // Returns the index of a suitable icon if one is found. -1 otherwise.
61 int FindBestMatchingIconForDensity( 61 int FindBestMatchingIconForDensity(
62 const std::vector<content::Manifest::Icon>& icons, 62 const std::vector<content::Manifest::Icon>& icons,
63 float density); 63 float density);
64 64
65 // Returns whether the |preferred_icon_size_in_pixels_| is in |sizes|. 65 // Returns whether the |preferred_icon_size_in_pixels_| is in |sizes|.
66 bool IconSizesContainsPreferredSize(const std::vector<gfx::Size>& sizes); 66 bool IconSizesContainsPreferredSize(const std::vector<gfx::Size>& sizes);
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);
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_;
83 84
84 friend class ManifestIconSelectorTest; 85 friend class ManifestIconSelectorTest;
85 86
86 DISALLOW_COPY_AND_ASSIGN(ManifestIconSelector); 87 DISALLOW_COPY_AND_ASSIGN(ManifestIconSelector);
87 }; 88 };
88 89
89 #endif // CHROME_BROWSER_MANIFEST_MANIFEST_ICON_SELECTOR_H_ 90 #endif // CHROME_BROWSER_MANIFEST_MANIFEST_ICON_SELECTOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/banners/app_banner_debug_log.cc ('k') | chrome/browser/manifest/manifest_icon_selector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698