Chromium Code Reviews| Index: content/renderer/render_view_impl.cc |
| diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc |
| index aef2207674ee7aca7f20337151b20a16de39fe68..298ca638122d74fa224d1b8c89f8329c8610804e 100644 |
| --- a/content/renderer/render_view_impl.cc |
| +++ b/content/renderer/render_view_impl.cc |
| @@ -4400,9 +4400,13 @@ float RenderViewImpl::GetFilteredTimePerFrame() const { |
| return filtered_time_per_frame(); |
| } |
| -void RenderViewImpl::ShowContextMenu(WebKit::WebFrame* frame, |
| - const WebKit::WebContextMenuData& data) { |
| - showContextMenu(frame, data); |
| +int RenderViewImpl::ShowContextMenu(content::ContextMenuClient* client, |
| + const content::ContextMenuParams& params) { |
| + DCHECK(client); // A null client means "internal" when we issue callbacks. |
| + content::ContextMenuParams our_params(params); |
| + our_params.custom_context.request_id = pending_context_menus_.Add(client); |
| + Send(new ViewHostMsg_ContextMenu(routing_id_, our_params)); |
| + return our_params.custom_context.request_id; |
| } |
| WebKit::WebPageVisibilityState RenderViewImpl::GetVisibilityState() const { |
| @@ -5132,12 +5136,16 @@ void RenderViewImpl::OnSetAltErrorPageURL(const GURL& url) { |
| void RenderViewImpl::OnCustomContextMenuAction( |
| const content::CustomContextMenuContext& custom_context, |
| unsigned action) { |
| - if (custom_context.is_pepper_menu) |
| - pepper_delegate_.OnCustomContextMenuAction(custom_context, action); |
| - else |
| + if (custom_context.request_id) { |
| + // External context menu request, look in our map. |
| + content::ContextMenuClient* client = |
| + pending_context_menus_.Lookup(custom_context.request_id); |
| + if (client) |
| + client->OnCustomContextMenuAction(custom_context.request_id, action); |
| + } else { |
| + // Internal request, forward to WebKit. |
| webview()->performCustomContextMenuAction(action); |
| - FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| - ContextMenuAction(action)); |
| + } |
| } |
| void RenderViewImpl::OnEnumerateDirectoryResponse( |
| @@ -6271,10 +6279,18 @@ void RenderViewImpl::OnSelectPopupMenuItems( |
| void RenderViewImpl::OnContextMenuClosed( |
| const content::CustomContextMenuContext& custom_context) { |
| - if (custom_context.is_pepper_menu) |
| - pepper_delegate_.OnContextMenuClosed(custom_context); |
| - else |
| + if (custom_context.request_id) { |
| + // External request, should be in our map. |
| + content::ContextMenuClient* client = |
| + pending_context_menus_.Lookup(custom_context.request_id); |
| + if (client) { |
|
jam
2012/10/10 04:01:43
nit: why the null check? seems that if this is NUL
brettw
2012/10/10 05:10:17
Removed, this was leftover from a previous version
|
| + client->OnCustomContextMenuClosed(custom_context.request_id); |
| + pending_context_menus_.Remove(custom_context.request_id); |
| + } |
| + } else { |
| + // Internal request, forward to WebKit. |
| context_menu_node_.reset(); |
| + } |
| } |
| void RenderViewImpl::OnEnableViewSourceMode() { |