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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: components/web_contents_delegate_android/web_contents_delegate_android.cc
diff --git a/components/web_contents_delegate_android/web_contents_delegate_android.cc b/components/web_contents_delegate_android/web_contents_delegate_android.cc
index 9ecfc69fee3399c31be9941513d37c9397323d08..55b3a3173f78e446238359e2a3e4877f65ba8aa0 100644
--- a/components/web_contents_delegate_android/web_contents_delegate_android.cc
+++ b/components/web_contents_delegate_android/web_contents_delegate_android.cc
@@ -11,6 +11,7 @@
#include "base/android/jni_string.h"
#include "components/web_contents_delegate_android/color_chooser_android.h"
#include "components/web_contents_delegate_android/validation_message_bubble_android.h"
+#include "content/browser/renderer_host/render_widget_host_view_android.h"
#include "content/public/browser/android/content_view_core.h"
#include "content/public/browser/color_chooser.h"
#include "content/public/browser/global_request_id.h"
@@ -18,8 +19,10 @@
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/page_navigator.h"
+#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/common/context_menu_params.h"
#include "content/public/common/referrer.h"
#include "jni/WebContentsDelegateAndroid_jni.h"
#include "ui/base/window_open_disposition.h"
@@ -433,6 +436,29 @@ void WebContentsDelegateAndroid::RequestAppBannerFromDevTools(
content::WebContents* web_contents) {
}
+static bool shouldShowFloatingActionMode(
+ const content::ContextMenuParams& params) {
+ return !(!params.link_url.is_empty()
+ || params.media_type == blink::WebContextMenuData::MediaTypeImage
+ || params.media_type == blink::WebContextMenuData::MediaTypeVideo);
+}
+
+bool WebContentsDelegateAndroid::HandleContextMenu(
+ content::RenderFrameHost* render_frame_host,
+ const content::ContextMenuParams& params) {
+ if (!shouldShowFloatingActionMode(params))
+ return false;
+ content::RenderWidgetHostViewAndroid* rwhv =
+ static_cast<content::RenderWidgetHostViewAndroid*>(
+ render_frame_host->GetView());
+
+ if (!rwhv)
+ return false;
+ rwhv->CreateSelectActionMode(params);
+ return true;
+}
+
+
// ----------------------------------------------------------------------------
// Native JNI methods
// ----------------------------------------------------------------------------

Powered by Google App Engine
This is Rietveld 408576698