Commit 00122a4d authored by cevans@chromium.org's avatar cevans@chromium.org

Fix Linux breakage of context menu items for the blocked plugin placeholder.

(I'm not sure about other platforms; on Linux, GTK has the weird quirk of
firing "context menu closed" before "context menu item selected", so it's
best to use a solution that doesn't try and track the visibility state of the
context menu).

BUG=none
TEST=manual

Review URL: http://codereview.chromium.org/6335008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71777 0039d316-1c4b-4281-b951-d872f2087c98
parent cf4f2ca1
...@@ -41,6 +41,9 @@ using WebKit::WebString; ...@@ -41,6 +41,9 @@ using WebKit::WebString;
using WebKit::WebVector; using WebKit::WebVector;
static const char* const kBlockedPluginDataURL = "chrome://blockedplugindata/"; static const char* const kBlockedPluginDataURL = "chrome://blockedplugindata/";
// TODO(cevans) - move these to a shared header file so that there are no
// collisions in the longer term. Currently, blocked_plugin.cc is the only
// user of custom menu commands (extension menu items have their own range).
static const unsigned kMenuActionLoad = 1; static const unsigned kMenuActionLoad = 1;
static const unsigned kMenuActionRemove = 2; static const unsigned kMenuActionRemove = 2;
...@@ -53,8 +56,7 @@ BlockedPlugin::BlockedPlugin(RenderView* render_view, ...@@ -53,8 +56,7 @@ BlockedPlugin::BlockedPlugin(RenderView* render_view,
const string16& message) const string16& message)
: RenderViewObserver(render_view), : RenderViewObserver(render_view),
frame_(frame), frame_(frame),
plugin_params_(params), plugin_params_(params) {
custom_menu_showing_(false) {
const base::StringPiece template_html( const base::StringPiece template_html(
ResourceBundle::GetSharedInstance().GetRawDataResource(template_id)); ResourceBundle::GetSharedInstance().GetRawDataResource(template_id));
...@@ -118,22 +120,18 @@ void BlockedPlugin::ShowContextMenu(const WebKit::WebMouseEvent& event) { ...@@ -118,22 +120,18 @@ void BlockedPlugin::ShowContextMenu(const WebKit::WebMouseEvent& event) {
menu_data.customItems.swap(custom_items); menu_data.customItems.swap(custom_items);
menu_data.mousePosition = WebPoint(event.windowX, event.windowY); menu_data.mousePosition = WebPoint(event.windowX, event.windowY);
render_view()->showContextMenu(NULL, menu_data); render_view()->showContextMenu(NULL, menu_data);
custom_menu_showing_ = true;
} }
bool BlockedPlugin::OnMessageReceived(const IPC::Message& message) { bool BlockedPlugin::OnMessageReceived(const IPC::Message& message) {
if (custom_menu_showing_ && // We don't swallow ViewMsg_CustomContextMenuAction because we listen for all
message.type() == ViewMsg_CustomContextMenuAction::ID) { // custom menu IDs, and not just our own. We don't swallow
// ViewMsg_LoadBlockedPlugins because multiple blocked plugins have an
// interest in it.
if (message.type() == ViewMsg_CustomContextMenuAction::ID) {
ViewMsg_CustomContextMenuAction::Dispatch( ViewMsg_CustomContextMenuAction::Dispatch(
&message, this, this, &BlockedPlugin::OnMenuItemSelected); &message, this, this, &BlockedPlugin::OnMenuItemSelected);
return true; } else if (message.type() == ViewMsg_LoadBlockedPlugins::ID) {
}
// Don't want to swallow these messages.
if (message.type() == ViewMsg_LoadBlockedPlugins::ID) {
LoadPlugin(); LoadPlugin();
} else if (message.type() == ViewMsg_ContextMenuClosed::ID) {
custom_menu_showing_ = false;
} }
return false; return false;
...@@ -144,8 +142,6 @@ void BlockedPlugin::OnMenuItemSelected(unsigned id) { ...@@ -144,8 +142,6 @@ void BlockedPlugin::OnMenuItemSelected(unsigned id) {
LoadPlugin(); LoadPlugin();
} else if (id == kMenuActionRemove) { } else if (id == kMenuActionRemove) {
HidePlugin(); HidePlugin();
} else {
NOTREACHED();
} }
} }
......
...@@ -66,8 +66,6 @@ class BlockedPlugin : public RenderViewObserver, ...@@ -66,8 +66,6 @@ class BlockedPlugin : public RenderViewObserver,
webkit::npapi::WebViewPlugin* plugin_; webkit::npapi::WebViewPlugin* plugin_;
// The name of the plugin that was blocked. // The name of the plugin that was blocked.
string16 name_; string16 name_;
// True iff we're showing a custom menu.
bool custom_menu_showing_;
}; };
#endif // CHROME_RENDERER_BLOCKED_PLUGIN_H_ #endif // CHROME_RENDERER_BLOCKED_PLUGIN_H_
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