Index: chrome/browser/android/manifest_icon_selector.h |
diff --git a/chrome/browser/android/manifest_icon_selector.h b/chrome/browser/android/manifest_icon_selector.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6e857b284fb7cade0f4a56d93a3980ced2c77812 |
--- /dev/null |
+++ b/chrome/browser/android/manifest_icon_selector.h |
@@ -0,0 +1,62 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_ANDROID_MANIFEST_ICON_SELECTOR_H_ |
+#define CHROME_BROWSER_ANDROID_MANIFEST_ICON_SELECTOR_H_ |
+ |
+#include "base/basictypes.h" |
+#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.
|
+ |
+namespace content { |
+class WebContents; |
+} // namespace content |
+ |
+namespace IPC { |
+class Message; |
+} |
mlamouri (slow - plz ping)
2015/01/30 19:25:43
nit: "// namespace IPC"
gone
2015/01/30 20:08:11
Done.
|
+ |
+class GURL; |
+ |
+// 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.
|
+class ManifestIconSelector { |
+ public: |
+ 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.
|
+ int preferred_size_in_dp); |
+ virtual ~ManifestIconSelector() {} |
+ |
+ // Runs the algorithm to find the best matching icon in the icons listed in |
+ // the Manifest. |
+ // Returns the icon url if a suitable icon is found. An empty URL otherwise. |
+ GURL FindBestMatchingIcon( |
+ const std::vector<content::Manifest::Icon>& icons, |
+ content::WebContents* web_contents) const; |
+ |
+ private: |
+ // Returns an array containing the items in |icons| without the unsupported |
+ // image MIME types. |
+ static std::vector<content::Manifest::Icon> FilterIconsByType( |
+ const std::vector<content::Manifest::Icon>& icons); |
+ |
+ // Runs an algorithm only based on icon declared sizes. It will try to find |
+ // size that is the closest to preferred_icon_size_in_px_ but bigger than |
+ // preferred_icon_size_in_px_ if possible. |
+ // Returns the icon url if a suitable icon is found. An empty URL otherwise. |
+ GURL FindBestMatchingIcon(const std::vector<content::Manifest::Icon>& icons, |
+ float density) const; |
+ |
+ // Returns whether the preferred_icon_size_in_px_ is in the given |sizes|. |
+ bool IconSizesContainsPreferredSize( |
+ const std::vector<gfx::Size>& sizes) const; |
+ |
+ // Returns whether the 'any' (ie. gfx::Size(0,0)) is in the given |sizes|. |
+ bool IconSizesContainsAny(const std::vector<gfx::Size>& sizes) const; |
+ |
+ const int preferred_icon_size_in_px_; |
+ |
+ friend class ManifestIconSelectorTest; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ManifestIconSelector); |
+}; |
+ |
+#endif // CHROME_BROWSER_ANDROID_MANIFEST_ICON_SELECTOR_H_ |