Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: content/browser/android/content_view_core_impl.cc

Issue 2103243002: Factor out ContentViewAndroidDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ScopedAnchorView Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 const gfx::Rect& bounds, 496 const gfx::Rect& bounds,
497 const std::vector<MenuItem>& items, 497 const std::vector<MenuItem>& items,
498 int selected_item, 498 int selected_item,
499 bool multiple, 499 bool multiple,
500 bool right_aligned) { 500 bool right_aligned) {
501 JNIEnv* env = AttachCurrentThread(); 501 JNIEnv* env = AttachCurrentThread();
502 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 502 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
503 if (j_obj.is_null()) 503 if (j_obj.is_null())
504 return; 504 return;
505 505
506 ScopedJavaLocalRef<jobject> bounds_rect(CreateJavaRect(env, bounds));
507
508 // For multi-select list popups we find the list of previous selections by 506 // For multi-select list popups we find the list of previous selections by
509 // iterating through the items. But for single selection popups we take the 507 // iterating through the items. But for single selection popups we take the
510 // given |selected_item| as is. 508 // given |selected_item| as is.
511 ScopedJavaLocalRef<jintArray> selected_array; 509 ScopedJavaLocalRef<jintArray> selected_array;
512 if (multiple) { 510 if (multiple) {
513 std::unique_ptr<jint[]> native_selected_array(new jint[items.size()]); 511 std::unique_ptr<jint[]> native_selected_array(new jint[items.size()]);
514 size_t selected_count = 0; 512 size_t selected_count = 0;
515 for (size_t i = 0; i < items.size(); ++i) { 513 for (size_t i = 0; i < items.size(); ++i) {
516 if (items[i].checked) 514 if (items[i].checked)
517 native_selected_array[selected_count++] = i; 515 native_selected_array[selected_count++] = i;
(...skipping 16 matching lines...) Expand all
534 for (size_t i = 0; i < items.size(); ++i) { 532 for (size_t i = 0; i < items.size(); ++i) {
535 labels.push_back(items[i].label); 533 labels.push_back(items[i].label);
536 jint enabled = 534 jint enabled =
537 (items[i].type == MenuItem::GROUP ? POPUP_ITEM_TYPE_GROUP : 535 (items[i].type == MenuItem::GROUP ? POPUP_ITEM_TYPE_GROUP :
538 (items[i].enabled ? POPUP_ITEM_TYPE_ENABLED : 536 (items[i].enabled ? POPUP_ITEM_TYPE_ENABLED :
539 POPUP_ITEM_TYPE_DISABLED)); 537 POPUP_ITEM_TYPE_DISABLED));
540 env->SetIntArrayRegion(enabled_array.obj(), i, 1, &enabled); 538 env->SetIntArrayRegion(enabled_array.obj(), i, 1, &enabled);
541 } 539 }
542 ScopedJavaLocalRef<jobjectArray> items_array( 540 ScopedJavaLocalRef<jobjectArray> items_array(
543 base::android::ToJavaArrayOfStrings(env, labels)); 541 base::android::ToJavaArrayOfStrings(env, labels));
542 select_popup_.reset(view_.AcquireAnchorView());
543 view_.SetAnchorRect(select_popup_->ref(),
544 gfx::ScaleRect(gfx::RectF(bounds), page_scale_));
544 Java_ContentViewCore_showSelectPopup( 545 Java_ContentViewCore_showSelectPopup(
545 env, j_obj.obj(), reinterpret_cast<intptr_t>(frame), bounds_rect.obj(), 546 env, j_obj.obj(), select_popup_->obj(), bounds.width() * page_scale_,
547 reinterpret_cast<intptr_t>(frame),
546 items_array.obj(), enabled_array.obj(), multiple, selected_array.obj(), 548 items_array.obj(), enabled_array.obj(), multiple, selected_array.obj(),
547 right_aligned); 549 right_aligned);
548 } 550 }
549 551
550 void ContentViewCoreImpl::HideSelectPopupMenu() { 552 void ContentViewCoreImpl::HideSelectPopupMenu() {
551 JNIEnv* env = AttachCurrentThread(); 553 JNIEnv* env = AttachCurrentThread();
552 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 554 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
553 if (!j_obj.is_null()) 555 if (!j_obj.is_null())
554 Java_ContentViewCore_hideSelectPopup(env, j_obj.obj()); 556 Java_ContentViewCore_hideSelectPopup(env, j_obj.obj());
557 if (select_popup_)
558 select_popup_.reset();
555 } 559 }
556 560
557 void ContentViewCoreImpl::OnGestureEventAck(const blink::WebGestureEvent& event, 561 void ContentViewCoreImpl::OnGestureEventAck(const blink::WebGestureEvent& event,
558 InputEventAckState ack_result) { 562 InputEventAckState ack_result) {
559 JNIEnv* env = AttachCurrentThread(); 563 JNIEnv* env = AttachCurrentThread();
560 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 564 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
561 if (j_obj.is_null()) 565 if (j_obj.is_null())
562 return; 566 return;
563 567
564 switch (event.type) { 568 switch (event.type) {
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 return; 860 return;
857 861
858 gfx::Point base_point = gfx::ToRoundedPoint(base); 862 gfx::Point base_point = gfx::ToRoundedPoint(base);
859 gfx::Point extent_point = gfx::ToRoundedPoint(extent); 863 gfx::Point extent_point = gfx::ToRoundedPoint(extent);
860 if (base_point == extent_point) 864 if (base_point == extent_point)
861 return; 865 return;
862 866
863 web_contents_->SelectRange(base_point, extent_point); 867 web_contents_->SelectRange(base_point, extent_point);
864 } 868 }
865 869
866 const base::android::JavaRef<jobject>&
867 ContentViewCoreImpl::GetViewAndroidDelegate() const {
868 return view_.GetViewAndroidDelegate();
869 }
870
871 ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() const { 870 ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() const {
872 return view_.GetWindowAndroid(); 871 return view_.GetWindowAndroid();
873 } 872 }
874 873
875 cc::Layer* ContentViewCoreImpl::GetLayer() const { 874 cc::Layer* ContentViewCoreImpl::GetLayer() const {
876 return view_.GetLayer(); 875 return view_.GetLayer();
877 } 876 }
878 877
879 ui::ViewAndroid* ContentViewCoreImpl::GetViewAndroid() { 878 ui::ViewAndroid* ContentViewCoreImpl::GetViewAndroid() {
880 return &view_; 879 return &view_;
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
1650 return ScopedJavaLocalRef<jobject>(); 1649 return ScopedJavaLocalRef<jobject>();
1651 1650
1652 return view->GetJavaObject(); 1651 return view->GetJavaObject();
1653 } 1652 }
1654 1653
1655 bool RegisterContentViewCore(JNIEnv* env) { 1654 bool RegisterContentViewCore(JNIEnv* env) {
1656 return RegisterNativesImpl(env) && JNI_DragEvent::RegisterNativesImpl(env); 1655 return RegisterNativesImpl(env) && JNI_DragEvent::RegisterNativesImpl(env);
1657 } 1656 }
1658 1657
1659 } // namespace content 1658 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698