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

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
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() {
« content/public/renderer/render_view.h ('K') | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698