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" |
11 #include "base/strings/string16.h" | |
12 #include "base/task/cancelable_task_tracker.h" | 11 #include "base/task/cancelable_task_tracker.h" |
| 12 #include "chrome/browser/android/shortcut_info.h" |
13 #include "chrome/common/web_application_info.h" | 13 #include "chrome/common/web_application_info.h" |
14 #include "components/favicon_base/favicon_types.h" | 14 #include "components/favicon_base/favicon_types.h" |
15 #include "content/public/browser/web_contents_observer.h" | 15 #include "content/public/browser/web_contents_observer.h" |
16 #include "content/public/common/manifest.h" | 16 #include "content/public/common/manifest.h" |
17 #include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h" | |
18 | 17 |
19 namespace content { | 18 namespace content { |
20 class WebContents; | 19 class WebContents; |
21 } // namespace content | 20 } // namespace content |
22 | 21 |
23 namespace IPC { | 22 namespace IPC { |
24 class Message; | 23 class Message; |
25 } | 24 } |
26 | 25 |
27 class GURL; | 26 class GURL; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 void OnDidGetFavicon( | 77 void OnDidGetFavicon( |
79 const favicon_base::FaviconRawBitmapResult& bitmap_result); | 78 const favicon_base::FaviconRawBitmapResult& bitmap_result); |
80 | 79 |
81 // WebContentsObserver | 80 // WebContentsObserver |
82 virtual bool OnMessageReceived(const IPC::Message& message) override; | 81 virtual bool OnMessageReceived(const IPC::Message& message) override; |
83 virtual void WebContentsDestroyed() override; | 82 virtual void WebContentsDestroyed() override; |
84 | 83 |
85 // Adds a shortcut to the launcher using a FaviconRawBitmapResult. | 84 // Adds a shortcut to the launcher using a FaviconRawBitmapResult. |
86 // Must be called from a WorkerPool task. | 85 // Must be called from a WorkerPool task. |
87 static void AddShortcutInBackgroundWithRawBitmap( | 86 static void AddShortcutInBackgroundWithRawBitmap( |
88 const GURL& url, | 87 const ShortcutInfo& info, |
89 const base::string16& title, | 88 const favicon_base::FaviconRawBitmapResult& bitmap_result); |
90 content::Manifest::DisplayMode display, | |
91 const favicon_base::FaviconRawBitmapResult& bitmap_result, | |
92 blink::WebScreenOrientationLockType orientation); | |
93 | 89 |
94 // Adds a shortcut to the launcher using a SkBitmap. | 90 // Adds a shortcut to the launcher using a SkBitmap. |
95 // Must be called from a WorkerPool task. | 91 // Must be called from a WorkerPool task. |
96 static void AddShortcutInBackgroundWithSkBitmap( | 92 static void AddShortcutInBackgroundWithSkBitmap( |
97 const GURL& url, | 93 const ShortcutInfo& info, |
98 const base::string16& title, | 94 const SkBitmap& icon_bitmap); |
99 content::Manifest::DisplayMode display, | |
100 const SkBitmap& icon_bitmap, | |
101 blink::WebScreenOrientationLockType orientation); | |
102 | 95 |
103 // Registers JNI hooks. | 96 // Registers JNI hooks. |
104 static bool RegisterShortcutHelper(JNIEnv* env); | 97 static bool RegisterShortcutHelper(JNIEnv* env); |
105 | 98 |
106 private: | 99 private: |
107 enum ManifestIconStatus { | 100 enum ManifestIconStatus { |
108 MANIFEST_ICON_STATUS_NONE, | 101 MANIFEST_ICON_STATUS_NONE, |
109 MANIFEST_ICON_STATUS_FETCHING, | 102 MANIFEST_ICON_STATUS_FETCHING, |
110 MANIFEST_ICON_STATUS_DONE | 103 MANIFEST_ICON_STATUS_DONE |
111 }; | 104 }; |
(...skipping 22 matching lines...) Expand all Loading... |
134 | 127 |
135 // Returns whether the preferred_icon_size_in_px_ is in the given |sizes|. | 128 // Returns whether the preferred_icon_size_in_px_ is in the given |sizes|. |
136 bool IconSizesContainsPreferredSize( | 129 bool IconSizesContainsPreferredSize( |
137 const std::vector<gfx::Size>& sizes) const; | 130 const std::vector<gfx::Size>& sizes) const; |
138 | 131 |
139 // Returns whether the 'any' (ie. gfx::Size(0,0)) is in the given |sizes|. | 132 // Returns whether the 'any' (ie. gfx::Size(0,0)) is in the given |sizes|. |
140 bool IconSizesContainsAny(const std::vector<gfx::Size>& sizes) const; | 133 bool IconSizesContainsAny(const std::vector<gfx::Size>& sizes) const; |
141 | 134 |
142 JavaObjectWeakGlobalRef java_ref_; | 135 JavaObjectWeakGlobalRef java_ref_; |
143 | 136 |
144 GURL url_; | 137 ShortcutInfo shortcut_info_; |
145 base::string16 title_; | |
146 content::Manifest::DisplayMode display_; | |
147 SkBitmap manifest_icon_; | 138 SkBitmap manifest_icon_; |
148 base::CancelableTaskTracker cancelable_task_tracker_; | 139 base::CancelableTaskTracker cancelable_task_tracker_; |
149 blink::WebScreenOrientationLockType orientation_; | |
150 | 140 |
151 bool add_shortcut_requested_; | 141 bool add_shortcut_requested_; |
152 | 142 |
153 ManifestIconStatus manifest_icon_status_; | 143 ManifestIconStatus manifest_icon_status_; |
154 const int preferred_icon_size_in_px_; | 144 const int preferred_icon_size_in_px_; |
155 static const int kPreferredIconSizeInDp; | 145 static const int kPreferredIconSizeInDp; |
156 | 146 |
157 base::WeakPtrFactory<ShortcutHelper> weak_ptr_factory_; | 147 base::WeakPtrFactory<ShortcutHelper> weak_ptr_factory_; |
158 | 148 |
159 friend class ShortcutHelperTest; | 149 friend class ShortcutHelperTest; |
160 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); | 150 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); |
161 }; | 151 }; |
162 | 152 |
163 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ | 153 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ |
OLD | NEW |