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 "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 } | 504 } |
505 | 505 |
506 void ContentViewCoreImpl::OnBackgroundColorChanged(SkColor color) { | 506 void ContentViewCoreImpl::OnBackgroundColorChanged(SkColor color) { |
507 JNIEnv* env = AttachCurrentThread(); | 507 JNIEnv* env = AttachCurrentThread(); |
508 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 508 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
509 if (obj.is_null()) | 509 if (obj.is_null()) |
510 return; | 510 return; |
511 Java_ContentViewCore_onBackgroundColorChanged(env, obj.obj(), color); | 511 Java_ContentViewCore_onBackgroundColorChanged(env, obj.obj(), color); |
512 } | 512 } |
513 | 513 |
514 void ContentViewCoreImpl::ShowSelectPopupMenu( | 514 void ContentViewCoreImpl::ShowSelectPopupMenu(const gfx::Rect& bounds, |
515 const std::vector<MenuItem>& items, int selected_item, bool multiple) { | 515 const std::vector<MenuItem>& items, int selected_item, bool multiple) { |
516 JNIEnv* env = AttachCurrentThread(); | 516 JNIEnv* env = AttachCurrentThread(); |
517 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 517 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
518 if (j_obj.is_null()) | 518 if (j_obj.is_null()) |
519 return; | 519 return; |
520 | 520 |
| 521 ScopedJavaLocalRef<jobject> bounds_rect(CreateJavaRect(env, bounds)); |
| 522 |
521 // For multi-select list popups we find the list of previous selections by | 523 // For multi-select list popups we find the list of previous selections by |
522 // iterating through the items. But for single selection popups we take the | 524 // iterating through the items. But for single selection popups we take the |
523 // given |selected_item| as is. | 525 // given |selected_item| as is. |
524 ScopedJavaLocalRef<jintArray> selected_array; | 526 ScopedJavaLocalRef<jintArray> selected_array; |
525 if (multiple) { | 527 if (multiple) { |
526 scoped_ptr<jint[]> native_selected_array(new jint[items.size()]); | 528 scoped_ptr<jint[]> native_selected_array(new jint[items.size()]); |
527 size_t selected_count = 0; | 529 size_t selected_count = 0; |
528 for (size_t i = 0; i < items.size(); ++i) { | 530 for (size_t i = 0; i < items.size(); ++i) { |
529 if (items[i].checked) | 531 if (items[i].checked) |
530 native_selected_array[selected_count++] = i; | 532 native_selected_array[selected_count++] = i; |
(...skipping 17 matching lines...) Expand all Loading... |
548 labels.push_back(items[i].label); | 550 labels.push_back(items[i].label); |
549 jint enabled = | 551 jint enabled = |
550 (items[i].type == MenuItem::GROUP ? POPUP_ITEM_TYPE_GROUP : | 552 (items[i].type == MenuItem::GROUP ? POPUP_ITEM_TYPE_GROUP : |
551 (items[i].enabled ? POPUP_ITEM_TYPE_ENABLED : | 553 (items[i].enabled ? POPUP_ITEM_TYPE_ENABLED : |
552 POPUP_ITEM_TYPE_DISABLED)); | 554 POPUP_ITEM_TYPE_DISABLED)); |
553 env->SetIntArrayRegion(enabled_array.obj(), i, 1, &enabled); | 555 env->SetIntArrayRegion(enabled_array.obj(), i, 1, &enabled); |
554 } | 556 } |
555 ScopedJavaLocalRef<jobjectArray> items_array( | 557 ScopedJavaLocalRef<jobjectArray> items_array( |
556 base::android::ToJavaArrayOfStrings(env, labels)); | 558 base::android::ToJavaArrayOfStrings(env, labels)); |
557 Java_ContentViewCore_showSelectPopup(env, j_obj.obj(), | 559 Java_ContentViewCore_showSelectPopup(env, j_obj.obj(), |
558 items_array.obj(), enabled_array.obj(), | 560 bounds_rect.obj(), |
559 multiple, selected_array.obj()); | 561 items_array.obj(), |
| 562 enabled_array.obj(), |
| 563 multiple, |
| 564 selected_array.obj()); |
560 } | 565 } |
561 | 566 |
562 void ContentViewCoreImpl::HideSelectPopupMenu() { | 567 void ContentViewCoreImpl::HideSelectPopupMenu() { |
563 JNIEnv* env = AttachCurrentThread(); | 568 JNIEnv* env = AttachCurrentThread(); |
564 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 569 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
565 if (!j_obj.is_null()) | 570 if (!j_obj.is_null()) |
566 Java_ContentViewCore_hideSelectPopup(env, j_obj.obj()); | 571 Java_ContentViewCore_hideSelectPopup(env, j_obj.obj()); |
567 } | 572 } |
568 | 573 |
569 void ContentViewCoreImpl::ConfirmTouchEvent(InputEventAckState ack_result) { | 574 void ContentViewCoreImpl::ConfirmTouchEvent(InputEventAckState ack_result) { |
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1797 reinterpret_cast<ui::ViewAndroid*>(view_android), | 1802 reinterpret_cast<ui::ViewAndroid*>(view_android), |
1798 reinterpret_cast<ui::WindowAndroid*>(window_android)); | 1803 reinterpret_cast<ui::WindowAndroid*>(window_android)); |
1799 return reinterpret_cast<intptr_t>(view); | 1804 return reinterpret_cast<intptr_t>(view); |
1800 } | 1805 } |
1801 | 1806 |
1802 bool RegisterContentViewCore(JNIEnv* env) { | 1807 bool RegisterContentViewCore(JNIEnv* env) { |
1803 return RegisterNativesImpl(env); | 1808 return RegisterNativesImpl(env); |
1804 } | 1809 } |
1805 | 1810 |
1806 } // namespace content | 1811 } // namespace content |
OLD | NEW |