OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ |
6 #define CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ | 6 #define CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
11 #include "base/android/jni_helper.h" | 11 #include "base/android/jni_helper.h" |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/process/process.h" | 16 #include "base/process/process.h" |
17 #include "content/browser/renderer_host/input/touch_disposition_gesture_filter.h
" | 17 #include "content/browser/renderer_host/input/content_gesture_provider.h" |
18 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 18 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
19 #include "content/browser/web_contents/web_contents_impl.h" | 19 #include "content/browser/web_contents/web_contents_impl.h" |
20 #include "content/public/browser/android/content_view_core.h" | 20 #include "content/public/browser/android/content_view_core.h" |
21 #include "content/public/browser/notification_observer.h" | 21 #include "content/public/browser/notification_observer.h" |
22 #include "content/public/browser/notification_registrar.h" | 22 #include "content/public/browser/notification_registrar.h" |
23 #include "content/public/browser/web_contents_observer.h" | 23 #include "content/public/browser/web_contents_observer.h" |
24 #include "third_party/WebKit/public/web/WebInputEvent.h" | 24 #include "third_party/WebKit/public/web/WebInputEvent.h" |
25 #include "ui/gfx/rect.h" | 25 #include "ui/gfx/rect.h" |
26 #include "ui/gfx/rect_f.h" | 26 #include "ui/gfx/rect_f.h" |
27 #include "url/gurl.h" | 27 #include "url/gurl.h" |
28 | 28 |
29 namespace ui { | 29 namespace ui { |
30 class ViewAndroid; | 30 class ViewAndroid; |
31 class WindowAndroid; | 31 class WindowAndroid; |
32 } | 32 } |
33 | 33 |
34 namespace content { | 34 namespace content { |
35 class RenderWidgetHostViewAndroid; | 35 class RenderWidgetHostViewAndroid; |
36 struct MenuItem; | 36 struct MenuItem; |
| 37 struct NativeWebTouchEvent; |
37 | 38 |
38 // TODO(jrg): this is a shell. Upstream the rest. | 39 // TODO(jrg): this is a shell. Upstream the rest. |
39 class ContentViewCoreImpl : public ContentViewCore, | 40 class ContentViewCoreImpl : public ContentViewCore, |
| 41 public ContentGestureProviderClient, |
40 public NotificationObserver, | 42 public NotificationObserver, |
41 public TouchDispositionGestureFilterClient, | |
42 public WebContentsObserver { | 43 public WebContentsObserver { |
43 public: | 44 public: |
44 static ContentViewCoreImpl* FromWebContents(WebContents* web_contents); | 45 static ContentViewCoreImpl* FromWebContents(WebContents* web_contents); |
45 ContentViewCoreImpl(JNIEnv* env, | 46 ContentViewCoreImpl(JNIEnv* env, |
46 jobject obj, | 47 jobject obj, |
47 WebContents* web_contents, | 48 WebContents* web_contents, |
48 ui::ViewAndroid* view_android, | 49 ui::ViewAndroid* view_android, |
49 ui::WindowAndroid* window_android); | 50 ui::WindowAndroid* window_android); |
50 | 51 |
51 // ContentViewCore implementation. | 52 // ContentViewCore implementation. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 jstring extra_headers, | 91 jstring extra_headers, |
91 jbyteArray post_data, | 92 jbyteArray post_data, |
92 jstring base_url_for_data_url, | 93 jstring base_url_for_data_url, |
93 jstring virtual_url_for_data_url, | 94 jstring virtual_url_for_data_url, |
94 jboolean can_load_local_resources); | 95 jboolean can_load_local_resources); |
95 base::android::ScopedJavaLocalRef<jstring> GetURL(JNIEnv* env, jobject) const; | 96 base::android::ScopedJavaLocalRef<jstring> GetURL(JNIEnv* env, jobject) const; |
96 base::android::ScopedJavaLocalRef<jstring> GetTitle( | 97 base::android::ScopedJavaLocalRef<jstring> GetTitle( |
97 JNIEnv* env, jobject obj) const; | 98 JNIEnv* env, jobject obj) const; |
98 jboolean IsIncognito(JNIEnv* env, jobject obj); | 99 jboolean IsIncognito(JNIEnv* env, jobject obj); |
99 void SendOrientationChangeEvent(JNIEnv* env, jobject obj, jint orientation); | 100 void SendOrientationChangeEvent(JNIEnv* env, jobject obj, jint orientation); |
100 void OnTouchEventHandlingBegin(JNIEnv* env, | 101 jboolean OnTouchEvent(JNIEnv* env, |
101 jobject obj, | 102 jobject obj, |
102 jobject motion_event); | 103 jobject motion_event); |
103 void OnTouchEventHandlingEnd(JNIEnv* env, jobject obj); | |
104 jboolean SendMouseMoveEvent(JNIEnv* env, | 104 jboolean SendMouseMoveEvent(JNIEnv* env, |
105 jobject obj, | 105 jobject obj, |
106 jlong time_ms, | 106 jlong time_ms, |
107 jfloat x, | 107 jfloat x, |
108 jfloat y); | 108 jfloat y); |
109 jboolean SendMouseWheelEvent(JNIEnv* env, | 109 jboolean SendMouseWheelEvent(JNIEnv* env, |
110 jobject obj, | 110 jobject obj, |
111 jlong time_ms, | 111 jlong time_ms, |
112 jfloat x, | 112 jfloat x, |
113 jfloat y, | 113 jfloat y, |
114 jfloat vertical_axis); | 114 jfloat vertical_axis); |
115 void ScrollBegin(JNIEnv* env, jobject obj, jlong time_ms, | 115 void ScrollBegin(JNIEnv* env, jobject obj, jlong time_ms, |
116 jfloat x, jfloat y, jfloat hintx, jfloat hinty); | 116 jfloat x, jfloat y, jfloat hintx, jfloat hinty); |
117 void ScrollEnd(JNIEnv* env, jobject obj, jlong time_ms); | 117 void ScrollEnd(JNIEnv* env, jobject obj, jlong time_ms); |
118 void ScrollBy(JNIEnv* env, jobject obj, jlong time_ms, | 118 void ScrollBy(JNIEnv* env, jobject obj, jlong time_ms, |
119 jfloat x, jfloat y, jfloat dx, jfloat dy); | 119 jfloat x, jfloat y, jfloat dx, jfloat dy); |
120 void FlingStart(JNIEnv* env, jobject obj, jlong time_ms, | 120 void FlingStart(JNIEnv* env, jobject obj, jlong time_ms, |
121 jfloat x, jfloat y, jfloat vx, jfloat vy); | 121 jfloat x, jfloat y, jfloat vx, jfloat vy); |
122 void FlingCancel(JNIEnv* env, jobject obj, jlong time_ms); | 122 void FlingCancel(JNIEnv* env, jobject obj, jlong time_ms); |
123 void SingleTap(JNIEnv* env, jobject obj, jlong time_ms, | 123 void SingleTap(JNIEnv* env, jobject obj, jlong time_ms, |
124 jfloat x, jfloat y, | 124 jfloat x, jfloat y, |
125 jboolean disambiguation_popup_tap); | 125 jboolean disambiguation_popup_tap); |
126 void SingleTapUnconfirmed(JNIEnv* env, jobject obj, jlong time_ms, | |
127 jfloat x, jfloat y); | |
128 void ShowPress(JNIEnv* env, jobject obj, jlong time_ms, | |
129 jfloat x, jfloat y); | |
130 void TapCancel(JNIEnv* env, jobject obj, jlong time_ms, | |
131 jfloat x, jfloat y); | |
132 void TapDown(JNIEnv* env, jobject obj, jlong time_ms, | |
133 jfloat x, jfloat y); | |
134 void DoubleTap(JNIEnv* env, jobject obj, jlong time_ms, | 126 void DoubleTap(JNIEnv* env, jobject obj, jlong time_ms, |
135 jfloat x, jfloat y) ; | 127 jfloat x, jfloat y) ; |
136 void LongPress(JNIEnv* env, jobject obj, jlong time_ms, | 128 void LongPress(JNIEnv* env, jobject obj, jlong time_ms, |
137 jfloat x, jfloat y, | 129 jfloat x, jfloat y, |
138 jboolean disambiguation_popup_tap); | 130 jboolean disambiguation_popup_tap); |
139 void LongTap(JNIEnv* env, jobject obj, jlong time_ms, | |
140 jfloat x, jfloat y, | |
141 jboolean disambiguation_popup_tap); | |
142 void PinchBegin(JNIEnv* env, jobject obj, jlong time_ms, jfloat x, jfloat y); | 131 void PinchBegin(JNIEnv* env, jobject obj, jlong time_ms, jfloat x, jfloat y); |
143 void PinchEnd(JNIEnv* env, jobject obj, jlong time_ms); | 132 void PinchEnd(JNIEnv* env, jobject obj, jlong time_ms); |
144 void PinchBy(JNIEnv* env, jobject obj, jlong time_ms, | 133 void PinchBy(JNIEnv* env, jobject obj, jlong time_ms, |
145 jfloat x, jfloat y, jfloat delta); | 134 jfloat x, jfloat y, jfloat delta); |
146 void SelectBetweenCoordinates(JNIEnv* env, jobject obj, | 135 void SelectBetweenCoordinates(JNIEnv* env, jobject obj, |
147 jfloat x1, jfloat y1, | 136 jfloat x1, jfloat y1, |
148 jfloat x2, jfloat y2); | 137 jfloat x2, jfloat y2); |
149 void MoveCaret(JNIEnv* env, jobject obj, jfloat x, jfloat y); | 138 void MoveCaret(JNIEnv* env, jobject obj, jfloat x, jfloat y); |
150 | 139 |
| 140 void ResetGestureDetectors(JNIEnv* env, jobject obj); |
| 141 void IgnoreRemainingTouchEvents(JNIEnv* env, jobject obj); |
| 142 void OnWindowFocusLost(JNIEnv* env, jobject obj); |
| 143 void UpdateDoubleTapSupportForPage(JNIEnv* env, |
| 144 jobject obj, |
| 145 jboolean has_support); |
| 146 void UpdateDoubleTapSupport(JNIEnv* env, jobject obj, jboolean has_support); |
| 147 void UpdateMultiTouchZoomSupport(JNIEnv* env, |
| 148 jobject obj, |
| 149 jboolean has_support); |
| 150 jboolean IsScrollOrPinchInProgress(JNIEnv* env, jobject obj); |
| 151 |
151 void LoadIfNecessary(JNIEnv* env, jobject obj); | 152 void LoadIfNecessary(JNIEnv* env, jobject obj); |
152 void RequestRestoreLoad(JNIEnv* env, jobject obj); | 153 void RequestRestoreLoad(JNIEnv* env, jobject obj); |
153 void StopLoading(JNIEnv* env, jobject obj); | 154 void StopLoading(JNIEnv* env, jobject obj); |
154 void Reload(JNIEnv* env, jobject obj, jboolean check_for_repost); | 155 void Reload(JNIEnv* env, jobject obj, jboolean check_for_repost); |
155 void ReloadIgnoringCache(JNIEnv* env, jobject obj, jboolean check_for_repost); | 156 void ReloadIgnoringCache(JNIEnv* env, jobject obj, jboolean check_for_repost); |
156 void CancelPendingReload(JNIEnv* env, jobject obj); | 157 void CancelPendingReload(JNIEnv* env, jobject obj); |
157 void ContinuePendingReload(JNIEnv* env, jobject obj); | 158 void ContinuePendingReload(JNIEnv* env, jobject obj); |
158 void ClearHistory(JNIEnv* env, jobject obj); | 159 void ClearHistory(JNIEnv* env, jobject obj); |
159 void EvaluateJavaScript(JNIEnv* env, | 160 void EvaluateJavaScript(JNIEnv* env, |
160 jobject obj, | 161 jobject obj, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 jstring jurl, | 216 jstring jurl, |
216 jint delegate); | 217 jint delegate); |
217 jboolean IsShowingInterstitialPage(JNIEnv* env, jobject obj); | 218 jboolean IsShowingInterstitialPage(JNIEnv* env, jobject obj); |
218 | 219 |
219 void AttachExternalVideoSurface(JNIEnv* env, | 220 void AttachExternalVideoSurface(JNIEnv* env, |
220 jobject obj, | 221 jobject obj, |
221 jint player_id, | 222 jint player_id, |
222 jobject jsurface); | 223 jobject jsurface); |
223 void DetachExternalVideoSurface(JNIEnv* env, jobject obj, jint player_id); | 224 void DetachExternalVideoSurface(JNIEnv* env, jobject obj, jint player_id); |
224 void SetAccessibilityEnabled(JNIEnv* env, jobject obj, bool enabled); | 225 void SetAccessibilityEnabled(JNIEnv* env, jobject obj, bool enabled); |
225 void SendActionAfterDoubleTapUma(JNIEnv* env, | |
226 jobject obj, | |
227 jint type, | |
228 jboolean has_delay, | |
229 jint count); | |
230 void SendSingleTapUma(JNIEnv* env, jobject obj, jint type, jint count); | |
231 | 226 |
232 void ExtractSmartClipData(JNIEnv* env, | 227 void ExtractSmartClipData(JNIEnv* env, |
233 jobject obj, | 228 jobject obj, |
234 jint x, | 229 jint x, |
235 jint y, | 230 jint y, |
236 jint width, | 231 jint width, |
237 jint height); | 232 jint height); |
238 // -------------------------------------------------------------------------- | 233 // -------------------------------------------------------------------------- |
239 // Public methods that call to Java via JNI | 234 // Public methods that call to Java via JNI |
240 // -------------------------------------------------------------------------- | 235 // -------------------------------------------------------------------------- |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 | 324 |
330 // NotificationObserver implementation. | 325 // NotificationObserver implementation. |
331 virtual void Observe(int type, | 326 virtual void Observe(int type, |
332 const NotificationSource& source, | 327 const NotificationSource& source, |
333 const NotificationDetails& details) OVERRIDE; | 328 const NotificationDetails& details) OVERRIDE; |
334 | 329 |
335 // WebContentsObserver implementation. | 330 // WebContentsObserver implementation. |
336 virtual void RenderViewReady() OVERRIDE; | 331 virtual void RenderViewReady() OVERRIDE; |
337 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE; | 332 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE; |
338 | 333 |
339 // TouchDispositionGestureFilterClient implementation. | 334 // ContentGestureProviderClient implementation. |
340 virtual void ForwardGestureEvent( | 335 virtual void OnGestureEvent(const blink::WebGestureEvent& event) OVERRIDE; |
341 const blink::WebGestureEvent& event) OVERRIDE; | |
342 | 336 |
343 // -------------------------------------------------------------------------- | 337 // -------------------------------------------------------------------------- |
344 // Other private methods and data | 338 // Other private methods and data |
345 // -------------------------------------------------------------------------- | 339 // -------------------------------------------------------------------------- |
346 | 340 |
347 void InitWebContents(); | 341 void InitWebContents(); |
348 | 342 |
349 RenderWidgetHostViewAndroid* GetRenderWidgetHostViewAndroid(); | 343 RenderWidgetHostViewAndroid* GetRenderWidgetHostViewAndroid(); |
350 | 344 |
351 float GetTouchPaddingDip(); | 345 float GetTouchPaddingDip(); |
352 | 346 |
353 blink::WebGestureEvent MakeGestureEvent( | 347 blink::WebGestureEvent MakeGestureEvent( |
354 blink::WebInputEvent::Type type, int64 time_ms, float x, float y) const; | 348 blink::WebInputEvent::Type type, int64 time_ms, float x, float y) const; |
355 | 349 |
356 void SendBeginFrame(base::TimeTicks frame_time); | 350 void SendBeginFrame(base::TimeTicks frame_time); |
357 | 351 |
358 gfx::Size GetViewportSizePix() const; | 352 gfx::Size GetViewportSizePix() const; |
359 gfx::Size GetViewportSizeOffsetPix() const; | 353 gfx::Size GetViewportSizeOffsetPix() const; |
360 | 354 |
361 void DeleteScaledSnapshotTexture(); | 355 void DeleteScaledSnapshotTexture(); |
362 | 356 |
363 void SendGestureEvent(const blink::WebGestureEvent& event); | 357 void SendGestureEvent(const blink::WebGestureEvent& event); |
364 void SendSyntheticGestureEvent(const blink::WebGestureEvent& event); | |
365 | 358 |
366 // Update focus state of the RenderWidgetHostView. | 359 // Update focus state of the RenderWidgetHostView. |
367 void SetFocusInternal(bool focused); | 360 void SetFocusInternal(bool focused); |
368 | 361 |
369 // Send device_orientation_ to renderer. | 362 // Send device_orientation_ to renderer. |
370 void SendOrientationChangeEventInternal(); | 363 void SendOrientationChangeEventInternal(); |
371 | 364 |
372 // A weak reference to the Java ContentViewCore object. | 365 // A weak reference to the Java ContentViewCore object. |
373 JavaObjectWeakGlobalRef java_ref_; | 366 JavaObjectWeakGlobalRef java_ref_; |
374 | 367 |
(...skipping 19 matching lines...) Expand all Loading... |
394 | 387 |
395 // The owning window that has a hold of main application activity. | 388 // The owning window that has a hold of main application activity. |
396 ui::WindowAndroid* window_android_; | 389 ui::WindowAndroid* window_android_; |
397 | 390 |
398 // The cache of device's current orientation set from Java side, this value | 391 // The cache of device's current orientation set from Java side, this value |
399 // will be sent to Renderer once it is ready. | 392 // will be sent to Renderer once it is ready. |
400 int device_orientation_; | 393 int device_orientation_; |
401 | 394 |
402 bool geolocation_needs_pause_; | 395 bool geolocation_needs_pause_; |
403 | 396 |
404 // Handles gesture dispatch as the generating touch events are ack'ed. | 397 scoped_ptr<ContentGestureProvider> gesture_provider_; |
405 TouchDispositionGestureFilter touch_disposition_gesture_filter_; | |
406 bool handling_touch_event_; | |
407 blink::WebTouchEvent pending_touch_event_; | |
408 GestureEventPacket pending_gesture_packet_; | |
409 | 398 |
410 DISALLOW_COPY_AND_ASSIGN(ContentViewCoreImpl); | 399 DISALLOW_COPY_AND_ASSIGN(ContentViewCoreImpl); |
411 }; | 400 }; |
412 | 401 |
413 bool RegisterContentViewCore(JNIEnv* env); | 402 bool RegisterContentViewCore(JNIEnv* env); |
414 | 403 |
415 } // namespace content | 404 } // namespace content |
416 | 405 |
417 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ | 406 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ |
OLD | NEW |