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