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 }; |
112 | 105 |
113 virtual ~ShortcutHelper(); | 106 virtual ~ShortcutHelper(); |
114 | 107 |
115 void Destroy(); | 108 void Destroy(); |
116 | 109 |
117 JavaObjectWeakGlobalRef java_ref_; | 110 JavaObjectWeakGlobalRef java_ref_; |
118 | 111 |
119 GURL url_; | 112 ShortcutInfo shortcut_info_; |
120 base::string16 title_; | |
121 content::Manifest::DisplayMode display_; | |
122 SkBitmap manifest_icon_; | 113 SkBitmap manifest_icon_; |
123 base::CancelableTaskTracker cancelable_task_tracker_; | 114 base::CancelableTaskTracker cancelable_task_tracker_; |
124 blink::WebScreenOrientationLockType orientation_; | |
125 | 115 |
126 bool add_shortcut_requested_; | 116 bool add_shortcut_requested_; |
127 | 117 |
128 ManifestIconStatus manifest_icon_status_; | 118 ManifestIconStatus manifest_icon_status_; |
129 const int preferred_icon_size_in_px_; | 119 const int preferred_icon_size_in_px_; |
130 static const int kPreferredIconSizeInDp; | 120 static const int kPreferredIconSizeInDp; |
131 | 121 |
132 base::WeakPtrFactory<ShortcutHelper> weak_ptr_factory_; | 122 base::WeakPtrFactory<ShortcutHelper> weak_ptr_factory_; |
133 | 123 |
134 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); | 124 DISALLOW_COPY_AND_ASSIGN(ShortcutHelper); |
135 }; | 125 }; |
136 | 126 |
137 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ | 127 #endif // CHROME_BROWSER_ANDROID_SHORTCUT_HELPER_H_ |
OLD | NEW |