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

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

Issue 501583003: Move external popup menus from WebViewClient to WebFrameClient, part 3/3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 | Annotate | Revision Log
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"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "cc/layers/layer.h" 16 #include "cc/layers/layer.h"
17 #include "cc/layers/solid_color_layer.h" 17 #include "cc/layers/solid_color_layer.h"
18 #include "cc/output/begin_frame_args.h" 18 #include "cc/output/begin_frame_args.h"
19 #include "content/browser/accessibility/browser_accessibility_state_impl.h" 19 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
20 #include "content/browser/android/gesture_event_type.h" 20 #include "content/browser/android/gesture_event_type.h"
21 #include "content/browser/android/interstitial_page_delegate_android.h" 21 #include "content/browser/android/interstitial_page_delegate_android.h"
22 #include "content/browser/android/java/gin_java_bridge_dispatcher_host.h" 22 #include "content/browser/android/java/gin_java_bridge_dispatcher_host.h"
23 #include "content/browser/android/load_url_params.h" 23 #include "content/browser/android/load_url_params.h"
24 #include "content/browser/android/popup_touch_handle_drawable.h" 24 #include "content/browser/android/popup_touch_handle_drawable.h"
25 #include "content/browser/frame_host/interstitial_page_impl.h" 25 #include "content/browser/frame_host/interstitial_page_impl.h"
26 #include "content/browser/frame_host/navigation_controller_impl.h" 26 #include "content/browser/frame_host/navigation_controller_impl.h"
27 #include "content/browser/frame_host/navigation_entry_impl.h" 27 #include "content/browser/frame_host/navigation_entry_impl.h"
28 #include "content/browser/frame_host/render_frame_host_impl.h"
28 #include "content/browser/geolocation/geolocation_dispatcher_host.h" 29 #include "content/browser/geolocation/geolocation_dispatcher_host.h"
29 #include "content/browser/media/media_web_contents_observer.h" 30 #include "content/browser/media/media_web_contents_observer.h"
30 #include "content/browser/renderer_host/compositor_impl_android.h" 31 #include "content/browser/renderer_host/compositor_impl_android.h"
31 #include "content/browser/renderer_host/input/motion_event_android.h" 32 #include "content/browser/renderer_host/input/motion_event_android.h"
32 #include "content/browser/renderer_host/input/web_input_event_builders_android.h " 33 #include "content/browser/renderer_host/input/web_input_event_builders_android.h "
33 #include "content/browser/renderer_host/input/web_input_event_util.h" 34 #include "content/browser/renderer_host/input/web_input_event_util.h"
34 #include "content/browser/renderer_host/render_view_host_impl.h" 35 #include "content/browser/renderer_host/render_view_host_impl.h"
35 #include "content/browser/renderer_host/render_widget_host_impl.h" 36 #include "content/browser/renderer_host/render_widget_host_impl.h"
36 #include "content/browser/renderer_host/render_widget_host_view_android.h" 37 #include "content/browser/renderer_host/render_widget_host_view_android.h"
37 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host. h" 38 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host. h"
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 void ContentViewCoreImpl::OnBackgroundColorChanged(SkColor color) { 417 void ContentViewCoreImpl::OnBackgroundColorChanged(SkColor color) {
417 root_layer_->SetBackgroundColor(color); 418 root_layer_->SetBackgroundColor(color);
418 419
419 JNIEnv* env = AttachCurrentThread(); 420 JNIEnv* env = AttachCurrentThread();
420 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 421 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
421 if (obj.is_null()) 422 if (obj.is_null())
422 return; 423 return;
423 Java_ContentViewCore_onBackgroundColorChanged(env, obj.obj(), color); 424 Java_ContentViewCore_onBackgroundColorChanged(env, obj.obj(), color);
424 } 425 }
425 426
426 void ContentViewCoreImpl::ShowSelectPopupMenu(const gfx::Rect& bounds, 427 void ContentViewCoreImpl::ShowSelectPopupMenu(
427 const std::vector<MenuItem>& items, int selected_item, bool multiple) { 428 RenderFrameHost* frame,
429 const gfx::Rect& bounds,
430 const std::vector<MenuItem>& items,
431 int selected_item,
432 bool multiple) {
428 JNIEnv* env = AttachCurrentThread(); 433 JNIEnv* env = AttachCurrentThread();
429 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 434 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
430 if (j_obj.is_null()) 435 if (j_obj.is_null())
431 return; 436 return;
432 437
433 ScopedJavaLocalRef<jobject> bounds_rect(CreateJavaRect(env, bounds)); 438 ScopedJavaLocalRef<jobject> bounds_rect(CreateJavaRect(env, bounds));
434 439
435 // For multi-select list popups we find the list of previous selections by 440 // For multi-select list popups we find the list of previous selections by
436 // iterating through the items. But for single selection popups we take the 441 // iterating through the items. But for single selection popups we take the
437 // given |selected_item| as is. 442 // given |selected_item| as is.
(...skipping 23 matching lines...) Expand all
461 for (size_t i = 0; i < items.size(); ++i) { 466 for (size_t i = 0; i < items.size(); ++i) {
462 labels.push_back(items[i].label); 467 labels.push_back(items[i].label);
463 jint enabled = 468 jint enabled =
464 (items[i].type == MenuItem::GROUP ? POPUP_ITEM_TYPE_GROUP : 469 (items[i].type == MenuItem::GROUP ? POPUP_ITEM_TYPE_GROUP :
465 (items[i].enabled ? POPUP_ITEM_TYPE_ENABLED : 470 (items[i].enabled ? POPUP_ITEM_TYPE_ENABLED :
466 POPUP_ITEM_TYPE_DISABLED)); 471 POPUP_ITEM_TYPE_DISABLED));
467 env->SetIntArrayRegion(enabled_array.obj(), i, 1, &enabled); 472 env->SetIntArrayRegion(enabled_array.obj(), i, 1, &enabled);
468 } 473 }
469 ScopedJavaLocalRef<jobjectArray> items_array( 474 ScopedJavaLocalRef<jobjectArray> items_array(
470 base::android::ToJavaArrayOfStrings(env, labels)); 475 base::android::ToJavaArrayOfStrings(env, labels));
471 Java_ContentViewCore_showSelectPopup(env, j_obj.obj(), 476 Java_ContentViewCore_showSelectPopup(env,
477 j_obj.obj(),
478 reinterpret_cast<intptr_t>(frame),
472 bounds_rect.obj(), 479 bounds_rect.obj(),
473 items_array.obj(), 480 items_array.obj(),
474 enabled_array.obj(), 481 enabled_array.obj(),
475 multiple, 482 multiple,
476 selected_array.obj()); 483 selected_array.obj());
477 } 484 }
478 485
479 void ContentViewCoreImpl::HideSelectPopupMenu() { 486 void ContentViewCoreImpl::HideSelectPopupMenu() {
480 JNIEnv* env = AttachCurrentThread(); 487 JNIEnv* env = AttachCurrentThread();
481 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); 488 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 scoped_refptr<cc::Layer> ContentViewCoreImpl::GetLayer() const { 810 scoped_refptr<cc::Layer> ContentViewCoreImpl::GetLayer() const {
804 return root_layer_.get(); 811 return root_layer_.get();
805 } 812 }
806 813
807 // ---------------------------------------------------------------------------- 814 // ----------------------------------------------------------------------------
808 // Methods called from Java via JNI 815 // Methods called from Java via JNI
809 // ---------------------------------------------------------------------------- 816 // ----------------------------------------------------------------------------
810 817
811 void ContentViewCoreImpl::SelectPopupMenuItems(JNIEnv* env, 818 void ContentViewCoreImpl::SelectPopupMenuItems(JNIEnv* env,
812 jobject obj, 819 jobject obj,
820 jlong selectPopupSourceFrame,
813 jintArray indices) { 821 jintArray indices) {
814 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( 822 RenderFrameHostImpl* rfhi =
815 web_contents_->GetRenderViewHost()); 823 reinterpret_cast<RenderFrameHostImpl*>(selectPopupSourceFrame);
816 DCHECK(rvhi); 824 DCHECK(rfhi);
817 if (indices == NULL) { 825 if (indices == NULL) {
818 rvhi->DidCancelPopupMenu(); 826 rfhi->DidCancelPopupMenu();
819 return; 827 return;
820 } 828 }
821 829
822 int selected_count = env->GetArrayLength(indices); 830 int selected_count = env->GetArrayLength(indices);
823 std::vector<int> selected_indices; 831 std::vector<int> selected_indices;
824 jint* indices_ptr = env->GetIntArrayElements(indices, NULL); 832 jint* indices_ptr = env->GetIntArrayElements(indices, NULL);
825 for (int i = 0; i < selected_count; ++i) 833 for (int i = 0; i < selected_count; ++i)
826 selected_indices.push_back(indices_ptr[i]); 834 selected_indices.push_back(indices_ptr[i]);
827 env->ReleaseIntArrayElements(indices, indices_ptr, JNI_ABORT); 835 env->ReleaseIntArrayElements(indices, indices_ptr, JNI_ABORT);
828 rvhi->DidSelectPopupMenuItems(selected_indices); 836 rfhi->DidSelectPopupMenuItems(selected_indices);
829 } 837 }
830 838
831 void ContentViewCoreImpl::LoadUrl( 839 void ContentViewCoreImpl::LoadUrl(
832 JNIEnv* env, jobject obj, 840 JNIEnv* env, jobject obj,
833 jstring url, 841 jstring url,
834 jint load_url_type, 842 jint load_url_type,
835 jint transition_type, 843 jint transition_type,
836 jstring j_referrer_url, 844 jstring j_referrer_url,
837 jint referrer_policy, 845 jint referrer_policy,
838 jint ua_override_option, 846 jint ua_override_option,
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
1508 reinterpret_cast<ui::WindowAndroid*>(window_android), 1516 reinterpret_cast<ui::WindowAndroid*>(window_android),
1509 retained_objects_set); 1517 retained_objects_set);
1510 return reinterpret_cast<intptr_t>(view); 1518 return reinterpret_cast<intptr_t>(view);
1511 } 1519 }
1512 1520
1513 bool RegisterContentViewCore(JNIEnv* env) { 1521 bool RegisterContentViewCore(JNIEnv* env) {
1514 return RegisterNativesImpl(env); 1522 return RegisterNativesImpl(env);
1515 } 1523 }
1516 1524
1517 } // namespace content 1525 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/content_view_core_impl.h ('k') | content/browser/browser_plugin/browser_plugin_guest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698