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

Unified Diff: content/renderer/render_view_impl.cc

Issue 11083002: Allow custom context menus to be requested. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_view_impl.cc
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index e7d3d5947b630523917ef20a03ba9902df5521df..503d87d53f9d57689f17fd8d8260d0dc1309eb0e 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -4420,9 +4420,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 {
@@ -5153,12 +5157,15 @@ 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);
+ client->OnMenuAction(custom_context.request_id, action);
+ } else {
+ // Internal request, forward to WebKit.
webview()->performCustomContextMenuAction(action);
- FOR_EACH_OBSERVER(RenderViewObserver, observers_,
- ContextMenuAction(action));
+ }
}
void RenderViewImpl::OnEnumerateDirectoryResponse(
@@ -6292,10 +6299,16 @@ 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);
+ client->OnMenuClosed(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() {
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698