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

Side by Side Diff: components/web_contents_delegate_android/web_contents_delegate_android.cc

Issue 2089933002: Context Menu Refactor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixing nits Created 4 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "components/web_contents_delegate_android/web_contents_delegate_android .h" 5 #include "components/web_contents_delegate_android/web_contents_delegate_android .h"
6 6
7 #include <android/keycodes.h> 7 #include <android/keycodes.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"
11 #include "base/android/jni_string.h" 11 #include "base/android/jni_string.h"
12 #include "components/web_contents_delegate_android/color_chooser_android.h" 12 #include "components/web_contents_delegate_android/color_chooser_android.h"
13 #include "components/web_contents_delegate_android/validation_message_bubble_and roid.h" 13 #include "components/web_contents_delegate_android/validation_message_bubble_and roid.h"
14 #include "content/browser/renderer_host/render_widget_host_view_android.h"
14 #include "content/public/browser/android/content_view_core.h" 15 #include "content/public/browser/android/content_view_core.h"
15 #include "content/public/browser/color_chooser.h" 16 #include "content/public/browser/color_chooser.h"
16 #include "content/public/browser/global_request_id.h" 17 #include "content/public/browser/global_request_id.h"
17 #include "content/public/browser/invalidate_type.h" 18 #include "content/public/browser/invalidate_type.h"
18 #include "content/public/browser/native_web_keyboard_event.h" 19 #include "content/public/browser/native_web_keyboard_event.h"
19 #include "content/public/browser/navigation_controller.h" 20 #include "content/public/browser/navigation_controller.h"
20 #include "content/public/browser/page_navigator.h" 21 #include "content/public/browser/page_navigator.h"
22 #include "content/public/browser/render_frame_host.h"
21 #include "content/public/browser/render_widget_host_view.h" 23 #include "content/public/browser/render_widget_host_view.h"
22 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
25 #include "content/public/common/context_menu_params.h"
23 #include "content/public/common/referrer.h" 26 #include "content/public/common/referrer.h"
24 #include "jni/WebContentsDelegateAndroid_jni.h" 27 #include "jni/WebContentsDelegateAndroid_jni.h"
25 #include "ui/base/window_open_disposition.h" 28 #include "ui/base/window_open_disposition.h"
26 #include "ui/gfx/geometry/rect.h" 29 #include "ui/gfx/geometry/rect.h"
27 #include "url/gurl.h" 30 #include "url/gurl.h"
28 31
29 using base::android::AttachCurrentThread; 32 using base::android::AttachCurrentThread;
30 using base::android::ConvertUTF8ToJavaString; 33 using base::android::ConvertUTF8ToJavaString;
31 using base::android::ConvertUTF16ToJavaString; 34 using base::android::ConvertUTF16ToJavaString;
32 using base::android::ScopedJavaLocalRef; 35 using base::android::ScopedJavaLocalRef;
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 if (rwhv) { 429 if (rwhv) {
427 validation_message_bubble_->SetPositionRelativeToAnchor( 430 validation_message_bubble_->SetPositionRelativeToAnchor(
428 rwhv->GetRenderWidgetHost(), anchor_in_root_view); 431 rwhv->GetRenderWidgetHost(), anchor_in_root_view);
429 } 432 }
430 } 433 }
431 434
432 void WebContentsDelegateAndroid::RequestAppBannerFromDevTools( 435 void WebContentsDelegateAndroid::RequestAppBannerFromDevTools(
433 content::WebContents* web_contents) { 436 content::WebContents* web_contents) {
434 } 437 }
435 438
439 static bool shouldShowFloatingActionMode(
440 const content::ContextMenuParams& params) {
441 return !(!params.link_url.is_empty()
442 || params.media_type == blink::WebContextMenuData::MediaTypeImage
443 || params.media_type == blink::WebContextMenuData::MediaTypeVideo);
444 }
445
446 bool WebContentsDelegateAndroid::HandleContextMenu(
447 content::RenderFrameHost* render_frame_host,
448 const content::ContextMenuParams& params) {
449 if (!shouldShowFloatingActionMode(params))
450 return false;
451 content::RenderWidgetHostViewAndroid* rwhv =
452 static_cast<content::RenderWidgetHostViewAndroid*>(
453 render_frame_host->GetView());
454
455 if (!rwhv)
456 return false;
457 rwhv->CreateSelectActionMode(params);
458 return true;
459 }
460
461
436 // ---------------------------------------------------------------------------- 462 // ----------------------------------------------------------------------------
437 // Native JNI methods 463 // Native JNI methods
438 // ---------------------------------------------------------------------------- 464 // ----------------------------------------------------------------------------
439 465
440 // Register native methods 466 // Register native methods
441 467
442 bool RegisterWebContentsDelegateAndroid(JNIEnv* env) { 468 bool RegisterWebContentsDelegateAndroid(JNIEnv* env) {
443 return RegisterNativesImpl(env); 469 return RegisterNativesImpl(env);
444 } 470 }
445 471
446 } // namespace web_contents_delegate_android 472 } // namespace web_contents_delegate_android
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698