| 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/gesture_event_queue.h" |
| 17 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 18 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 18 #include "content/browser/web_contents/web_contents_impl.h" | 19 #include "content/browser/web_contents/web_contents_impl.h" |
| 19 #include "content/public/browser/android/content_view_core.h" | 20 #include "content/public/browser/android/content_view_core.h" |
| 20 #include "content/public/browser/notification_observer.h" | 21 #include "content/public/browser/notification_observer.h" |
| 21 #include "content/public/browser/notification_registrar.h" | 22 #include "content/public/browser/notification_registrar.h" |
| 22 #include "content/public/browser/web_contents_observer.h" | 23 #include "content/public/browser/web_contents_observer.h" |
| 23 #include "third_party/WebKit/public/web/WebInputEvent.h" | 24 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 24 #include "ui/gfx/rect.h" | 25 #include "ui/gfx/rect.h" |
| 25 #include "ui/gfx/rect_f.h" | 26 #include "ui/gfx/rect_f.h" |
| 26 #include "url/gurl.h" | 27 #include "url/gurl.h" |
| 27 | 28 |
| 28 namespace ui { | 29 namespace ui { |
| 29 class ViewAndroid; | 30 class ViewAndroid; |
| 30 class WindowAndroid; | 31 class WindowAndroid; |
| 31 } | 32 } |
| 32 | 33 |
| 33 namespace content { | 34 namespace content { |
| 34 class RenderWidgetHostViewAndroid; | 35 class RenderWidgetHostViewAndroid; |
| 35 struct MenuItem; | 36 struct MenuItem; |
| 36 | 37 |
| 37 // TODO(jrg): this is a shell. Upstream the rest. | 38 // TODO(jrg): this is a shell. Upstream the rest. |
| 38 class ContentViewCoreImpl : public ContentViewCore, | 39 class ContentViewCoreImpl : public ContentViewCore, |
| 39 public NotificationObserver, | 40 public NotificationObserver, |
| 40 public WebContentsObserver { | 41 public WebContentsObserver, |
| 42 public GestureEventQueueClient { |
| 41 public: | 43 public: |
| 42 static ContentViewCoreImpl* FromWebContents(WebContents* web_contents); | 44 static ContentViewCoreImpl* FromWebContents(WebContents* web_contents); |
| 43 ContentViewCoreImpl(JNIEnv* env, | 45 ContentViewCoreImpl(JNIEnv* env, |
| 44 jobject obj, | 46 jobject obj, |
| 45 WebContents* web_contents, | 47 WebContents* web_contents, |
| 46 ui::ViewAndroid* view_android, | 48 ui::ViewAndroid* view_android, |
| 47 ui::WindowAndroid* window_android); | 49 ui::WindowAndroid* window_android); |
| 48 | 50 |
| 49 // ContentViewCore implementation. | 51 // ContentViewCore implementation. |
| 50 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaObject() OVERRIDE; | 52 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaObject() OVERRIDE; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 jstring extra_headers, | 89 jstring extra_headers, |
| 88 jbyteArray post_data, | 90 jbyteArray post_data, |
| 89 jstring base_url_for_data_url, | 91 jstring base_url_for_data_url, |
| 90 jstring virtual_url_for_data_url, | 92 jstring virtual_url_for_data_url, |
| 91 jboolean can_load_local_resources); | 93 jboolean can_load_local_resources); |
| 92 base::android::ScopedJavaLocalRef<jstring> GetURL(JNIEnv* env, jobject) const; | 94 base::android::ScopedJavaLocalRef<jstring> GetURL(JNIEnv* env, jobject) const; |
| 93 base::android::ScopedJavaLocalRef<jstring> GetTitle( | 95 base::android::ScopedJavaLocalRef<jstring> GetTitle( |
| 94 JNIEnv* env, jobject obj) const; | 96 JNIEnv* env, jobject obj) const; |
| 95 jboolean IsIncognito(JNIEnv* env, jobject obj); | 97 jboolean IsIncognito(JNIEnv* env, jobject obj); |
| 96 void SendOrientationChangeEvent(JNIEnv* env, jobject obj, jint orientation); | 98 void SendOrientationChangeEvent(JNIEnv* env, jobject obj, jint orientation); |
| 97 jboolean SendTouchEvent(JNIEnv* env, | 99 void OnTouchEventHandlingBegin(JNIEnv* env, |
| 98 jobject obj, | 100 jobject obj, |
| 99 jlong time_ms, | 101 jlong time_ms, |
| 100 jint type, | 102 jint type, |
| 101 jobjectArray pts); | 103 jobjectArray pts); |
| 104 void OnTouchEventHandlingEnd(JNIEnv* env, jobject obj); |
| 102 jboolean SendMouseMoveEvent(JNIEnv* env, | 105 jboolean SendMouseMoveEvent(JNIEnv* env, |
| 103 jobject obj, | 106 jobject obj, |
| 104 jlong time_ms, | 107 jlong time_ms, |
| 105 jfloat x, | 108 jfloat x, |
| 106 jfloat y); | 109 jfloat y); |
| 107 jboolean SendMouseWheelEvent(JNIEnv* env, | 110 jboolean SendMouseWheelEvent(JNIEnv* env, |
| 108 jobject obj, | 111 jobject obj, |
| 109 jlong time_ms, | 112 jlong time_ms, |
| 110 jfloat x, | 113 jfloat x, |
| 111 jfloat y, | 114 jfloat y, |
| 112 jfloat vertical_axis); | 115 jfloat vertical_axis); |
| 113 void ScrollBegin(JNIEnv* env, jobject obj, jlong time_ms, | 116 void ScrollBegin(JNIEnv* env, jobject obj, jlong time_ms, |
| 114 jfloat x, jfloat y, jfloat hintx, jfloat hinty); | 117 jfloat x, jfloat y, jfloat hintx, jfloat hinty); |
| 115 void ScrollEnd(JNIEnv* env, jobject obj, jlong time_ms); | 118 void ScrollEnd(JNIEnv* env, jobject obj, jlong time_ms); |
| 116 void ScrollBy(JNIEnv* env, jobject obj, jlong time_ms, | 119 void ScrollBy(JNIEnv* env, jobject obj, jlong time_ms, |
| 117 jfloat x, jfloat y, jfloat dx, jfloat dy); | 120 jfloat x, jfloat y, jfloat dx, jfloat dy); |
| 118 void FlingStart(JNIEnv* env, jobject obj, jlong time_ms, | 121 void FlingStart(JNIEnv* env, jobject obj, jlong time_ms, |
| 119 jfloat x, jfloat y, jfloat vx, jfloat vy); | 122 jfloat x, jfloat y, jfloat vx, jfloat vy); |
| 120 void FlingCancel(JNIEnv* env, jobject obj, jlong time_ms); | 123 void FlingCancel(JNIEnv* env, jobject obj, jlong time_ms); |
| 121 void SingleTap(JNIEnv* env, jobject obj, jlong time_ms, | 124 void SingleTap(JNIEnv* env, jobject obj, jlong time_ms, |
| 122 jfloat x, jfloat y, | 125 jfloat x, jfloat y, |
| 123 jboolean disambiguation_popup_tap); | 126 jboolean disambiguation_popup_tap); |
| 124 void SingleTapUnconfirmed(JNIEnv* env, jobject obj, jlong time_ms, | 127 void SingleTapUnconfirmed(JNIEnv* env, jobject obj, jlong time_ms, |
| 125 jfloat x, jfloat y); | 128 jfloat x, jfloat y); |
| 126 void ShowPressState(JNIEnv* env, jobject obj, jlong time_ms, | 129 void ShowPress(JNIEnv* env, jobject obj, jlong time_ms, |
| 127 jfloat x, jfloat y); | 130 jfloat x, jfloat y); |
| 128 void TapCancel(JNIEnv* env, jobject obj, jlong time_ms, | 131 void TapCancel(JNIEnv* env, jobject obj, jlong time_ms, |
| 129 jfloat x, jfloat y); | 132 jfloat x, jfloat y); |
| 130 void TapDown(JNIEnv* env, jobject obj, jlong time_ms, | 133 void TapDown(JNIEnv* env, jobject obj, jlong time_ms, |
| 131 jfloat x, jfloat y); | 134 jfloat x, jfloat y); |
| 132 void DoubleTap(JNIEnv* env, jobject obj, jlong time_ms, | 135 void DoubleTap(JNIEnv* env, jobject obj, jlong time_ms, |
| 133 jfloat x, jfloat y) ; | 136 jfloat x, jfloat y) ; |
| 134 void LongPress(JNIEnv* env, jobject obj, jlong time_ms, | 137 void LongPress(JNIEnv* env, jobject obj, jlong time_ms, |
| 135 jfloat x, jfloat y, | 138 jfloat x, jfloat y, |
| 136 jboolean disambiguation_popup_tap); | 139 jboolean disambiguation_popup_tap); |
| 137 void LongTap(JNIEnv* env, jobject obj, jlong time_ms, | 140 void LongTap(JNIEnv* env, jobject obj, jlong time_ms, |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 void UpdateImeAdapter(int native_ime_adapter, int text_input_type, | 265 void UpdateImeAdapter(int native_ime_adapter, int text_input_type, |
| 263 const std::string& text, | 266 const std::string& text, |
| 264 int selection_start, int selection_end, | 267 int selection_start, int selection_end, |
| 265 int composition_start, int composition_end, | 268 int composition_start, int composition_end, |
| 266 bool show_ime_if_needed, bool require_ack); | 269 bool show_ime_if_needed, bool require_ack); |
| 267 void SetTitle(const base::string16& title); | 270 void SetTitle(const base::string16& title); |
| 268 void OnBackgroundColorChanged(SkColor color); | 271 void OnBackgroundColorChanged(SkColor color); |
| 269 | 272 |
| 270 bool HasFocus(); | 273 bool HasFocus(); |
| 271 void ConfirmTouchEvent(InputEventAckState ack_result); | 274 void ConfirmTouchEvent(InputEventAckState ack_result); |
| 272 void OnFlingStartEventAck(InputEventAckState ack_result); | 275 void OnUnhandledFlingStartEventAck(bool had_consumer, float vx, float vy); |
| 273 void OnScrollBeginEventAck(); | 276 void OnScrollBeginEventAck(); |
| 274 void OnScrollUpdateGestureConsumed(); | 277 void OnScrollUpdateGestureConsumed(); |
| 275 void OnScrollEndEventAck(); | 278 void OnScrollEndEventAck(); |
| 276 void HasTouchEventHandlers(bool need_touch_events); | 279 void HasTouchEventHandlers(bool need_touch_events); |
| 277 void OnSelectionChanged(const std::string& text); | 280 void OnSelectionChanged(const std::string& text); |
| 278 void OnSelectionBoundsChanged( | 281 void OnSelectionBoundsChanged( |
| 279 const ViewHostMsg_SelectionBounds_Params& params); | 282 const ViewHostMsg_SelectionBounds_Params& params); |
| 280 | 283 |
| 281 void StartContentIntent(const GURL& content_url); | 284 void StartContentIntent(const GURL& content_url); |
| 282 | 285 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 virtual ~ContentViewCoreImpl(); | 331 virtual ~ContentViewCoreImpl(); |
| 329 | 332 |
| 330 // NotificationObserver implementation. | 333 // NotificationObserver implementation. |
| 331 virtual void Observe(int type, | 334 virtual void Observe(int type, |
| 332 const NotificationSource& source, | 335 const NotificationSource& source, |
| 333 const NotificationDetails& details) OVERRIDE; | 336 const NotificationDetails& details) OVERRIDE; |
| 334 | 337 |
| 335 // WebContentsObserver implementation. | 338 // WebContentsObserver implementation. |
| 336 virtual void RenderViewReady() OVERRIDE; | 339 virtual void RenderViewReady() OVERRIDE; |
| 337 | 340 |
| 341 // GestureEventQueueClient implementation. |
| 342 virtual void ForwardGestureEvent( |
| 343 const blink::WebGestureEvent& event) OVERRIDE; |
| 344 |
| 338 // -------------------------------------------------------------------------- | 345 // -------------------------------------------------------------------------- |
| 339 // Other private methods and data | 346 // Other private methods and data |
| 340 // -------------------------------------------------------------------------- | 347 // -------------------------------------------------------------------------- |
| 341 | 348 |
| 342 void InitWebContents(); | 349 void InitWebContents(); |
| 343 | 350 |
| 344 RenderWidgetHostViewAndroid* GetRenderWidgetHostViewAndroid(); | 351 RenderWidgetHostViewAndroid* GetRenderWidgetHostViewAndroid(); |
| 345 | 352 |
| 346 float GetTouchPaddingDip(); | 353 float GetTouchPaddingDip(); |
| 347 | 354 |
| 348 blink::WebGestureEvent MakeGestureEvent( | 355 blink::WebGestureEvent MakeGestureEvent( |
| 349 blink::WebInputEvent::Type type, int64 time_ms, float x, float y) const; | 356 blink::WebInputEvent::Type type, int64 time_ms, float x, float y) const; |
| 350 | 357 |
| 351 void SendBeginFrame(base::TimeTicks frame_time); | 358 void SendBeginFrame(base::TimeTicks frame_time); |
| 352 | 359 |
| 353 gfx::Size GetViewportSizePix() const; | 360 gfx::Size GetViewportSizePix() const; |
| 354 gfx::Size GetViewportSizeOffsetPix() const; | 361 gfx::Size GetViewportSizeOffsetPix() const; |
| 355 | 362 |
| 356 void DeleteScaledSnapshotTexture(); | 363 void DeleteScaledSnapshotTexture(); |
| 357 | 364 |
| 358 void SendGestureEvent(const blink::WebGestureEvent& event); | 365 void SendGestureEvent(const blink::WebGestureEvent& event); |
| 366 void SendSyntheticGestureEvent(const blink::WebGestureEvent& event); |
| 359 | 367 |
| 360 // Update focus state of the RenderWidgetHostView. | 368 // Update focus state of the RenderWidgetHostView. |
| 361 void SetFocusInternal(bool focused); | 369 void SetFocusInternal(bool focused); |
| 362 | 370 |
| 363 // Send device_orientation_ to renderer. | 371 // Send device_orientation_ to renderer. |
| 364 void SendOrientationChangeEventInternal(); | 372 void SendOrientationChangeEventInternal(); |
| 365 | 373 |
| 366 // A weak reference to the Java ContentViewCore object. | 374 // A weak reference to the Java ContentViewCore object. |
| 367 JavaObjectWeakGlobalRef java_ref_; | 375 JavaObjectWeakGlobalRef java_ref_; |
| 368 | 376 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 388 | 396 |
| 389 // The owning window that has a hold of main application activity. | 397 // The owning window that has a hold of main application activity. |
| 390 ui::WindowAndroid* window_android_; | 398 ui::WindowAndroid* window_android_; |
| 391 | 399 |
| 392 // The cache of device's current orientation set from Java side, this value | 400 // The cache of device's current orientation set from Java side, this value |
| 393 // will be sent to Renderer once it is ready. | 401 // will be sent to Renderer once it is ready. |
| 394 int device_orientation_; | 402 int device_orientation_; |
| 395 | 403 |
| 396 bool geolocation_needs_pause_; | 404 bool geolocation_needs_pause_; |
| 397 | 405 |
| 406 GestureEventQueue gesture_event_queue_; |
| 407 bool handling_touch_event_; |
| 408 blink::WebTouchEvent pending_touch_event_; |
| 409 GestureEventPacket pending_gesture_packet_; |
| 410 |
| 398 DISALLOW_COPY_AND_ASSIGN(ContentViewCoreImpl); | 411 DISALLOW_COPY_AND_ASSIGN(ContentViewCoreImpl); |
| 399 }; | 412 }; |
| 400 | 413 |
| 401 bool RegisterContentViewCore(JNIEnv* env); | 414 bool RegisterContentViewCore(JNIEnv* env); |
| 402 | 415 |
| 403 } // namespace content | 416 } // namespace content |
| 404 | 417 |
| 405 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ | 418 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ |
| OLD | NEW |