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

Side by Side Diff: chrome/browser/android/shortcut_helper.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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_ANDROID_SHORTCUT_HELPER_H_ 5 #ifndef CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_
6 #define CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ 6 #define CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_
7 7
8 #include "base/android/jni_android.h" 8 #include "base/android/jni_android.h"
9 #include "base/android/jni_weak_ref.h" 9 #include "base/android/jni_weak_ref.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 #include "base/task/cancelable_task_tracker.h" 12 #include "base/task/cancelable_task_tracker.h"
13 #include "chrome/browser/android/manifest_icon_selector.h"
13 #include "chrome/common/web_application_info.h" 14 #include "chrome/common/web_application_info.h"
14 #include "components/favicon_base/favicon_types.h" 15 #include "components/favicon_base/favicon_types.h"
15 #include "content/public/browser/web_contents_observer.h" 16 #include "content/public/browser/web_contents_observer.h"
16 #include "content/public/common/manifest.h" 17 #include "content/public/common/manifest.h"
17 #include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h" 18 #include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h"
18 19
19 namespace content { 20 namespace content {
20 class WebContents; 21 class WebContents;
21 } // namespace content 22 } // namespace content
22 23
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 enum ManifestIconStatus { 108 enum ManifestIconStatus {
108 MANIFEST_ICON_STATUS_NONE, 109 MANIFEST_ICON_STATUS_NONE,
109 MANIFEST_ICON_STATUS_FETCHING, 110 MANIFEST_ICON_STATUS_FETCHING,
110 MANIFEST_ICON_STATUS_DONE 111 MANIFEST_ICON_STATUS_DONE
111 }; 112 };
112 113
113 virtual ~ShortcutHelper(); 114 virtual ~ShortcutHelper();
114 115
115 void Destroy(); 116 void Destroy();
116 117
117 // Runs the algorithm to find the best matching icon in the icons listed in
118 // the Manifest.
119 // Returns the icon url if a suitable icon is found. An empty URL otherwise.
120 GURL FindBestMatchingIcon(
121 const std::vector<content::Manifest::Icon>& icons) const;
122
123 // Runs an algorithm only based on icon declared sizes. It will try to find
124 // size that is the closest to preferred_icon_size_in_px_ but bigger than
125 // preferred_icon_size_in_px_ if possible.
126 // Returns the icon url if a suitable icon is found. An empty URL otherwise.
127 GURL FindBestMatchingIcon(const std::vector<content::Manifest::Icon>& icons,
128 float density) const;
129
130 // Returns an array containing the items in |icons| without the unsupported
131 // image MIME types.
132 static std::vector<content::Manifest::Icon> FilterIconsByType(
133 const std::vector<content::Manifest::Icon>& icons);
134
135 // Returns whether the preferred_icon_size_in_px_ is in the given |sizes|.
136 bool IconSizesContainsPreferredSize(
137 const std::vector<gfx::Size>& sizes) const;
138
139 // Returns whether the 'any' (ie. gfx::Size(0,0)) is in the given |sizes|.
140 bool IconSizesContainsAny(const std::vector<gfx::Size>& sizes) const;
141
142 JavaObjectWeakGlobalRef java_ref_; 118 JavaObjectWeakGlobalRef java_ref_;
143 119
144 GURL url_; 120 GURL url_;
145 base::string16 title_; 121 base::string16 title_;
146 content::Manifest::DisplayMode display_; 122 content::Manifest::DisplayMode display_;
147 SkBitmap manifest_icon_; 123 SkBitmap manifest_icon_;
148 base::CancelableTaskTracker cancelable_task_tracker_; 124 base::CancelableTaskTracker cancelable_task_tracker_;
149 blink::WebScreenOrientationLockType orientation_; 125 blink::WebScreenOrientationLockType orientation_;
150 126
151 bool add_shortcut_requested_; 127 bool add_shortcut_requested_;
152 128
129 ManifestIconSelector manifest_icon_selector_;
153 ManifestIconStatus manifest_icon_status_; 130 ManifestIconStatus manifest_icon_status_;
154 const int preferred_icon_size_in_px_; 131 const int preferred_icon_size_in_px_;
155 static const int kPreferredIconSizeInDp; 132 static const int kPreferredIconSizeInDp;
156 133
157 base::WeakPtrFactory<ShortcutHelper> weak_ptr_factory_; 134 base::WeakPtrFactory<ShortcutHelper> weak_ptr_factory_;
158 135
159 friend class ShortcutHelperTest;
160 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); 136 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper);
161 }; 137 };
162 138
163 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ 139 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698