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

Unified Diff: content/renderer/pepper/pepper_plugin_delegate_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/pepper/pepper_plugin_delegate_impl.cc
diff --git a/content/renderer/pepper/pepper_plugin_delegate_impl.cc b/content/renderer/pepper/pepper_plugin_delegate_impl.cc
index f7c724fc8ac8e25642ab0b73a7901b71eefe36d7..bfd46732c566cc248413a77860c55b7214a2b8f3 100644
--- a/content/renderer/pepper/pepper_plugin_delegate_impl.cc
+++ b/content/renderer/pepper/pepper_plugin_delegate_impl.cc
@@ -478,6 +478,32 @@ scoped_refptr<PepperBrokerImpl> PepperPluginDelegateImpl::CreateBroker(
return broker;
}
+void PepperPluginDelegateImpl::OnCustomContextMenuAction(int request_id,
+ unsigned action) {
+ // Just save the action.
+ DCHECK(!has_saved_context_menu_action_);
+ has_saved_context_menu_action_ = true;
+ saved_context_menu_action_ = action;
+}
+
+void PepperPluginDelegateImpl::OnCustomContextMenuClosed(int request_id) {
+ PendingContextMenuMap::iterator found =
+ pending_context_menus_.find(request_id);
+ if (found == pending_context_menus_.end()) {
+ NOTREACHED() << "OnContextMenuClosed() called twice for the same menu.";
+ return;
+ }
+
+ if (has_saved_context_menu_action_) {
+ found->second->CompleteShow(PP_OK, saved_context_menu_action_);
+ has_saved_context_menu_action_ = false;
+ saved_context_menu_action_ = 0;
+ } else {
+ found->second->CompleteShow(PP_ERROR_USERCANCEL, 0);
+ }
+ pending_context_menus_.erase(found);
+}
+
void PepperPluginDelegateImpl::OnPpapiBrokerChannelCreated(
int request_id,
const IPC::ChannelHandle& handle) {
@@ -1371,15 +1397,10 @@ int32_t PepperPluginDelegateImpl::ShowContextMenu(
static_cast<RenderWidgetFullscreenPepper*>(container)->routing_id();
}
- int request_id = pending_context_menus_.Add(
- new scoped_refptr<webkit::ppapi::PPB_Flash_Menu_Impl>(menu));
-
ContextMenuParams params;
params.x = position.x();
params.y = position.y();
params.custom_context.is_pepper_menu = true;
- params.custom_context.request_id = request_id;
- params.custom_context.render_widget_id = render_widget_id;
params.custom_items = menu->menu_data();
// Transform the position to be in render view's coordinates.
@@ -1393,47 +1414,12 @@ int32_t PepperPluginDelegateImpl::ShowContextMenu(
params.y += instance->view_data().rect.point.y;
}
- IPC::Message* msg = new ViewHostMsg_ContextMenu(render_view_->routing_id(),
- params);
- if (!render_view_->Send(msg)) {
- pending_context_menus_.Remove(request_id);
- return PP_ERROR_FAILED;
- }
-
+ int request_id = render_view_->ShowContextMenu(this, params);
+ pending_context_menus_[request_id] =
+ scoped_refptr<webkit::ppapi::PPB_Flash_Menu_Impl>(menu);
return PP_OK_COMPLETIONPENDING;
}
-void PepperPluginDelegateImpl::OnContextMenuClosed(
- const CustomContextMenuContext& custom_context) {
- int request_id = custom_context.request_id;
- scoped_refptr<webkit::ppapi::PPB_Flash_Menu_Impl>* menu_ptr =
- pending_context_menus_.Lookup(request_id);
- if (!menu_ptr) {
- NOTREACHED() << "CompleteShowContextMenu() called twice for the same menu.";
- return;
- }
- scoped_refptr<webkit::ppapi::PPB_Flash_Menu_Impl> menu = *menu_ptr;
- DCHECK(menu.get());
- pending_context_menus_.Remove(request_id);
-
- if (has_saved_context_menu_action_) {
- menu->CompleteShow(PP_OK, saved_context_menu_action_);
- has_saved_context_menu_action_ = false;
- saved_context_menu_action_ = 0;
- } else {
- menu->CompleteShow(PP_ERROR_USERCANCEL, 0);
- }
-}
-
-void PepperPluginDelegateImpl::OnCustomContextMenuAction(
- const CustomContextMenuContext& custom_context,
- unsigned action) {
- // Just save the action.
- DCHECK(!has_saved_context_menu_action_);
- has_saved_context_menu_action_ = true;
- saved_context_menu_action_ = action;
-}
-
webkit::ppapi::FullscreenContainer*
PepperPluginDelegateImpl::CreateFullscreenContainer(
webkit::ppapi::PluginInstance* instance) {

Powered by Google App Engine
This is Rietveld 408576698