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