Commit 077e704b authored by fsamuel@chromium.org's avatar fsamuel@chromium.org

<webview>: Make HandleContextMenu easier to refactor

In the future, BrowserPluginGuest will no longer be a WebContentsDelegate, and so special handling for guests that relies on the internal implementation details of BrowserPlugin should be moved to chrome.

BUG=364141, 330264

Review URL: https://codereview.chromium.org/296703005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272579 0039d316-1c4b-4281-b951-d872f2087c98
parent 3827620e
......@@ -423,17 +423,10 @@ ColorChooser* BrowserPluginGuest::OpenColorChooser(
}
bool BrowserPluginGuest::HandleContextMenu(const ContextMenuParams& params) {
if (delegate_) {
WebContentsViewGuest* view_guest =
static_cast<WebContentsViewGuest*>(GetWebContents()->GetView());
ContextMenuParams context_menu_params =
view_guest->ConvertContextMenuParams(params);
return delegate_->HandleContextMenu(context_menu_params);
}
if (!delegate_)
return false;
// Will be handled by WebContentsViewGuest.
return false;
return delegate_->HandleContextMenu(params);
}
void BrowserPluginGuest::HandleKeyboardEvent(
......
......@@ -3188,11 +3188,18 @@ void WebContentsImpl::WorkerCrashed(RenderFrameHost* render_frame_host) {
void WebContentsImpl::ShowContextMenu(RenderFrameHost* render_frame_host,
const ContextMenuParams& params) {
ContextMenuParams context_menu_params(params);
// Allow WebContentsDelegates to handle the context menu operation first.
if (delegate_ && delegate_->HandleContextMenu(params))
if (GetBrowserPluginGuest()) {
WebContentsViewGuest* view_guest =
static_cast<WebContentsViewGuest*>(GetView());
context_menu_params = view_guest->ConvertContextMenuParams(params);
}
if (delegate_ && delegate_->HandleContextMenu(context_menu_params))
return;
render_view_host_delegate_view_->ShowContextMenu(render_frame_host, params);
render_view_host_delegate_view_->ShowContextMenu(render_frame_host,
context_menu_params);
}
void WebContentsImpl::RunJavaScriptMessage(
......
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