| OLD | NEW |
| 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" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 enum ManifestIconStatus { | 107 enum ManifestIconStatus { |
| 108 MANIFEST_ICON_STATUS_NONE, | 108 MANIFEST_ICON_STATUS_NONE, |
| 109 MANIFEST_ICON_STATUS_FETCHING, | 109 MANIFEST_ICON_STATUS_FETCHING, |
| 110 MANIFEST_ICON_STATUS_DONE | 110 MANIFEST_ICON_STATUS_DONE |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 virtual ~ShortcutHelper(); | 113 virtual ~ShortcutHelper(); |
| 114 | 114 |
| 115 void Destroy(); | 115 void Destroy(); |
| 116 | 116 |
| 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_; | 117 JavaObjectWeakGlobalRef java_ref_; |
| 143 | 118 |
| 144 GURL url_; | 119 GURL url_; |
| 145 base::string16 title_; | 120 base::string16 title_; |
| 146 content::Manifest::DisplayMode display_; | 121 content::Manifest::DisplayMode display_; |
| 147 SkBitmap manifest_icon_; | 122 SkBitmap manifest_icon_; |
| 148 base::CancelableTaskTracker cancelable_task_tracker_; | 123 base::CancelableTaskTracker cancelable_task_tracker_; |
| 149 blink::WebScreenOrientationLockType orientation_; | 124 blink::WebScreenOrientationLockType orientation_; |
| 150 | 125 |
| 151 bool add_shortcut_requested_; | 126 bool add_shortcut_requested_; |
| 152 | 127 |
| 153 ManifestIconStatus manifest_icon_status_; | 128 ManifestIconStatus manifest_icon_status_; |
| 154 const int preferred_icon_size_in_px_; | 129 const int preferred_icon_size_in_px_; |
| 155 static const int kPreferredIconSizeInDp; | 130 static const int kPreferredIconSizeInDp; |
| 156 | 131 |
| 157 base::WeakPtrFactory<ShortcutHelper> weak_ptr_factory_; | 132 base::WeakPtrFactory<ShortcutHelper> weak_ptr_factory_; |
| 158 | 133 |
| 159 friend class ShortcutHelperTest; | |
| 160 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); | 134 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); |
| 161 }; | 135 }; |
| 162 | 136 |
| 163 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ | 137 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ |
| OLD | NEW |