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

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

Issue 2589503002: Use exact pixel sizes instead of dip in webapp/WebAPK installability code (Closed)
Patch Set: Created 4 years 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"
11 11
12 // Selects the icon most closely matching the size constraints. This follows 12 // Selects the icon most closely matching the size constraints. This follows
13 // very basic heuristics -- improvements are welcome. 13 // very basic heuristics -- improvements are welcome.
14 class ManifestIconSelector { 14 class ManifestIconSelector {
15 public: 15 public:
16 // Runs the algorithm to find the best matching icon in the icons listed in 16 // Runs the algorithm to find the best matching icon in the icons listed in
17 // the Manifest. 17 // the Manifest.
18 // 18 //
19 // Size is defined in Android's density-independent pixels (dp): 19 // Size is defined in Android's density-independent pixels (dp):
20 // http://developer.android.com/guide/practices/screens_support.html 20 // http://developer.android.com/guide/practices/screens_support.html
21 // If/when this class is generalized, it may be a good idea to switch this to 21 // If/when this class is generalized, it may be a good idea to switch this to
22 // taking in pixels, instead. 22 // taking in pixels, instead.
23 // 23 //
24 // Any icon returned will be close as possible to |ideal_icon_size_in_dp| 24 // Any icon returned will be close as possible to |ideal_icon_size_in_px|
25 // with a size not less than |minimum_icon_size_in_dp|. 25 // with a size not less than |minimum_icon_size_in_px|.
26 // 26 //
27 // 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.
28 static GURL FindBestMatchingIcon( 28 static GURL FindBestMatchingIcon(
29 const std::vector<content::Manifest::Icon>& icons, 29 const std::vector<content::Manifest::Icon>& icons,
30 int ideal_icon_size_in_dp, 30 int ideal_icon_size_in_px,
31 int minimum_icon_size_in_dp); 31 int minimum_icon_size_in_px);
32
33 static int ConvertIconSizeFromDpToPx(int icon_size_in_dp);
34 32
35 private: 33 private:
36 ManifestIconSelector(int ideal_icon_size_in_px, 34 ManifestIconSelector(int ideal_icon_size_in_px,
37 int minimum_icon_size_in_px); 35 int minimum_icon_size_in_px);
38 virtual ~ManifestIconSelector() {} 36 virtual ~ManifestIconSelector() {}
39 37
40 // Returns the square icon that is the smallest icon larger than 38 // Returns the square icon that is the smallest icon larger than
41 // ideal_icon_size_in_px_ (if it exists), or the largest icon smaller than 39 // ideal_icon_size_in_px_ (if it exists), or the largest icon smaller than
42 // ideal_icon_size_in_px_ otherwise. 40 // ideal_icon_size_in_px_ otherwise.
43 int FindClosestIconToIdealSize( 41 int FindClosestIconToIdealSize(
(...skipping 24 matching lines...) Expand all
68 66
69 const int ideal_icon_size_in_px_; 67 const int ideal_icon_size_in_px_;
70 const int minimum_icon_size_in_px_; 68 const int minimum_icon_size_in_px_;
71 69
72 friend class ManifestIconSelectorTest; 70 friend class ManifestIconSelectorTest;
73 71
74 DISALLOW_COPY_AND_ASSIGN(ManifestIconSelector); 72 DISALLOW_COPY_AND_ASSIGN(ManifestIconSelector);
75 }; 73 };
76 74
77 #endif // CHROME_BROWSER_MANIFEST_MANIFEST_ICON_SELECTOR_H_ 75 #endif // CHROME_BROWSER_MANIFEST_MANIFEST_ICON_SELECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698