OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_ANDROID_MANIFEST_ICON_SELECTOR_H_ | |
6 #define CHROME_BROWSER_ANDROID_MANIFEST_ICON_SELECTOR_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "content/public/common/manifest.h" | |
10 #include "url/gurl.h" | |
11 | |
12 namespace content { | |
13 class WebContents; | |
14 } // namespace content | |
15 | |
16 namespace IPC { | |
17 class Message; | |
18 } // namespace IPC | |
19 | |
20 // Selects the icon most closely matching the size constraints. This follows | |
21 // very basic heuristics -- improvements are welcome. | |
22 class ManifestIconSelector { | |
23 public: | |
24 // Runs the algorithm to find the best matching icon in the icons listed in | |
25 // the Manifest. | |
26 // Returns the icon url if a suitable icon is found. An empty URL otherwise. | |
mlamouri (slow - plz ping)
2015/02/03 17:14:14
Could you point that the preferred size is in dp,
gone
2015/02/03 19:25:06
Done.
| |
27 static GURL FindBestMatchingIcon( | |
28 const std::vector<content::Manifest::Icon>& icons, | |
29 float preferred_size_in_dp, | |
30 content::WebContents* web_contents); | |
mlamouri (slow - plz ping)
2015/02/03 17:14:14
It seems unfortunate to pass a WebContents when we
gone
2015/02/03 19:25:06
Passing in just the screen now.
| |
31 | |
32 private: | |
33 ManifestIconSelector() {} | |
34 virtual ~ManifestIconSelector() {} | |
35 | |
36 // Returns an array containing the items in |icons| without the unsupported | |
37 // image MIME types. | |
38 static std::vector<content::Manifest::Icon> FilterIconsByType( | |
39 const std::vector<content::Manifest::Icon>& icons); | |
40 | |
41 // Runs an algorithm only based on icon declared sizes. It will try to find | |
42 // size that is the closest to preferred_icon_size_in_px_ but bigger than | |
43 // preferred_icon_size_in_px_ if possible. | |
44 // Returns the icon url if a suitable icon is found. An empty URL otherwise. | |
45 static GURL FindBestMatchingIcon( | |
46 const std::vector<content::Manifest::Icon>& icons, | |
47 float density, | |
48 int preferred_icon_size_in_px); | |
mlamouri (slow - plz ping)
2015/02/03 17:14:14
If you want to pass |preferred_icon_size_in_px| to
gone
2015/02/03 19:25:05
Done.
| |
49 | |
50 // Returns whether the |preferred_icon_size_in_px| is in the given |sizes|. | |
51 static bool IconSizesContainsPreferredSize( | |
52 const std::vector<gfx::Size>& sizes, | |
53 int preferred_icon_size_in_px); | |
54 | |
55 // Returns whether the 'any' (ie. gfx::Size(0,0)) is in the given |sizes|. | |
56 static bool IconSizesContainsAny(const std::vector<gfx::Size>& sizes); | |
57 | |
58 friend class ManifestIconSelectorTest; | |
59 | |
60 DISALLOW_COPY_AND_ASSIGN(ManifestIconSelector); | |
61 }; | |
62 | |
63 #endif // CHROME_BROWSER_ANDROID_MANIFEST_ICON_SELECTOR_H_ | |
OLD | NEW |