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