| 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 | 37 |
| 38 // TODO(jrg): this is a shell. Upstream the rest. | 38 // TODO(jrg): this is a shell. Upstream the rest. |
| 39 class ContentViewCoreImpl : public ContentViewCore, | 39 class ContentViewCoreImpl : public ContentViewCore, |
| 40 public ContentGestureProviderClient, |
| 40 public NotificationObserver, | 41 public NotificationObserver, |
| 41 public TouchDispositionGestureFilterClient, | |
| 42 public WebContentsObserver { | 42 public WebContentsObserver { |
| 43 public: | 43 public: |
| 44 static ContentViewCoreImpl* FromWebContents(WebContents* web_contents); | 44 static ContentViewCoreImpl* FromWebContents(WebContents* web_contents); |
| 45 ContentViewCoreImpl(JNIEnv* env, | 45 ContentViewCoreImpl(JNIEnv* env, |
| 46 jobject obj, | 46 jobject obj, |
| 47 WebContents* web_contents, | 47 WebContents* web_contents, |
| 48 ui::ViewAndroid* view_android, | 48 ui::ViewAndroid* view_android, |
| 49 ui::WindowAndroid* window_android); | 49 ui::WindowAndroid* window_android); |
| 50 | 50 |
| 51 // ContentViewCore implementation. | 51 // ContentViewCore implementation. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 jstring extra_headers, | 88 jstring extra_headers, |
| 89 jbyteArray post_data, | 89 jbyteArray post_data, |
| 90 jstring base_url_for_data_url, | 90 jstring base_url_for_data_url, |
| 91 jstring virtual_url_for_data_url, | 91 jstring virtual_url_for_data_url, |
| 92 jboolean can_load_local_resources); | 92 jboolean can_load_local_resources); |
| 93 base::android::ScopedJavaLocalRef<jstring> GetURL(JNIEnv* env, jobject) const; | 93 base::android::ScopedJavaLocalRef<jstring> GetURL(JNIEnv* env, jobject) const; |
| 94 base::android::ScopedJavaLocalRef<jstring> GetTitle( | 94 base::android::ScopedJavaLocalRef<jstring> GetTitle( |
| 95 JNIEnv* env, jobject obj) const; | 95 JNIEnv* env, jobject obj) const; |
| 96 jboolean IsIncognito(JNIEnv* env, jobject obj); | 96 jboolean IsIncognito(JNIEnv* env, jobject obj); |
| 97 void SendOrientationChangeEvent(JNIEnv* env, jobject obj, jint orientation); | 97 void SendOrientationChangeEvent(JNIEnv* env, jobject obj, jint orientation); |
| 98 void OnTouchEventHandlingBegin(JNIEnv* env, | 98 jboolean OnTouchEvent(JNIEnv* env, |
| 99 jobject obj, | 99 jobject obj, |
| 100 jobject motion_event); | 100 jobject motion_event); |
| 101 void OnTouchEventHandlingEnd(JNIEnv* env, jobject obj); | |
| 102 jboolean SendMouseMoveEvent(JNIEnv* env, | 101 jboolean SendMouseMoveEvent(JNIEnv* env, |
| 103 jobject obj, | 102 jobject obj, |
| 104 jlong time_ms, | 103 jlong time_ms, |
| 105 jfloat x, | 104 jfloat x, |
| 106 jfloat y); | 105 jfloat y); |
| 107 jboolean SendMouseWheelEvent(JNIEnv* env, | 106 jboolean SendMouseWheelEvent(JNIEnv* env, |
| 108 jobject obj, | 107 jobject obj, |
| 109 jlong time_ms, | 108 jlong time_ms, |
| 110 jfloat x, | 109 jfloat x, |
| 111 jfloat y, | 110 jfloat y, |
| 112 jfloat vertical_axis); | 111 jfloat vertical_axis); |
| 113 void ScrollBegin(JNIEnv* env, jobject obj, jlong time_ms, | 112 void ScrollBegin(JNIEnv* env, jobject obj, jlong time_ms, |
| 114 jfloat x, jfloat y, jfloat hintx, jfloat hinty); | 113 jfloat x, jfloat y, jfloat hintx, jfloat hinty); |
| 115 void ScrollEnd(JNIEnv* env, jobject obj, jlong time_ms); | 114 void ScrollEnd(JNIEnv* env, jobject obj, jlong time_ms); |
| 116 void ScrollBy(JNIEnv* env, jobject obj, jlong time_ms, | 115 void ScrollBy(JNIEnv* env, jobject obj, jlong time_ms, |
| 117 jfloat x, jfloat y, jfloat dx, jfloat dy); | 116 jfloat x, jfloat y, jfloat dx, jfloat dy); |
| 118 void FlingStart(JNIEnv* env, jobject obj, jlong time_ms, | 117 void FlingStart(JNIEnv* env, jobject obj, jlong time_ms, |
| 119 jfloat x, jfloat y, jfloat vx, jfloat vy); | 118 jfloat x, jfloat y, jfloat vx, jfloat vy); |
| 120 void FlingCancel(JNIEnv* env, jobject obj, jlong time_ms); | 119 void FlingCancel(JNIEnv* env, jobject obj, jlong time_ms); |
| 121 void SingleTap(JNIEnv* env, jobject obj, jlong time_ms, | 120 void SingleTap(JNIEnv* env, jobject obj, jlong time_ms, |
| 122 jfloat x, jfloat y, | 121 jfloat x, jfloat y, |
| 123 jboolean disambiguation_popup_tap); | 122 jboolean disambiguation_popup_tap); |
| 124 void SingleTapUnconfirmed(JNIEnv* env, jobject obj, jlong time_ms, | |
| 125 jfloat x, jfloat y); | |
| 126 void ShowPress(JNIEnv* env, jobject obj, jlong time_ms, | |
| 127 jfloat x, jfloat y); | |
| 128 void TapCancel(JNIEnv* env, jobject obj, jlong time_ms, | |
| 129 jfloat x, jfloat y); | |
| 130 void TapDown(JNIEnv* env, jobject obj, jlong time_ms, | |
| 131 jfloat x, jfloat y); | |
| 132 void DoubleTap(JNIEnv* env, jobject obj, jlong time_ms, | 123 void DoubleTap(JNIEnv* env, jobject obj, jlong time_ms, |
| 133 jfloat x, jfloat y) ; | 124 jfloat x, jfloat y) ; |
| 134 void LongPress(JNIEnv* env, jobject obj, jlong time_ms, | 125 void LongPress(JNIEnv* env, jobject obj, jlong time_ms, |
| 135 jfloat x, jfloat y, | 126 jfloat x, jfloat y, |
| 136 jboolean disambiguation_popup_tap); | 127 jboolean disambiguation_popup_tap); |
| 137 void LongTap(JNIEnv* env, jobject obj, jlong time_ms, | |
| 138 jfloat x, jfloat y, | |
| 139 jboolean disambiguation_popup_tap); | |
| 140 void PinchBegin(JNIEnv* env, jobject obj, jlong time_ms, jfloat x, jfloat y); | 128 void PinchBegin(JNIEnv* env, jobject obj, jlong time_ms, jfloat x, jfloat y); |
| 141 void PinchEnd(JNIEnv* env, jobject obj, jlong time_ms); | 129 void PinchEnd(JNIEnv* env, jobject obj, jlong time_ms); |
| 142 void PinchBy(JNIEnv* env, jobject obj, jlong time_ms, | 130 void PinchBy(JNIEnv* env, jobject obj, jlong time_ms, |
| 143 jfloat x, jfloat y, jfloat delta); | 131 jfloat x, jfloat y, jfloat delta); |
| 144 void SelectBetweenCoordinates(JNIEnv* env, jobject obj, | 132 void SelectBetweenCoordinates(JNIEnv* env, jobject obj, |
| 145 jfloat x1, jfloat y1, | 133 jfloat x1, jfloat y1, |
| 146 jfloat x2, jfloat y2); | 134 jfloat x2, jfloat y2); |
| 147 void MoveCaret(JNIEnv* env, jobject obj, jfloat x, jfloat y); | 135 void MoveCaret(JNIEnv* env, jobject obj, jfloat x, jfloat y); |
| 148 | 136 |
| 137 void ResetGestureDetectors(JNIEnv* env, jobject obj); |
| 138 void IgnoreRemainingTouchEvents(JNIEnv* env, jobject obj); |
| 139 void OnWindowFocusLost(JNIEnv* env, jobject obj); |
| 140 void UpdateDoubleTapSupportForPage(JNIEnv* env, |
| 141 jobject obj, |
| 142 jboolean has_support); |
| 143 void UpdateDoubleTapSupport(JNIEnv* env, jobject obj, jboolean has_support); |
| 144 void UpdateMultiTouchZoomSupport(JNIEnv* env, |
| 145 jobject obj, |
| 146 jboolean has_support); |
| 147 |
| 149 void LoadIfNecessary(JNIEnv* env, jobject obj); | 148 void LoadIfNecessary(JNIEnv* env, jobject obj); |
| 150 void RequestRestoreLoad(JNIEnv* env, jobject obj); | 149 void RequestRestoreLoad(JNIEnv* env, jobject obj); |
| 151 void StopLoading(JNIEnv* env, jobject obj); | 150 void StopLoading(JNIEnv* env, jobject obj); |
| 152 void Reload(JNIEnv* env, jobject obj, jboolean check_for_repost); | 151 void Reload(JNIEnv* env, jobject obj, jboolean check_for_repost); |
| 153 void ReloadIgnoringCache(JNIEnv* env, jobject obj, jboolean check_for_repost); | 152 void ReloadIgnoringCache(JNIEnv* env, jobject obj, jboolean check_for_repost); |
| 154 void CancelPendingReload(JNIEnv* env, jobject obj); | 153 void CancelPendingReload(JNIEnv* env, jobject obj); |
| 155 void ContinuePendingReload(JNIEnv* env, jobject obj); | 154 void ContinuePendingReload(JNIEnv* env, jobject obj); |
| 156 void ClearHistory(JNIEnv* env, jobject obj); | 155 void ClearHistory(JNIEnv* env, jobject obj); |
| 157 void EvaluateJavaScript(JNIEnv* env, | 156 void EvaluateJavaScript(JNIEnv* env, |
| 158 jobject obj, | 157 jobject obj, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 bool animate); | 210 bool animate); |
| 212 void ShowImeIfNeeded(JNIEnv* env, jobject obj); | 211 void ShowImeIfNeeded(JNIEnv* env, jobject obj); |
| 213 | 212 |
| 214 void ShowInterstitialPage(JNIEnv* env, | 213 void ShowInterstitialPage(JNIEnv* env, |
| 215 jobject obj, | 214 jobject obj, |
| 216 jstring jurl, | 215 jstring jurl, |
| 217 jint delegate); | 216 jint delegate); |
| 218 jboolean IsShowingInterstitialPage(JNIEnv* env, jobject obj); | 217 jboolean IsShowingInterstitialPage(JNIEnv* env, jobject obj); |
| 219 | 218 |
| 220 void SetAccessibilityEnabled(JNIEnv* env, jobject obj, bool enabled); | 219 void SetAccessibilityEnabled(JNIEnv* env, jobject obj, bool enabled); |
| 221 void SendActionAfterDoubleTapUma(JNIEnv* env, | |
| 222 jobject obj, | |
| 223 jint type, | |
| 224 jboolean has_delay, | |
| 225 jint count); | |
| 226 void SendSingleTapUma(JNIEnv* env, jobject obj, jint type, jint count); | |
| 227 | 220 |
| 228 void ExtractSmartClipData(JNIEnv* env, | 221 void ExtractSmartClipData(JNIEnv* env, |
| 229 jobject obj, | 222 jobject obj, |
| 230 jint x, | 223 jint x, |
| 231 jint y, | 224 jint y, |
| 232 jint width, | 225 jint width, |
| 233 jint height); | 226 jint height); |
| 234 // -------------------------------------------------------------------------- | 227 // -------------------------------------------------------------------------- |
| 235 // Public methods that call to Java via JNI | 228 // Public methods that call to Java via JNI |
| 236 // -------------------------------------------------------------------------- | 229 // -------------------------------------------------------------------------- |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 | 313 |
| 321 // NotificationObserver implementation. | 314 // NotificationObserver implementation. |
| 322 virtual void Observe(int type, | 315 virtual void Observe(int type, |
| 323 const NotificationSource& source, | 316 const NotificationSource& source, |
| 324 const NotificationDetails& details) OVERRIDE; | 317 const NotificationDetails& details) OVERRIDE; |
| 325 | 318 |
| 326 // WebContentsObserver implementation. | 319 // WebContentsObserver implementation. |
| 327 virtual void RenderViewReady() OVERRIDE; | 320 virtual void RenderViewReady() OVERRIDE; |
| 328 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE; | 321 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE; |
| 329 | 322 |
| 330 // TouchDispositionGestureFilterClient implementation. | 323 // ContentGestureProviderClient implementation. |
| 331 virtual void ForwardGestureEvent( | 324 virtual void OnGestureEvent(const blink::WebGestureEvent& event) OVERRIDE; |
| 332 const blink::WebGestureEvent& event) OVERRIDE; | |
| 333 | 325 |
| 334 // -------------------------------------------------------------------------- | 326 // -------------------------------------------------------------------------- |
| 335 // Other private methods and data | 327 // Other private methods and data |
| 336 // -------------------------------------------------------------------------- | 328 // -------------------------------------------------------------------------- |
| 337 | 329 |
| 338 void InitWebContents(); | 330 void InitWebContents(); |
| 339 | 331 |
| 340 RenderWidgetHostViewAndroid* GetRenderWidgetHostViewAndroid(); | 332 RenderWidgetHostViewAndroid* GetRenderWidgetHostViewAndroid(); |
| 341 | 333 |
| 342 float GetTouchPaddingDip(); | 334 float GetTouchPaddingDip(); |
| 343 | 335 |
| 344 blink::WebGestureEvent MakeGestureEvent( | 336 blink::WebGestureEvent MakeGestureEvent( |
| 345 blink::WebInputEvent::Type type, int64 time_ms, float x, float y) const; | 337 blink::WebInputEvent::Type type, int64 time_ms, float x, float y) const; |
| 346 | 338 |
| 347 void SendBeginFrame(base::TimeTicks frame_time); | 339 void SendBeginFrame(base::TimeTicks frame_time); |
| 348 | 340 |
| 349 gfx::Size GetViewportSizePix() const; | 341 gfx::Size GetViewportSizePix() const; |
| 350 gfx::Size GetViewportSizeOffsetPix() const; | 342 gfx::Size GetViewportSizeOffsetPix() const; |
| 351 | 343 |
| 352 void DeleteScaledSnapshotTexture(); | 344 void DeleteScaledSnapshotTexture(); |
| 353 | 345 |
| 354 void SendGestureEvent(const blink::WebGestureEvent& event); | 346 void SendGestureEvent(const blink::WebGestureEvent& event); |
| 355 void SendSyntheticGestureEvent(const blink::WebGestureEvent& event); | |
| 356 | 347 |
| 357 // Update focus state of the RenderWidgetHostView. | 348 // Update focus state of the RenderWidgetHostView. |
| 358 void SetFocusInternal(bool focused); | 349 void SetFocusInternal(bool focused); |
| 359 | 350 |
| 360 // Send device_orientation_ to renderer. | 351 // Send device_orientation_ to renderer. |
| 361 void SendOrientationChangeEventInternal(); | 352 void SendOrientationChangeEventInternal(); |
| 362 | 353 |
| 363 // A weak reference to the Java ContentViewCore object. | 354 // A weak reference to the Java ContentViewCore object. |
| 364 JavaObjectWeakGlobalRef java_ref_; | 355 JavaObjectWeakGlobalRef java_ref_; |
| 365 | 356 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 379 base::TimeDelta vsync_interval_; | 370 base::TimeDelta vsync_interval_; |
| 380 base::TimeDelta expected_browser_composite_time_; | 371 base::TimeDelta expected_browser_composite_time_; |
| 381 | 372 |
| 382 // The Android view that can be used to add and remove decoration layers | 373 // The Android view that can be used to add and remove decoration layers |
| 383 // like AutofillPopup. | 374 // like AutofillPopup. |
| 384 ui::ViewAndroid* view_android_; | 375 ui::ViewAndroid* view_android_; |
| 385 | 376 |
| 386 // The owning window that has a hold of main application activity. | 377 // The owning window that has a hold of main application activity. |
| 387 ui::WindowAndroid* window_android_; | 378 ui::WindowAndroid* window_android_; |
| 388 | 379 |
| 380 // Provides gesture synthesis given a stream of touch events (derived from |
| 381 // Android MotionEvent's) and touch event acks. |
| 382 ContentGestureProvider gesture_provider_; |
| 383 |
| 389 // The cache of device's current orientation set from Java side, this value | 384 // The cache of device's current orientation set from Java side, this value |
| 390 // will be sent to Renderer once it is ready. | 385 // will be sent to Renderer once it is ready. |
| 391 int device_orientation_; | 386 int device_orientation_; |
| 392 | 387 |
| 393 bool geolocation_needs_pause_; | 388 bool geolocation_needs_pause_; |
| 394 | 389 |
| 395 // Handles gesture dispatch as the generating touch events are ack'ed. | |
| 396 TouchDispositionGestureFilter touch_disposition_gesture_filter_; | |
| 397 bool handling_touch_event_; | |
| 398 blink::WebTouchEvent pending_touch_event_; | |
| 399 GestureEventPacket pending_gesture_packet_; | |
| 400 | |
| 401 DISALLOW_COPY_AND_ASSIGN(ContentViewCoreImpl); | 390 DISALLOW_COPY_AND_ASSIGN(ContentViewCoreImpl); |
| 402 }; | 391 }; |
| 403 | 392 |
| 404 bool RegisterContentViewCore(JNIEnv* env); | 393 bool RegisterContentViewCore(JNIEnv* env); |
| 405 | 394 |
| 406 } // namespace content | 395 } // namespace content |
| 407 | 396 |
| 408 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ | 397 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ |
| OLD | NEW |