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

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

Issue 231953003: Show Ash like <select> popup on Android tablets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@newpopupx
Patch Set: Created 6 years, 8 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 "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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 509
510 void ContentViewCoreImpl::OnBackgroundColorChanged(SkColor color) { 510 void ContentViewCoreImpl::OnBackgroundColorChanged(SkColor color) {
511 JNIEnv* env = AttachCurrentThread(); 511 JNIEnv* env = AttachCurrentThread();
512 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 512 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
513 if (obj.is_null()) 513 if (obj.is_null())
514 return; 514 return;
515 Java_ContentViewCore_onBackgroundColorChanged(env, obj.obj(), color); 515 Java_ContentViewCore_onBackgroundColorChanged(env, obj.obj(), color);
516 } 516 }
517 517
518 void ContentViewCoreImpl::ShowSelectPopupMenu( 518 void ContentViewCoreImpl::ShowSelectPopupMenu(
519 const std::vector<MenuItem>& items, int selected_item, bool multiple) { 519 const gfx::Rect& bounds, const std::vector<MenuItem>& items,
Ted C 2014/04/12 01:10:27 this formatting wasn't correct before, it should a
keishi 2014/04/15 14:41:07 Done.
520 int selected_item, double item_font_size, bool multiple) {
520 JNIEnv* env = AttachCurrentThread(); 521 JNIEnv* env = AttachCurrentThread();
521 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 522 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
522 if (j_obj.is_null()) 523 if (j_obj.is_null())
523 return; 524 return;
524 525
526 ScopedJavaLocalRef<jobject> bounds_rect(CreateJavaRect(env, bounds));
527
525 // For multi-select list popups we find the list of previous selections by 528 // For multi-select list popups we find the list of previous selections by
526 // iterating through the items. But for single selection popups we take the 529 // iterating through the items. But for single selection popups we take the
527 // given |selected_item| as is. 530 // given |selected_item| as is.
528 ScopedJavaLocalRef<jintArray> selected_array; 531 ScopedJavaLocalRef<jintArray> selected_array;
529 if (multiple) { 532 if (multiple) {
530 scoped_ptr<jint[]> native_selected_array(new jint[items.size()]); 533 scoped_ptr<jint[]> native_selected_array(new jint[items.size()]);
531 size_t selected_count = 0; 534 size_t selected_count = 0;
532 for (size_t i = 0; i < items.size(); ++i) { 535 for (size_t i = 0; i < items.size(); ++i) {
533 if (items[i].checked) 536 if (items[i].checked)
534 native_selected_array[selected_count++] = i; 537 native_selected_array[selected_count++] = i;
(...skipping 17 matching lines...) Expand all
552 labels.push_back(items[i].label); 555 labels.push_back(items[i].label);
553 jint enabled = 556 jint enabled =
554 (items[i].type == MenuItem::GROUP ? POPUP_ITEM_TYPE_GROUP : 557 (items[i].type == MenuItem::GROUP ? POPUP_ITEM_TYPE_GROUP :
555 (items[i].enabled ? POPUP_ITEM_TYPE_ENABLED : 558 (items[i].enabled ? POPUP_ITEM_TYPE_ENABLED :
556 POPUP_ITEM_TYPE_DISABLED)); 559 POPUP_ITEM_TYPE_DISABLED));
557 env->SetIntArrayRegion(enabled_array.obj(), i, 1, &enabled); 560 env->SetIntArrayRegion(enabled_array.obj(), i, 1, &enabled);
558 } 561 }
559 ScopedJavaLocalRef<jobjectArray> items_array( 562 ScopedJavaLocalRef<jobjectArray> items_array(
560 base::android::ToJavaArrayOfStrings(env, labels)); 563 base::android::ToJavaArrayOfStrings(env, labels));
561 Java_ContentViewCore_showSelectPopup(env, j_obj.obj(), 564 Java_ContentViewCore_showSelectPopup(env, j_obj.obj(),
562 items_array.obj(), enabled_array.obj(), 565 bounds_rect.obj(),
563 multiple, selected_array.obj()); 566 items_array.obj(),
567 enabled_array.obj(),
568 item_font_size,
569 multiple,
570 selected_array.obj());
564 } 571 }
565 572
566 void ContentViewCoreImpl::HideSelectPopupMenu() { 573 void ContentViewCoreImpl::HideSelectPopupMenu() {
567 JNIEnv* env = AttachCurrentThread(); 574 JNIEnv* env = AttachCurrentThread();
568 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 575 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
569 if (!j_obj.is_null()) 576 if (!j_obj.is_null())
570 Java_ContentViewCore_hideSelectPopup(env, j_obj.obj()); 577 Java_ContentViewCore_hideSelectPopup(env, j_obj.obj());
571 } 578 }
572 579
573 void ContentViewCoreImpl::ConfirmTouchEvent(InputEventAckState ack_result) { 580 void ContentViewCoreImpl::ConfirmTouchEvent(InputEventAckState ack_result) {
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 reinterpret_cast<ui::ViewAndroid*>(view_android), 1808 reinterpret_cast<ui::ViewAndroid*>(view_android),
1802 reinterpret_cast<ui::WindowAndroid*>(window_android)); 1809 reinterpret_cast<ui::WindowAndroid*>(window_android));
1803 return reinterpret_cast<intptr_t>(view); 1810 return reinterpret_cast<intptr_t>(view);
1804 } 1811 }
1805 1812
1806 bool RegisterContentViewCore(JNIEnv* env) { 1813 bool RegisterContentViewCore(JNIEnv* env) {
1807 return RegisterNativesImpl(env); 1814 return RegisterNativesImpl(env);
1808 } 1815 }
1809 1816
1810 } // namespace content 1817 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698