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

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

Issue 880203004: Break out manifest icon logic from ShortcutHelper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Header removal Created 5 years, 10 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
(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.
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/01/30 22:32:13 Wouldn't that be better to not depend on WebConten
gone 2015/01/30 22:43:30 The logic is used in three different places, thoug
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);
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698