Commit 2065e9fc authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

content: don't show context menus for invisible WebContents

Bug: 855127
Change-Id: I2942e122373c210bd0bceaa59791e2619186f79b
Reviewed-on: https://chromium-review.googlesource.com/1175935Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583317}
parent 8ac49d0d
...@@ -5052,6 +5052,12 @@ void WebContentsImpl::ShowContextMenu(RenderFrameHost* render_frame_host, ...@@ -5052,6 +5052,12 @@ void WebContentsImpl::ShowContextMenu(RenderFrameHost* render_frame_host,
if (showing_context_menu_) if (showing_context_menu_)
return; return;
// If the WebContents is not visible, don't show the context menu. This can
// happen if the renderer takes a while to return the right-click event back
// to the browser process and in the meantime the user switches tabs.
if (GetVisibility() != Visibility::VISIBLE)
return;
ContextMenuParams context_menu_params(params); ContextMenuParams context_menu_params(params);
// Allow WebContentsDelegates to handle the context menu operation first. // Allow WebContentsDelegates to handle the context menu operation first.
if (delegate_ && delegate_->HandleContextMenu(context_menu_params)) if (delegate_ && delegate_->HandleContextMenu(context_menu_params))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment