| 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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 // Note that viewport_width/height is a best effort based. | 412 // Note that viewport_width/height is a best effort based. |
| 413 // ContentViewCore has the actual information about the physical viewport size. | 413 // ContentViewCore has the actual information about the physical viewport size. |
| 414 void ContentViewCoreImpl::UpdateFrameInfo( | 414 void ContentViewCoreImpl::UpdateFrameInfo( |
| 415 const gfx::Vector2dF& scroll_offset, | 415 const gfx::Vector2dF& scroll_offset, |
| 416 float page_scale_factor, | 416 float page_scale_factor, |
| 417 const gfx::Vector2dF& page_scale_factor_limits, | 417 const gfx::Vector2dF& page_scale_factor_limits, |
| 418 const gfx::SizeF& content_size, | 418 const gfx::SizeF& content_size, |
| 419 const gfx::SizeF& viewport_size, | 419 const gfx::SizeF& viewport_size, |
| 420 const float top_controls_height, | 420 const float top_controls_height, |
| 421 const float top_controls_shown_ratio, | 421 const float top_controls_shown_ratio, |
| 422 const float bottom_controls_height, |
| 423 const float bottom_controls_shown_ratio, |
| 422 bool is_mobile_optimized_hint, | 424 bool is_mobile_optimized_hint, |
| 423 const gfx::SelectionBound& selection_start) { | 425 const gfx::SelectionBound& selection_start) { |
| 424 JNIEnv* env = AttachCurrentThread(); | 426 JNIEnv* env = AttachCurrentThread(); |
| 425 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 427 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 426 if (obj.is_null() || !GetWindowAndroid()) | 428 if (obj.is_null() || !GetWindowAndroid()) |
| 427 return; | 429 return; |
| 428 | 430 |
| 429 GetViewAndroid()->set_content_offset( | 431 GetViewAndroid()->set_content_offset( |
| 430 gfx::Vector2dF(0.0f, top_controls_height * top_controls_shown_ratio)); | 432 gfx::Vector2dF(0.0f, top_controls_height * top_controls_shown_ratio)); |
| 431 | 433 |
| 432 page_scale_ = page_scale_factor; | 434 page_scale_ = page_scale_factor; |
| 433 | 435 |
| 434 // The CursorAnchorInfo API in Android only supports zero width selection | 436 // The CursorAnchorInfo API in Android only supports zero width selection |
| 435 // bounds. | 437 // bounds. |
| 436 const jboolean has_insertion_marker = | 438 const jboolean has_insertion_marker = |
| 437 selection_start.type() == gfx::SelectionBound::CENTER; | 439 selection_start.type() == gfx::SelectionBound::CENTER; |
| 438 const jboolean is_insertion_marker_visible = selection_start.visible(); | 440 const jboolean is_insertion_marker_visible = selection_start.visible(); |
| 439 const jfloat insertion_marker_horizontal = | 441 const jfloat insertion_marker_horizontal = |
| 440 has_insertion_marker ? selection_start.edge_top().x() : 0.0f; | 442 has_insertion_marker ? selection_start.edge_top().x() : 0.0f; |
| 441 const jfloat insertion_marker_top = | 443 const jfloat insertion_marker_top = |
| 442 has_insertion_marker ? selection_start.edge_top().y() : 0.0f; | 444 has_insertion_marker ? selection_start.edge_top().y() : 0.0f; |
| 443 const jfloat insertion_marker_bottom = | 445 const jfloat insertion_marker_bottom = |
| 444 has_insertion_marker ? selection_start.edge_bottom().y() : 0.0f; | 446 has_insertion_marker ? selection_start.edge_bottom().y() : 0.0f; |
| 445 | 447 |
| 446 Java_ContentViewCore_updateFrameInfo( | 448 Java_ContentViewCore_updateFrameInfo( |
| 447 env, obj, scroll_offset.x(), scroll_offset.y(), page_scale_factor, | 449 env, obj, scroll_offset.x(), scroll_offset.y(), page_scale_factor, |
| 448 page_scale_factor_limits.x(), page_scale_factor_limits.y(), | 450 page_scale_factor_limits.x(), page_scale_factor_limits.y(), |
| 449 content_size.width(), content_size.height(), viewport_size.width(), | 451 content_size.width(), content_size.height(), viewport_size.width(), |
| 450 viewport_size.height(), top_controls_height, top_controls_shown_ratio, | 452 viewport_size.height(), top_controls_height, top_controls_shown_ratio, |
| 453 bottom_controls_height, bottom_controls_shown_ratio, |
| 451 is_mobile_optimized_hint, has_insertion_marker, | 454 is_mobile_optimized_hint, has_insertion_marker, |
| 452 is_insertion_marker_visible, insertion_marker_horizontal, | 455 is_insertion_marker_visible, insertion_marker_horizontal, |
| 453 insertion_marker_top, insertion_marker_bottom); | 456 insertion_marker_top, insertion_marker_bottom); |
| 454 } | 457 } |
| 455 | 458 |
| 459 void ContentViewCoreImpl::OnBackgroundColorChanged(SkColor color) { |
| 460 JNIEnv* env = AttachCurrentThread(); |
| 461 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 462 if (obj.is_null()) |
| 463 return; |
| 464 Java_ContentViewCore_onBackgroundColorChanged(env, obj, color); |
| 465 } |
| 466 |
| 456 void ContentViewCoreImpl::ShowSelectPopupMenu( | 467 void ContentViewCoreImpl::ShowSelectPopupMenu( |
| 457 RenderFrameHost* frame, | 468 RenderFrameHost* frame, |
| 458 const gfx::Rect& bounds, | 469 const gfx::Rect& bounds, |
| 459 const std::vector<MenuItem>& items, | 470 const std::vector<MenuItem>& items, |
| 460 int selected_item, | 471 int selected_item, |
| 461 bool multiple, | 472 bool multiple, |
| 462 bool right_aligned) { | 473 bool right_aligned) { |
| 463 JNIEnv* env = AttachCurrentThread(); | 474 JNIEnv* env = AttachCurrentThread(); |
| 464 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 475 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
| 465 if (j_obj.is_null()) | 476 if (j_obj.is_null()) |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 return; | 646 return; |
| 636 | 647 |
| 637 JNIEnv* env = AttachCurrentThread(); | 648 JNIEnv* env = AttachCurrentThread(); |
| 638 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 649 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 639 if (obj.is_null()) | 650 if (obj.is_null()) |
| 640 return; | 651 return; |
| 641 Java_ContentViewCore_showPastePopup(env, obj, x_dip, | 652 Java_ContentViewCore_showPastePopup(env, obj, x_dip, |
| 642 y_dip); | 653 y_dip); |
| 643 } | 654 } |
| 644 | 655 |
| 656 void ContentViewCoreImpl::StartContentIntent(const GURL& content_url, |
| 657 bool is_main_frame) { |
| 658 JNIEnv* env = AttachCurrentThread(); |
| 659 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
| 660 if (j_obj.is_null()) |
| 661 return; |
| 662 ScopedJavaLocalRef<jstring> jcontent_url = |
| 663 ConvertUTF8ToJavaString(env, content_url.spec()); |
| 664 Java_ContentViewCore_startContentIntent(env, j_obj, jcontent_url, |
| 665 is_main_frame); |
| 666 } |
| 667 |
| 645 void ContentViewCoreImpl::ShowDisambiguationPopup( | 668 void ContentViewCoreImpl::ShowDisambiguationPopup( |
| 646 const gfx::Rect& rect_pixels, | 669 const gfx::Rect& rect_pixels, |
| 647 const SkBitmap& zoomed_bitmap) { | 670 const SkBitmap& zoomed_bitmap) { |
| 648 JNIEnv* env = AttachCurrentThread(); | 671 JNIEnv* env = AttachCurrentThread(); |
| 649 | 672 |
| 650 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 673 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 651 if (obj.is_null()) | 674 if (obj.is_null()) |
| 652 return; | 675 return; |
| 653 | 676 |
| 654 ScopedJavaLocalRef<jobject> rect_object(CreateJavaRect(env, rect_pixels)); | 677 ScopedJavaLocalRef<jobject> rect_object(CreateJavaRect(env, rect_pixels)); |
| (...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1531 return ScopedJavaLocalRef<jobject>(); | 1554 return ScopedJavaLocalRef<jobject>(); |
| 1532 | 1555 |
| 1533 return view->GetJavaObject(); | 1556 return view->GetJavaObject(); |
| 1534 } | 1557 } |
| 1535 | 1558 |
| 1536 bool RegisterContentViewCore(JNIEnv* env) { | 1559 bool RegisterContentViewCore(JNIEnv* env) { |
| 1537 return RegisterNativesImpl(env); | 1560 return RegisterNativesImpl(env); |
| 1538 } | 1561 } |
| 1539 | 1562 |
| 1540 } // namespace content | 1563 } // namespace content |
| OLD | NEW |