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 #include "content/browser/android/content_view_core_impl.h" | 5 #include "content/browser/android/content_view_core_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 FOR_EACH_OBSERVER(ContentViewCoreImplObserver, | 263 FOR_EACH_OBSERVER(ContentViewCoreImplObserver, |
264 observer_list_, | 264 observer_list_, |
265 OnContentViewCoreDestroyed()); | 265 OnContentViewCoreDestroyed()); |
266 observer_list_.Clear(); | 266 observer_list_.Clear(); |
267 | 267 |
268 JNIEnv* env = base::android::AttachCurrentThread(); | 268 JNIEnv* env = base::android::AttachCurrentThread(); |
269 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 269 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
270 java_ref_.reset(); | 270 java_ref_.reset(); |
271 if (!j_obj.is_null()) { | 271 if (!j_obj.is_null()) { |
272 Java_ContentViewCore_onNativeContentViewCoreDestroyed( | 272 Java_ContentViewCore_onNativeContentViewCoreDestroyed( |
273 env, j_obj.obj(), reinterpret_cast<intptr_t>(this)); | 273 env, j_obj, reinterpret_cast<intptr_t>(this)); |
274 } | 274 } |
275 } | 275 } |
276 | 276 |
277 void ContentViewCoreImpl::UpdateWindowAndroid( | 277 void ContentViewCoreImpl::UpdateWindowAndroid( |
278 JNIEnv* env, | 278 JNIEnv* env, |
279 const base::android::JavaParamRef<jobject>& obj, | 279 const base::android::JavaParamRef<jobject>& obj, |
280 jlong window_android) { | 280 jlong window_android) { |
281 if (window_android) { | 281 if (window_android) { |
282 DCHECK(!view_.GetWindowAndroid()); | 282 DCHECK(!view_.GetWindowAndroid()); |
283 ui::WindowAndroid* window = | 283 ui::WindowAndroid* window = |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 SetContentViewCore(this); | 331 SetContentViewCore(this); |
332 DCHECK(!web_contents_->GetUserData(kContentViewUserDataKey)); | 332 DCHECK(!web_contents_->GetUserData(kContentViewUserDataKey)); |
333 web_contents_->SetUserData(kContentViewUserDataKey, | 333 web_contents_->SetUserData(kContentViewUserDataKey, |
334 new ContentViewUserData(this)); | 334 new ContentViewUserData(this)); |
335 } | 335 } |
336 | 336 |
337 void ContentViewCoreImpl::RenderViewReady() { | 337 void ContentViewCoreImpl::RenderViewReady() { |
338 JNIEnv* env = AttachCurrentThread(); | 338 JNIEnv* env = AttachCurrentThread(); |
339 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 339 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
340 if (!obj.is_null()) | 340 if (!obj.is_null()) |
341 Java_ContentViewCore_onRenderProcessChange(env, obj.obj()); | 341 Java_ContentViewCore_onRenderProcessChange(env, obj); |
342 | 342 |
343 if (device_orientation_ != 0) | 343 if (device_orientation_ != 0) |
344 SendOrientationChangeEventInternal(); | 344 SendOrientationChangeEventInternal(); |
345 } | 345 } |
346 | 346 |
347 void ContentViewCoreImpl::RenderViewHostChanged(RenderViewHost* old_host, | 347 void ContentViewCoreImpl::RenderViewHostChanged(RenderViewHost* old_host, |
348 RenderViewHost* new_host) { | 348 RenderViewHost* new_host) { |
349 int old_pid = 0; | 349 int old_pid = 0; |
350 if (old_host) { | 350 if (old_host) { |
351 old_pid = GetRenderProcessIdFromRenderViewHost(old_host); | 351 old_pid = GetRenderProcessIdFromRenderViewHost(old_host); |
352 | 352 |
353 RenderWidgetHostViewAndroid* view = | 353 RenderWidgetHostViewAndroid* view = |
354 static_cast<RenderWidgetHostViewAndroid*>( | 354 static_cast<RenderWidgetHostViewAndroid*>( |
355 old_host->GetWidget()->GetView()); | 355 old_host->GetWidget()->GetView()); |
356 if (view) | 356 if (view) |
357 view->SetContentViewCore(NULL); | 357 view->SetContentViewCore(NULL); |
358 | 358 |
359 view = static_cast<RenderWidgetHostViewAndroid*>( | 359 view = static_cast<RenderWidgetHostViewAndroid*>( |
360 new_host->GetWidget()->GetView()); | 360 new_host->GetWidget()->GetView()); |
361 if (view) | 361 if (view) |
362 view->SetContentViewCore(this); | 362 view->SetContentViewCore(this); |
363 } | 363 } |
364 int new_pid = GetRenderProcessIdFromRenderViewHost( | 364 int new_pid = GetRenderProcessIdFromRenderViewHost( |
365 web_contents_->GetRenderViewHost()); | 365 web_contents_->GetRenderViewHost()); |
366 if (new_pid != old_pid) { | 366 if (new_pid != old_pid) { |
367 // Notify the Java side that the renderer process changed. | 367 // Notify the Java side that the renderer process changed. |
368 JNIEnv* env = AttachCurrentThread(); | 368 JNIEnv* env = AttachCurrentThread(); |
369 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 369 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
370 if (!obj.is_null()) { | 370 if (!obj.is_null()) { |
371 Java_ContentViewCore_onRenderProcessChange(env, obj.obj()); | 371 Java_ContentViewCore_onRenderProcessChange(env, obj); |
372 } | 372 } |
373 } | 373 } |
374 | 374 |
375 SetFocusInternal(HasFocus()); | 375 SetFocusInternal(HasFocus()); |
376 SetAccessibilityEnabledInternal(accessibility_enabled_); | 376 SetAccessibilityEnabledInternal(accessibility_enabled_); |
377 } | 377 } |
378 | 378 |
379 RenderWidgetHostViewAndroid* | 379 RenderWidgetHostViewAndroid* |
380 ContentViewCoreImpl::GetRenderWidgetHostViewAndroid() const { | 380 ContentViewCoreImpl::GetRenderWidgetHostViewAndroid() const { |
381 RenderWidgetHostView* rwhv = NULL; | 381 RenderWidgetHostView* rwhv = NULL; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 selection_start.type() == gfx::SelectionBound::CENTER; | 440 selection_start.type() == gfx::SelectionBound::CENTER; |
441 const jboolean is_insertion_marker_visible = selection_start.visible(); | 441 const jboolean is_insertion_marker_visible = selection_start.visible(); |
442 const jfloat insertion_marker_horizontal = | 442 const jfloat insertion_marker_horizontal = |
443 has_insertion_marker ? selection_start.edge_top().x() : 0.0f; | 443 has_insertion_marker ? selection_start.edge_top().x() : 0.0f; |
444 const jfloat insertion_marker_top = | 444 const jfloat insertion_marker_top = |
445 has_insertion_marker ? selection_start.edge_top().y() : 0.0f; | 445 has_insertion_marker ? selection_start.edge_top().y() : 0.0f; |
446 const jfloat insertion_marker_bottom = | 446 const jfloat insertion_marker_bottom = |
447 has_insertion_marker ? selection_start.edge_bottom().y() : 0.0f; | 447 has_insertion_marker ? selection_start.edge_bottom().y() : 0.0f; |
448 | 448 |
449 Java_ContentViewCore_updateFrameInfo( | 449 Java_ContentViewCore_updateFrameInfo( |
450 env, obj.obj(), | 450 env, obj, scroll_offset.x(), scroll_offset.y(), page_scale_factor, |
451 scroll_offset.x(), | 451 page_scale_factor_limits.x(), page_scale_factor_limits.y(), |
452 scroll_offset.y(), | 452 content_size.width(), content_size.height(), viewport_size.width(), |
453 page_scale_factor, | 453 viewport_size.height(), controls_offset.y(), content_offset.y(), |
454 page_scale_factor_limits.x(), | 454 is_mobile_optimized_hint, has_insertion_marker, |
455 page_scale_factor_limits.y(), | 455 is_insertion_marker_visible, insertion_marker_horizontal, |
456 content_size.width(), | 456 insertion_marker_top, insertion_marker_bottom); |
457 content_size.height(), | |
458 viewport_size.width(), | |
459 viewport_size.height(), | |
460 controls_offset.y(), | |
461 content_offset.y(), | |
462 is_mobile_optimized_hint, | |
463 has_insertion_marker, | |
464 is_insertion_marker_visible, | |
465 insertion_marker_horizontal, | |
466 insertion_marker_top, | |
467 insertion_marker_bottom); | |
468 } | 457 } |
469 | 458 |
470 void ContentViewCoreImpl::SetTitle(const base::string16& title) { | 459 void ContentViewCoreImpl::SetTitle(const base::string16& title) { |
471 JNIEnv* env = AttachCurrentThread(); | 460 JNIEnv* env = AttachCurrentThread(); |
472 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 461 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
473 if (obj.is_null()) | 462 if (obj.is_null()) |
474 return; | 463 return; |
475 ScopedJavaLocalRef<jstring> jtitle = | 464 ScopedJavaLocalRef<jstring> jtitle = |
476 ConvertUTF8ToJavaString(env, base::UTF16ToUTF8(title)); | 465 ConvertUTF8ToJavaString(env, base::UTF16ToUTF8(title)); |
477 Java_ContentViewCore_setTitle(env, obj.obj(), jtitle.obj()); | 466 Java_ContentViewCore_setTitle(env, obj, jtitle); |
478 } | 467 } |
479 | 468 |
480 void ContentViewCoreImpl::OnBackgroundColorChanged(SkColor color) { | 469 void ContentViewCoreImpl::OnBackgroundColorChanged(SkColor color) { |
481 view_.GetLayer()->SetBackgroundColor(color); | 470 view_.GetLayer()->SetBackgroundColor(color); |
482 | 471 |
483 JNIEnv* env = AttachCurrentThread(); | 472 JNIEnv* env = AttachCurrentThread(); |
484 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 473 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
485 if (obj.is_null()) | 474 if (obj.is_null()) |
486 return; | 475 return; |
487 Java_ContentViewCore_onBackgroundColorChanged(env, obj.obj(), color); | 476 Java_ContentViewCore_onBackgroundColorChanged(env, obj, color); |
488 } | 477 } |
489 | 478 |
490 void ContentViewCoreImpl::ShowSelectPopupMenu( | 479 void ContentViewCoreImpl::ShowSelectPopupMenu( |
491 RenderFrameHost* frame, | 480 RenderFrameHost* frame, |
492 const gfx::Rect& bounds, | 481 const gfx::Rect& bounds, |
493 const std::vector<MenuItem>& items, | 482 const std::vector<MenuItem>& items, |
494 int selected_item, | 483 int selected_item, |
495 bool multiple, | 484 bool multiple, |
496 bool right_aligned) { | 485 bool right_aligned) { |
497 JNIEnv* env = AttachCurrentThread(); | 486 JNIEnv* env = AttachCurrentThread(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 } | 524 } |
536 ScopedJavaLocalRef<jobjectArray> items_array( | 525 ScopedJavaLocalRef<jobjectArray> items_array( |
537 base::android::ToJavaArrayOfStrings(env, labels)); | 526 base::android::ToJavaArrayOfStrings(env, labels)); |
538 select_popup_ = view_.AcquireAnchorView(); | 527 select_popup_ = view_.AcquireAnchorView(); |
539 const ScopedJavaLocalRef<jobject> popup_view = select_popup_.view(); | 528 const ScopedJavaLocalRef<jobject> popup_view = select_popup_.view(); |
540 if (popup_view.is_null()) | 529 if (popup_view.is_null()) |
541 return; | 530 return; |
542 view_.SetAnchorRect(popup_view, | 531 view_.SetAnchorRect(popup_view, |
543 gfx::ScaleRect(gfx::RectF(bounds), page_scale_)); | 532 gfx::ScaleRect(gfx::RectF(bounds), page_scale_)); |
544 Java_ContentViewCore_showSelectPopup( | 533 Java_ContentViewCore_showSelectPopup( |
545 env, j_obj.obj(), popup_view.obj(), reinterpret_cast<intptr_t>(frame), | 534 env, j_obj, popup_view, reinterpret_cast<intptr_t>(frame), items_array, |
546 items_array.obj(), enabled_array.obj(), multiple, selected_array.obj(), | 535 enabled_array, multiple, selected_array, right_aligned); |
547 right_aligned); | |
548 } | 536 } |
549 | 537 |
550 void ContentViewCoreImpl::HideSelectPopupMenu() { | 538 void ContentViewCoreImpl::HideSelectPopupMenu() { |
551 JNIEnv* env = AttachCurrentThread(); | 539 JNIEnv* env = AttachCurrentThread(); |
552 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 540 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
553 if (!j_obj.is_null()) | 541 if (!j_obj.is_null()) |
554 Java_ContentViewCore_hideSelectPopup(env, j_obj.obj()); | 542 Java_ContentViewCore_hideSelectPopup(env, j_obj); |
555 select_popup_.Reset(); | 543 select_popup_.Reset(); |
556 } | 544 } |
557 | 545 |
558 void ContentViewCoreImpl::OnGestureEventAck(const blink::WebGestureEvent& event, | 546 void ContentViewCoreImpl::OnGestureEventAck(const blink::WebGestureEvent& event, |
559 InputEventAckState ack_result) { | 547 InputEventAckState ack_result) { |
560 JNIEnv* env = AttachCurrentThread(); | 548 JNIEnv* env = AttachCurrentThread(); |
561 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 549 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
562 if (j_obj.is_null()) | 550 if (j_obj.is_null()) |
563 return; | 551 return; |
564 | 552 |
565 switch (event.type) { | 553 switch (event.type) { |
566 case WebInputEvent::GestureFlingStart: | 554 case WebInputEvent::GestureFlingStart: |
567 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) { | 555 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) { |
568 // The view expects the fling velocity in pixels/s. | 556 // The view expects the fling velocity in pixels/s. |
569 Java_ContentViewCore_onFlingStartEventConsumed(env, j_obj.obj(), | 557 Java_ContentViewCore_onFlingStartEventConsumed( |
570 event.data.flingStart.velocityX * dpi_scale(), | 558 env, j_obj, event.data.flingStart.velocityX * dpi_scale(), |
571 event.data.flingStart.velocityY * dpi_scale()); | 559 event.data.flingStart.velocityY * dpi_scale()); |
572 } else { | 560 } else { |
573 // If a scroll ends with a fling, a SCROLL_END event is never sent. | 561 // If a scroll ends with a fling, a SCROLL_END event is never sent. |
574 // However, if that fling went unconsumed, we still need to let the | 562 // However, if that fling went unconsumed, we still need to let the |
575 // listeners know that scrolling has ended. | 563 // listeners know that scrolling has ended. |
576 Java_ContentViewCore_onScrollEndEventAck(env, j_obj.obj()); | 564 Java_ContentViewCore_onScrollEndEventAck(env, j_obj); |
577 } | 565 } |
578 break; | 566 break; |
579 case WebInputEvent::GestureFlingCancel: | 567 case WebInputEvent::GestureFlingCancel: |
580 Java_ContentViewCore_onFlingCancelEventAck(env, j_obj.obj()); | 568 Java_ContentViewCore_onFlingCancelEventAck(env, j_obj); |
581 break; | 569 break; |
582 case WebInputEvent::GestureScrollBegin: | 570 case WebInputEvent::GestureScrollBegin: |
583 Java_ContentViewCore_onScrollBeginEventAck(env, j_obj.obj()); | 571 Java_ContentViewCore_onScrollBeginEventAck(env, j_obj); |
584 break; | 572 break; |
585 case WebInputEvent::GestureScrollUpdate: | 573 case WebInputEvent::GestureScrollUpdate: |
586 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) | 574 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) |
587 Java_ContentViewCore_onScrollUpdateGestureConsumed(env, j_obj.obj()); | 575 Java_ContentViewCore_onScrollUpdateGestureConsumed(env, j_obj); |
588 break; | 576 break; |
589 case WebInputEvent::GestureScrollEnd: | 577 case WebInputEvent::GestureScrollEnd: |
590 Java_ContentViewCore_onScrollEndEventAck(env, j_obj.obj()); | 578 Java_ContentViewCore_onScrollEndEventAck(env, j_obj); |
591 break; | 579 break; |
592 case WebInputEvent::GesturePinchBegin: | 580 case WebInputEvent::GesturePinchBegin: |
593 Java_ContentViewCore_onPinchBeginEventAck(env, j_obj.obj()); | 581 Java_ContentViewCore_onPinchBeginEventAck(env, j_obj); |
594 break; | 582 break; |
595 case WebInputEvent::GesturePinchEnd: | 583 case WebInputEvent::GesturePinchEnd: |
596 Java_ContentViewCore_onPinchEndEventAck(env, j_obj.obj()); | 584 Java_ContentViewCore_onPinchEndEventAck(env, j_obj); |
597 break; | 585 break; |
598 case WebInputEvent::GestureTap: | 586 case WebInputEvent::GestureTap: |
599 Java_ContentViewCore_onSingleTapEventAck( | 587 Java_ContentViewCore_onSingleTapEventAck( |
600 env, | 588 env, j_obj, ack_result == INPUT_EVENT_ACK_STATE_CONSUMED, |
601 j_obj.obj(), | 589 event.x * dpi_scale(), event.y * dpi_scale()); |
602 ack_result == INPUT_EVENT_ACK_STATE_CONSUMED, | |
603 event.x * dpi_scale(), | |
604 event.y * dpi_scale()); | |
605 break; | 590 break; |
606 case WebInputEvent::GestureLongPress: | 591 case WebInputEvent::GestureLongPress: |
607 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) | 592 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) |
608 Java_ContentViewCore_performLongPressHapticFeedback(env, j_obj.obj()); | 593 Java_ContentViewCore_performLongPressHapticFeedback(env, j_obj); |
609 break; | 594 break; |
610 default: | 595 default: |
611 break; | 596 break; |
612 } | 597 } |
613 } | 598 } |
614 | 599 |
615 bool ContentViewCoreImpl::FilterInputEvent(const blink::WebInputEvent& event) { | 600 bool ContentViewCoreImpl::FilterInputEvent(const blink::WebInputEvent& event) { |
616 if (event.type != WebInputEvent::GestureTap && | 601 if (event.type != WebInputEvent::GestureTap && |
617 event.type != WebInputEvent::GestureDoubleTap && | 602 event.type != WebInputEvent::GestureDoubleTap && |
618 event.type != WebInputEvent::GestureLongTap && | 603 event.type != WebInputEvent::GestureLongTap && |
619 event.type != WebInputEvent::GestureLongPress) | 604 event.type != WebInputEvent::GestureLongPress) |
620 return false; | 605 return false; |
621 | 606 |
622 JNIEnv* env = AttachCurrentThread(); | 607 JNIEnv* env = AttachCurrentThread(); |
623 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 608 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
624 if (j_obj.is_null()) | 609 if (j_obj.is_null()) |
625 return false; | 610 return false; |
626 | 611 |
627 const blink::WebGestureEvent& gesture = | 612 const blink::WebGestureEvent& gesture = |
628 static_cast<const blink::WebGestureEvent&>(event); | 613 static_cast<const blink::WebGestureEvent&>(event); |
629 int gesture_type = ToGestureEventType(event.type); | 614 int gesture_type = ToGestureEventType(event.type); |
630 return Java_ContentViewCore_filterTapOrPressEvent(env, | 615 return Java_ContentViewCore_filterTapOrPressEvent(env, j_obj, gesture_type, |
631 j_obj.obj(), | |
632 gesture_type, | |
633 gesture.x * dpi_scale(), | 616 gesture.x * dpi_scale(), |
634 gesture.y * dpi_scale()); | 617 gesture.y * dpi_scale()); |
635 } | 618 } |
636 | 619 |
637 bool ContentViewCoreImpl::HasFocus() { | 620 bool ContentViewCoreImpl::HasFocus() { |
638 JNIEnv* env = AttachCurrentThread(); | 621 JNIEnv* env = AttachCurrentThread(); |
639 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 622 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
640 if (obj.is_null()) | 623 if (obj.is_null()) |
641 return false; | 624 return false; |
642 return Java_ContentViewCore_hasFocus(env, obj.obj()); | 625 return Java_ContentViewCore_hasFocus(env, obj); |
643 } | 626 } |
644 | 627 |
645 void ContentViewCoreImpl::RequestDisallowInterceptTouchEvent() { | 628 void ContentViewCoreImpl::RequestDisallowInterceptTouchEvent() { |
646 JNIEnv* env = AttachCurrentThread(); | 629 JNIEnv* env = AttachCurrentThread(); |
647 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 630 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
648 if (!obj.is_null()) | 631 if (!obj.is_null()) |
649 Java_ContentViewCore_requestDisallowInterceptTouchEvent(env, obj.obj()); | 632 Java_ContentViewCore_requestDisallowInterceptTouchEvent(env, obj); |
650 } | 633 } |
651 | 634 |
652 void ContentViewCoreImpl::OnSelectionChanged(const std::string& text) { | 635 void ContentViewCoreImpl::OnSelectionChanged(const std::string& text) { |
653 JNIEnv* env = AttachCurrentThread(); | 636 JNIEnv* env = AttachCurrentThread(); |
654 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 637 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
655 if (obj.is_null()) | 638 if (obj.is_null()) |
656 return; | 639 return; |
657 ScopedJavaLocalRef<jstring> jtext = ConvertUTF8ToJavaString(env, text); | 640 ScopedJavaLocalRef<jstring> jtext = ConvertUTF8ToJavaString(env, text); |
658 Java_ContentViewCore_onSelectionChanged(env, obj.obj(), jtext.obj()); | 641 Java_ContentViewCore_onSelectionChanged(env, obj, jtext); |
659 } | 642 } |
660 | 643 |
661 void ContentViewCoreImpl::OnSelectionEvent(ui::SelectionEventType event, | 644 void ContentViewCoreImpl::OnSelectionEvent(ui::SelectionEventType event, |
662 const gfx::PointF& selection_anchor, | 645 const gfx::PointF& selection_anchor, |
663 const gfx::RectF& selection_rect) { | 646 const gfx::RectF& selection_rect) { |
664 JNIEnv* env = AttachCurrentThread(); | 647 JNIEnv* env = AttachCurrentThread(); |
665 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 648 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
666 if (j_obj.is_null()) | 649 if (j_obj.is_null()) |
667 return; | 650 return; |
668 | 651 |
669 gfx::PointF selection_anchor_pix = | 652 gfx::PointF selection_anchor_pix = |
670 gfx::ScalePoint(selection_anchor, dpi_scale()); | 653 gfx::ScalePoint(selection_anchor, dpi_scale()); |
671 gfx::RectF selection_rect_pix = gfx::ScaleRect(selection_rect, dpi_scale()); | 654 gfx::RectF selection_rect_pix = gfx::ScaleRect(selection_rect, dpi_scale()); |
672 Java_ContentViewCore_onSelectionEvent( | 655 Java_ContentViewCore_onSelectionEvent( |
673 env, j_obj.obj(), event, selection_anchor_pix.x(), | 656 env, j_obj, event, selection_anchor_pix.x(), selection_anchor_pix.y(), |
674 selection_anchor_pix.y(), selection_rect_pix.x(), selection_rect_pix.y(), | 657 selection_rect_pix.x(), selection_rect_pix.y(), |
675 selection_rect_pix.right(), selection_rect_pix.bottom()); | 658 selection_rect_pix.right(), selection_rect_pix.bottom()); |
676 } | 659 } |
677 | 660 |
678 bool ContentViewCoreImpl::ShowPastePopup(int x_dip, int y_dip) { | 661 bool ContentViewCoreImpl::ShowPastePopup(int x_dip, int y_dip) { |
679 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); | 662 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); |
680 if (!view) | 663 if (!view) |
681 return false; | 664 return false; |
682 | 665 |
683 view->OnShowingPastePopup(gfx::PointF(x_dip, y_dip)); | 666 view->OnShowingPastePopup(gfx::PointF(x_dip, y_dip)); |
684 | 667 |
685 JNIEnv* env = AttachCurrentThread(); | 668 JNIEnv* env = AttachCurrentThread(); |
686 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 669 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
687 if (obj.is_null()) | 670 if (obj.is_null()) |
688 return false; | 671 return false; |
689 return Java_ContentViewCore_showPastePopupWithFeedback( | 672 return Java_ContentViewCore_showPastePopupWithFeedback( |
690 env, obj.obj(), static_cast<jint>(x_dip * dpi_scale()), | 673 env, obj, static_cast<jint>(x_dip * dpi_scale()), |
691 static_cast<jint>(y_dip * dpi_scale())); | 674 static_cast<jint>(y_dip * dpi_scale())); |
692 } | 675 } |
693 | 676 |
694 void ContentViewCoreImpl::StartContentIntent(const GURL& content_url, | 677 void ContentViewCoreImpl::StartContentIntent(const GURL& content_url, |
695 bool is_main_frame) { | 678 bool is_main_frame) { |
696 JNIEnv* env = AttachCurrentThread(); | 679 JNIEnv* env = AttachCurrentThread(); |
697 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 680 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
698 if (j_obj.is_null()) | 681 if (j_obj.is_null()) |
699 return; | 682 return; |
700 ScopedJavaLocalRef<jstring> jcontent_url = | 683 ScopedJavaLocalRef<jstring> jcontent_url = |
701 ConvertUTF8ToJavaString(env, content_url.spec()); | 684 ConvertUTF8ToJavaString(env, content_url.spec()); |
702 Java_ContentViewCore_startContentIntent(env, | 685 Java_ContentViewCore_startContentIntent(env, j_obj, jcontent_url, |
703 j_obj.obj(), | |
704 jcontent_url.obj(), | |
705 is_main_frame); | 686 is_main_frame); |
706 } | 687 } |
707 | 688 |
708 void ContentViewCoreImpl::ShowDisambiguationPopup( | 689 void ContentViewCoreImpl::ShowDisambiguationPopup( |
709 const gfx::Rect& rect_pixels, | 690 const gfx::Rect& rect_pixels, |
710 const SkBitmap& zoomed_bitmap) { | 691 const SkBitmap& zoomed_bitmap) { |
711 JNIEnv* env = AttachCurrentThread(); | 692 JNIEnv* env = AttachCurrentThread(); |
712 | 693 |
713 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 694 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
714 if (obj.is_null()) | 695 if (obj.is_null()) |
715 return; | 696 return; |
716 | 697 |
717 ScopedJavaLocalRef<jobject> rect_object(CreateJavaRect(env, rect_pixels)); | 698 ScopedJavaLocalRef<jobject> rect_object(CreateJavaRect(env, rect_pixels)); |
718 | 699 |
719 ScopedJavaLocalRef<jobject> java_bitmap = | 700 ScopedJavaLocalRef<jobject> java_bitmap = |
720 gfx::ConvertToJavaBitmap(&zoomed_bitmap); | 701 gfx::ConvertToJavaBitmap(&zoomed_bitmap); |
721 DCHECK(!java_bitmap.is_null()); | 702 DCHECK(!java_bitmap.is_null()); |
722 | 703 |
723 Java_ContentViewCore_showDisambiguationPopup(env, | 704 Java_ContentViewCore_showDisambiguationPopup(env, obj, rect_object, |
724 obj.obj(), | 705 java_bitmap); |
725 rect_object.obj(), | |
726 java_bitmap.obj()); | |
727 } | 706 } |
728 | 707 |
729 ScopedJavaLocalRef<jobject> | 708 ScopedJavaLocalRef<jobject> |
730 ContentViewCoreImpl::CreateMotionEventSynthesizer() { | 709 ContentViewCoreImpl::CreateMotionEventSynthesizer() { |
731 JNIEnv* env = AttachCurrentThread(); | 710 JNIEnv* env = AttachCurrentThread(); |
732 | 711 |
733 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 712 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
734 if (obj.is_null()) | 713 if (obj.is_null()) |
735 return ScopedJavaLocalRef<jobject>(); | 714 return ScopedJavaLocalRef<jobject>(); |
736 return Java_ContentViewCore_createMotionEventSynthesizer(env, obj.obj()); | 715 return Java_ContentViewCore_createMotionEventSynthesizer(env, obj); |
737 } | 716 } |
738 | 717 |
739 bool ContentViewCoreImpl::ShouldBlockMediaRequest(const GURL& url) { | 718 bool ContentViewCoreImpl::ShouldBlockMediaRequest(const GURL& url) { |
740 JNIEnv* env = AttachCurrentThread(); | 719 JNIEnv* env = AttachCurrentThread(); |
741 | 720 |
742 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 721 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
743 if (obj.is_null()) | 722 if (obj.is_null()) |
744 return true; | 723 return true; |
745 ScopedJavaLocalRef<jstring> j_url = ConvertUTF8ToJavaString(env, url.spec()); | 724 ScopedJavaLocalRef<jstring> j_url = ConvertUTF8ToJavaString(env, url.spec()); |
746 return Java_ContentViewCore_shouldBlockMediaRequest(env, obj.obj(), | 725 return Java_ContentViewCore_shouldBlockMediaRequest(env, obj, j_url); |
747 j_url.obj()); | |
748 } | 726 } |
749 | 727 |
750 void ContentViewCoreImpl::DidStopFlinging() { | 728 void ContentViewCoreImpl::DidStopFlinging() { |
751 JNIEnv* env = AttachCurrentThread(); | 729 JNIEnv* env = AttachCurrentThread(); |
752 | 730 |
753 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 731 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
754 if (!obj.is_null()) | 732 if (!obj.is_null()) |
755 Java_ContentViewCore_onNativeFlingStopped(env, obj.obj()); | 733 Java_ContentViewCore_onNativeFlingStopped(env, obj); |
756 } | 734 } |
757 | 735 |
758 ScopedJavaLocalRef<jobject> ContentViewCoreImpl::GetContext() const { | 736 ScopedJavaLocalRef<jobject> ContentViewCoreImpl::GetContext() const { |
759 JNIEnv* env = AttachCurrentThread(); | 737 JNIEnv* env = AttachCurrentThread(); |
760 | 738 |
761 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 739 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
762 if (obj.is_null()) | 740 if (obj.is_null()) |
763 return ScopedJavaLocalRef<jobject>(); | 741 return ScopedJavaLocalRef<jobject>(); |
764 | 742 |
765 return Java_ContentViewCore_getContext(env, obj.obj()); | 743 return Java_ContentViewCore_getContext(env, obj); |
766 } | 744 } |
767 | 745 |
768 gfx::Size ContentViewCoreImpl::GetViewSizeWithOSKHidden() const { | 746 gfx::Size ContentViewCoreImpl::GetViewSizeWithOSKHidden() const { |
769 gfx::Size size_pix; | 747 gfx::Size size_pix; |
770 JNIEnv* env = AttachCurrentThread(); | 748 JNIEnv* env = AttachCurrentThread(); |
771 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 749 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
772 if (j_obj.is_null()) | 750 if (j_obj.is_null()) |
773 return size_pix = gfx::Size(); | 751 return size_pix = gfx::Size(); |
774 size_pix = gfx::Size( | 752 size_pix = gfx::Size( |
775 Java_ContentViewCore_getViewportWidthPix(env, j_obj.obj()), | 753 Java_ContentViewCore_getViewportWidthPix(env, j_obj), |
776 Java_ContentViewCore_getViewportHeightWithOSKHiddenPix(env, j_obj.obj())); | 754 Java_ContentViewCore_getViewportHeightWithOSKHiddenPix(env, j_obj)); |
777 | 755 |
778 gfx::Size size_dip = gfx::ScaleToCeiledSize(size_pix, 1.0f / dpi_scale()); | 756 gfx::Size size_dip = gfx::ScaleToCeiledSize(size_pix, 1.0f / dpi_scale()); |
779 if (DoTopControlsShrinkBlinkSize()) | 757 if (DoTopControlsShrinkBlinkSize()) |
780 size_dip.Enlarge(0, -GetTopControlsHeightDip()); | 758 size_dip.Enlarge(0, -GetTopControlsHeightDip()); |
781 return size_dip; | 759 return size_dip; |
782 } | 760 } |
783 | 761 |
784 gfx::Size ContentViewCoreImpl::GetViewSize() const { | 762 gfx::Size ContentViewCoreImpl::GetViewSize() const { |
785 gfx::Size size = GetViewportSizeDip(); | 763 gfx::Size size = GetViewportSizeDip(); |
786 if (DoTopControlsShrinkBlinkSize()) | 764 if (DoTopControlsShrinkBlinkSize()) |
787 size.Enlarge(0, -GetTopControlsHeightDip()); | 765 size.Enlarge(0, -GetTopControlsHeightDip()); |
788 return size; | 766 return size; |
789 } | 767 } |
790 | 768 |
791 gfx::Size ContentViewCoreImpl::GetPhysicalBackingSize() const { | 769 gfx::Size ContentViewCoreImpl::GetPhysicalBackingSize() const { |
792 JNIEnv* env = AttachCurrentThread(); | 770 JNIEnv* env = AttachCurrentThread(); |
793 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 771 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
794 if (j_obj.is_null()) | 772 if (j_obj.is_null()) |
795 return gfx::Size(); | 773 return gfx::Size(); |
796 return gfx::Size( | 774 return gfx::Size( |
797 Java_ContentViewCore_getPhysicalBackingWidthPix(env, j_obj.obj()), | 775 Java_ContentViewCore_getPhysicalBackingWidthPix(env, j_obj), |
798 Java_ContentViewCore_getPhysicalBackingHeightPix(env, j_obj.obj())); | 776 Java_ContentViewCore_getPhysicalBackingHeightPix(env, j_obj)); |
799 } | 777 } |
800 | 778 |
801 gfx::Size ContentViewCoreImpl::GetViewportSizePix() const { | 779 gfx::Size ContentViewCoreImpl::GetViewportSizePix() const { |
802 JNIEnv* env = AttachCurrentThread(); | 780 JNIEnv* env = AttachCurrentThread(); |
803 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 781 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
804 if (j_obj.is_null()) | 782 if (j_obj.is_null()) |
805 return gfx::Size(); | 783 return gfx::Size(); |
806 return gfx::Size( | 784 return gfx::Size(Java_ContentViewCore_getViewportWidthPix(env, j_obj), |
807 Java_ContentViewCore_getViewportWidthPix(env, j_obj.obj()), | 785 Java_ContentViewCore_getViewportHeightPix(env, j_obj)); |
808 Java_ContentViewCore_getViewportHeightPix(env, j_obj.obj())); | |
809 } | 786 } |
810 | 787 |
811 int ContentViewCoreImpl::GetTopControlsHeightPix() const { | 788 int ContentViewCoreImpl::GetTopControlsHeightPix() const { |
812 JNIEnv* env = AttachCurrentThread(); | 789 JNIEnv* env = AttachCurrentThread(); |
813 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 790 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
814 if (j_obj.is_null()) | 791 if (j_obj.is_null()) |
815 return 0; | 792 return 0; |
816 return Java_ContentViewCore_getTopControlsHeightPix(env, j_obj.obj()); | 793 return Java_ContentViewCore_getTopControlsHeightPix(env, j_obj); |
817 } | 794 } |
818 | 795 |
819 gfx::Size ContentViewCoreImpl::GetViewportSizeDip() const { | 796 gfx::Size ContentViewCoreImpl::GetViewportSizeDip() const { |
820 return gfx::ScaleToCeiledSize(GetViewportSizePix(), 1.0f / dpi_scale()); | 797 return gfx::ScaleToCeiledSize(GetViewportSizePix(), 1.0f / dpi_scale()); |
821 } | 798 } |
822 | 799 |
823 bool ContentViewCoreImpl::DoTopControlsShrinkBlinkSize() const { | 800 bool ContentViewCoreImpl::DoTopControlsShrinkBlinkSize() const { |
824 JNIEnv* env = AttachCurrentThread(); | 801 JNIEnv* env = AttachCurrentThread(); |
825 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 802 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
826 if (j_obj.is_null()) | 803 if (j_obj.is_null()) |
827 return false; | 804 return false; |
828 return Java_ContentViewCore_doTopControlsShrinkBlinkSize(env, j_obj.obj()); | 805 return Java_ContentViewCore_doTopControlsShrinkBlinkSize(env, j_obj); |
829 } | 806 } |
830 | 807 |
831 float ContentViewCoreImpl::GetTopControlsHeightDip() const { | 808 float ContentViewCoreImpl::GetTopControlsHeightDip() const { |
832 return GetTopControlsHeightPix() / dpi_scale(); | 809 return GetTopControlsHeightPix() / dpi_scale(); |
833 } | 810 } |
834 | 811 |
835 void ContentViewCoreImpl::AttachLayer(scoped_refptr<cc::Layer> layer) { | 812 void ContentViewCoreImpl::AttachLayer(scoped_refptr<cc::Layer> layer) { |
836 view_.GetLayer()->InsertChild(layer, 0); | 813 view_.GetLayer()->InsertChild(layer, 0); |
837 view_.GetLayer()->SetIsDrawable(false); | 814 view_.GetLayer()->SetIsDrawable(false); |
838 } | 815 } |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1307 if (!rwhva) | 1284 if (!rwhva) |
1308 return 0; | 1285 return 0; |
1309 return rwhva->GetNativeImeAdapter(); | 1286 return rwhva->GetNativeImeAdapter(); |
1310 } | 1287 } |
1311 | 1288 |
1312 void ContentViewCoreImpl::ForceUpdateImeAdapter(long native_ime_adapter) { | 1289 void ContentViewCoreImpl::ForceUpdateImeAdapter(long native_ime_adapter) { |
1313 JNIEnv* env = AttachCurrentThread(); | 1290 JNIEnv* env = AttachCurrentThread(); |
1314 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1291 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
1315 if (obj.is_null()) | 1292 if (obj.is_null()) |
1316 return; | 1293 return; |
1317 Java_ContentViewCore_forceUpdateImeAdapter(env, obj.obj(), | 1294 Java_ContentViewCore_forceUpdateImeAdapter(env, obj, native_ime_adapter); |
1318 native_ime_adapter); | |
1319 } | 1295 } |
1320 | 1296 |
1321 void ContentViewCoreImpl::UpdateImeAdapter(long native_ime_adapter, | 1297 void ContentViewCoreImpl::UpdateImeAdapter(long native_ime_adapter, |
1322 int text_input_type, | 1298 int text_input_type, |
1323 int text_input_flags, | 1299 int text_input_flags, |
1324 const std::string& text, | 1300 const std::string& text, |
1325 int selection_start, | 1301 int selection_start, |
1326 int selection_end, | 1302 int selection_end, |
1327 int composition_start, | 1303 int composition_start, |
1328 int composition_end, | 1304 int composition_end, |
1329 bool show_ime_if_needed, | 1305 bool show_ime_if_needed, |
1330 bool is_non_ime_change) { | 1306 bool is_non_ime_change) { |
1331 JNIEnv* env = AttachCurrentThread(); | 1307 JNIEnv* env = AttachCurrentThread(); |
1332 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1308 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
1333 if (obj.is_null()) | 1309 if (obj.is_null()) |
1334 return; | 1310 return; |
1335 | 1311 |
1336 ScopedJavaLocalRef<jstring> jstring_text = ConvertUTF8ToJavaString(env, text); | 1312 ScopedJavaLocalRef<jstring> jstring_text = ConvertUTF8ToJavaString(env, text); |
1337 Java_ContentViewCore_updateImeAdapter(env, | 1313 Java_ContentViewCore_updateImeAdapter( |
1338 obj.obj(), | 1314 env, obj, native_ime_adapter, text_input_type, text_input_flags, |
1339 native_ime_adapter, | 1315 jstring_text, selection_start, selection_end, composition_start, |
1340 text_input_type, | 1316 composition_end, show_ime_if_needed, is_non_ime_change); |
1341 text_input_flags, | |
1342 jstring_text.obj(), | |
1343 selection_start, | |
1344 selection_end, | |
1345 composition_start, | |
1346 composition_end, | |
1347 show_ime_if_needed, | |
1348 is_non_ime_change); | |
1349 } | 1317 } |
1350 | 1318 |
1351 void ContentViewCoreImpl::SetAccessibilityEnabled( | 1319 void ContentViewCoreImpl::SetAccessibilityEnabled( |
1352 JNIEnv* env, | 1320 JNIEnv* env, |
1353 const JavaParamRef<jobject>& obj, | 1321 const JavaParamRef<jobject>& obj, |
1354 bool enabled) { | 1322 bool enabled) { |
1355 SetAccessibilityEnabledInternal(enabled); | 1323 SetAccessibilityEnabledInternal(enabled); |
1356 } | 1324 } |
1357 | 1325 |
1358 void ContentViewCoreImpl::SetTextTrackSettings( | 1326 void ContentViewCoreImpl::SetTextTrackSettings( |
(...skipping 24 matching lines...) Expand all Loading... |
1383 params.text_track_text_size = ConvertJavaStringToUTF8( | 1351 params.text_track_text_size = ConvertJavaStringToUTF8( |
1384 env, textTrackTextSize); | 1352 env, textTrackTextSize); |
1385 web_contents_->GetMainFrame()->SetTextTrackSettings(params); | 1353 web_contents_->GetMainFrame()->SetTextTrackSettings(params); |
1386 } | 1354 } |
1387 | 1355 |
1388 bool ContentViewCoreImpl::IsFullscreenRequiredForOrientationLock() const { | 1356 bool ContentViewCoreImpl::IsFullscreenRequiredForOrientationLock() const { |
1389 JNIEnv* env = AttachCurrentThread(); | 1357 JNIEnv* env = AttachCurrentThread(); |
1390 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1358 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
1391 if (obj.is_null()) | 1359 if (obj.is_null()) |
1392 return true; | 1360 return true; |
1393 return Java_ContentViewCore_isFullscreenRequiredForOrientationLock(env, | 1361 return Java_ContentViewCore_isFullscreenRequiredForOrientationLock(env, obj); |
1394 obj.obj()); | |
1395 } | 1362 } |
1396 | 1363 |
1397 void ContentViewCoreImpl::SetAccessibilityEnabledInternal(bool enabled) { | 1364 void ContentViewCoreImpl::SetAccessibilityEnabledInternal(bool enabled) { |
1398 accessibility_enabled_ = enabled; | 1365 accessibility_enabled_ = enabled; |
1399 BrowserAccessibilityStateImpl* accessibility_state = | 1366 BrowserAccessibilityStateImpl* accessibility_state = |
1400 BrowserAccessibilityStateImpl::GetInstance(); | 1367 BrowserAccessibilityStateImpl::GetInstance(); |
1401 if (enabled) { | 1368 if (enabled) { |
1402 // First check if we already have a BrowserAccessibilityManager that | 1369 // First check if we already have a BrowserAccessibilityManager that |
1403 // just needs to be connected to the ContentViewCore. | 1370 // just needs to be connected to the ContentViewCore. |
1404 if (web_contents_) { | 1371 if (web_contents_) { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1537 break; | 1504 break; |
1538 } | 1505 } |
1539 } | 1506 } |
1540 | 1507 |
1541 void ContentViewCoreImpl::OnShowUnhandledTapUIIfNeeded(int x_dip, int y_dip) { | 1508 void ContentViewCoreImpl::OnShowUnhandledTapUIIfNeeded(int x_dip, int y_dip) { |
1542 JNIEnv* env = AttachCurrentThread(); | 1509 JNIEnv* env = AttachCurrentThread(); |
1543 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1510 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
1544 if (obj.is_null()) | 1511 if (obj.is_null()) |
1545 return; | 1512 return; |
1546 Java_ContentViewCore_onShowUnhandledTapUIIfNeeded( | 1513 Java_ContentViewCore_onShowUnhandledTapUIIfNeeded( |
1547 env, obj.obj(), static_cast<jint>(x_dip * dpi_scale()), | 1514 env, obj, static_cast<jint>(x_dip * dpi_scale()), |
1548 static_cast<jint>(y_dip * dpi_scale())); | 1515 static_cast<jint>(y_dip * dpi_scale())); |
1549 } | 1516 } |
1550 | 1517 |
1551 void ContentViewCoreImpl::HidePopupsAndPreserveSelection() { | 1518 void ContentViewCoreImpl::HidePopupsAndPreserveSelection() { |
1552 JNIEnv* env = AttachCurrentThread(); | 1519 JNIEnv* env = AttachCurrentThread(); |
1553 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1520 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
1554 if (obj.is_null()) | 1521 if (obj.is_null()) |
1555 return; | 1522 return; |
1556 | 1523 |
1557 Java_ContentViewCore_hidePopupsAndPreserveSelection(env, obj.obj()); | 1524 Java_ContentViewCore_hidePopupsAndPreserveSelection(env, obj); |
1558 } | 1525 } |
1559 | 1526 |
1560 void ContentViewCoreImpl::OnSmartClipDataExtracted( | 1527 void ContentViewCoreImpl::OnSmartClipDataExtracted( |
1561 const base::string16& text, | 1528 const base::string16& text, |
1562 const base::string16& html, | 1529 const base::string16& html, |
1563 const gfx::Rect& clip_rect) { | 1530 const gfx::Rect& clip_rect) { |
1564 JNIEnv* env = AttachCurrentThread(); | 1531 JNIEnv* env = AttachCurrentThread(); |
1565 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1532 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
1566 if (obj.is_null()) | 1533 if (obj.is_null()) |
1567 return; | 1534 return; |
1568 ScopedJavaLocalRef<jstring> jtext = ConvertUTF16ToJavaString(env, text); | 1535 ScopedJavaLocalRef<jstring> jtext = ConvertUTF16ToJavaString(env, text); |
1569 ScopedJavaLocalRef<jstring> jhtml = ConvertUTF16ToJavaString(env, html); | 1536 ScopedJavaLocalRef<jstring> jhtml = ConvertUTF16ToJavaString(env, html); |
1570 ScopedJavaLocalRef<jobject> clip_rect_object(CreateJavaRect(env, clip_rect)); | 1537 ScopedJavaLocalRef<jobject> clip_rect_object(CreateJavaRect(env, clip_rect)); |
1571 Java_ContentViewCore_onSmartClipDataExtracted( | 1538 Java_ContentViewCore_onSmartClipDataExtracted(env, obj, jtext, jhtml, |
1572 env, obj.obj(), jtext.obj(), jhtml.obj(), clip_rect_object.obj()); | 1539 clip_rect_object); |
1573 } | 1540 } |
1574 | 1541 |
1575 void ContentViewCoreImpl::WebContentsDestroyed() { | 1542 void ContentViewCoreImpl::WebContentsDestroyed() { |
1576 WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>( | 1543 WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>( |
1577 static_cast<WebContentsImpl*>(web_contents())->GetView()); | 1544 static_cast<WebContentsImpl*>(web_contents())->GetView()); |
1578 DCHECK(wcva); | 1545 DCHECK(wcva); |
1579 wcva->SetContentViewCore(NULL); | 1546 wcva->SetContentViewCore(NULL); |
1580 } | 1547 } |
1581 | 1548 |
1582 bool ContentViewCoreImpl::PullStart() { | 1549 bool ContentViewCoreImpl::PullStart() { |
1583 JNIEnv* env = AttachCurrentThread(); | 1550 JNIEnv* env = AttachCurrentThread(); |
1584 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1551 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
1585 if (!obj.is_null()) | 1552 if (!obj.is_null()) |
1586 return Java_ContentViewCore_onOverscrollRefreshStart(env, obj.obj()); | 1553 return Java_ContentViewCore_onOverscrollRefreshStart(env, obj); |
1587 return false; | 1554 return false; |
1588 } | 1555 } |
1589 | 1556 |
1590 void ContentViewCoreImpl::PullUpdate(float delta) { | 1557 void ContentViewCoreImpl::PullUpdate(float delta) { |
1591 JNIEnv* env = AttachCurrentThread(); | 1558 JNIEnv* env = AttachCurrentThread(); |
1592 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1559 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
1593 if (!obj.is_null()) | 1560 if (!obj.is_null()) |
1594 Java_ContentViewCore_onOverscrollRefreshUpdate(env, obj.obj(), delta); | 1561 Java_ContentViewCore_onOverscrollRefreshUpdate(env, obj, delta); |
1595 } | 1562 } |
1596 | 1563 |
1597 void ContentViewCoreImpl::PullRelease(bool allow_refresh) { | 1564 void ContentViewCoreImpl::PullRelease(bool allow_refresh) { |
1598 JNIEnv* env = AttachCurrentThread(); | 1565 JNIEnv* env = AttachCurrentThread(); |
1599 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1566 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
1600 if (!obj.is_null()) { | 1567 if (!obj.is_null()) { |
1601 Java_ContentViewCore_onOverscrollRefreshRelease(env, obj.obj(), | 1568 Java_ContentViewCore_onOverscrollRefreshRelease(env, obj, allow_refresh); |
1602 allow_refresh); | |
1603 } | 1569 } |
1604 } | 1570 } |
1605 | 1571 |
1606 void ContentViewCoreImpl::PullReset() { | 1572 void ContentViewCoreImpl::PullReset() { |
1607 JNIEnv* env = AttachCurrentThread(); | 1573 JNIEnv* env = AttachCurrentThread(); |
1608 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1574 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
1609 if (!obj.is_null()) | 1575 if (!obj.is_null()) |
1610 Java_ContentViewCore_onOverscrollRefreshReset(env, obj.obj()); | 1576 Java_ContentViewCore_onOverscrollRefreshReset(env, obj); |
1611 } | 1577 } |
1612 | 1578 |
1613 // This is called for each ContentView. | 1579 // This is called for each ContentView. |
1614 jlong Init(JNIEnv* env, | 1580 jlong Init(JNIEnv* env, |
1615 const JavaParamRef<jobject>& obj, | 1581 const JavaParamRef<jobject>& obj, |
1616 const JavaParamRef<jobject>& web_contents, | 1582 const JavaParamRef<jobject>& web_contents, |
1617 const JavaParamRef<jobject>& view_android_delegate, | 1583 const JavaParamRef<jobject>& view_android_delegate, |
1618 jlong window_android, | 1584 jlong window_android, |
1619 const JavaParamRef<jobject>& retained_objects_set) { | 1585 const JavaParamRef<jobject>& retained_objects_set) { |
1620 ContentViewCoreImpl* view = new ContentViewCoreImpl( | 1586 ContentViewCoreImpl* view = new ContentViewCoreImpl( |
(...skipping 17 matching lines...) Expand all Loading... |
1638 return ScopedJavaLocalRef<jobject>(); | 1604 return ScopedJavaLocalRef<jobject>(); |
1639 | 1605 |
1640 return view->GetJavaObject(); | 1606 return view->GetJavaObject(); |
1641 } | 1607 } |
1642 | 1608 |
1643 bool RegisterContentViewCore(JNIEnv* env) { | 1609 bool RegisterContentViewCore(JNIEnv* env) { |
1644 return RegisterNativesImpl(env); | 1610 return RegisterNativesImpl(env); |
1645 } | 1611 } |
1646 | 1612 |
1647 } // namespace content | 1613 } // namespace content |
OLD | NEW |