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

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: Removing 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"
mlamouri (slow - plz ping) 2015/01/30 19:25:42 nit: you might want to include gurl.h here.
gone 2015/01/30 20:08:11 Done.
10
11 namespace content {
12 class WebContents;
13 } // namespace content
14
15 namespace IPC {
16 class Message;
17 }
mlamouri (slow - plz ping) 2015/01/30 19:25:43 nit: "// namespace IPC"
gone 2015/01/30 20:08:11 Done.
18
19 class GURL;
20
21 // Selects the icon most closely matching the size constraints.
mlamouri (slow - plz ping) 2015/01/30 19:25:42 nit: I would specify that this is following very b
gone 2015/01/30 20:08:11 Done.
22 class ManifestIconSelector {
23 public:
24 ManifestIconSelector(content::WebContents* web_contents,
mlamouri (slow - plz ping) 2015/01/30 19:25:42 Instead of having a constructor that takes a WebCo
gone 2015/01/30 20:08:11 Done.
25 int preferred_size_in_dp);
26 virtual ~ManifestIconSelector() {}
27
28 // Runs the algorithm to find the best matching icon in the icons listed in
29 // the Manifest.
30 // Returns the icon url if a suitable icon is found. An empty URL otherwise.
31 GURL FindBestMatchingIcon(
32 const std::vector<content::Manifest::Icon>& icons,
33 content::WebContents* web_contents) const;
34
35 private:
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 GURL FindBestMatchingIcon(const std::vector<content::Manifest::Icon>& icons,
46 float density) const;
47
48 // Returns whether the preferred_icon_size_in_px_ is in the given |sizes|.
49 bool IconSizesContainsPreferredSize(
50 const std::vector<gfx::Size>& sizes) const;
51
52 // Returns whether the 'any' (ie. gfx::Size(0,0)) is in the given |sizes|.
53 bool IconSizesContainsAny(const std::vector<gfx::Size>& sizes) const;
54
55 const int preferred_icon_size_in_px_;
56
57 friend class ManifestIconSelectorTest;
58
59 DISALLOW_COPY_AND_ASSIGN(ManifestIconSelector);
60 };
61
62 #endif // CHROME_BROWSER_ANDROID_MANIFEST_ICON_SELECTOR_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/manifest_icon_selector.cc » ('j') | chrome/browser/android/manifest_icon_selector.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698