| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/renderer/blocked_plugin.h" | 5 #include "chrome/renderer/blocked_plugin.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/string_piece.h" | 8 #include "base/string_piece.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 using WebKit::WebString; | 40 using WebKit::WebString; |
| 41 using WebKit::WebVector; | 41 using WebKit::WebVector; |
| 42 | 42 |
| 43 static const char* const kBlockedPluginDataURL = "chrome://blockedplugindata/"; | 43 static const char* const kBlockedPluginDataURL = "chrome://blockedplugindata/"; |
| 44 // TODO(cevans) - move these to a shared header file so that there are no | 44 // TODO(cevans) - move these to a shared header file so that there are no |
| 45 // collisions in the longer term. Currently, blocked_plugin.cc is the only | 45 // collisions in the longer term. Currently, blocked_plugin.cc is the only |
| 46 // user of custom menu commands (extension menu items have their own range). | 46 // user of custom menu commands (extension menu items have their own range). |
| 47 static const unsigned kMenuActionLoad = 1; | 47 static const unsigned kMenuActionLoad = 1; |
| 48 static const unsigned kMenuActionRemove = 2; | 48 static const unsigned kMenuActionRemove = 2; |
| 49 | 49 |
| 50 static const BlockedPlugin* gLastActiveMenu; |
| 51 |
| 50 BlockedPlugin::BlockedPlugin(RenderView* render_view, | 52 BlockedPlugin::BlockedPlugin(RenderView* render_view, |
| 51 WebFrame* frame, | 53 WebFrame* frame, |
| 52 const webkit::npapi::PluginGroup& info, | 54 const webkit::npapi::PluginGroup& info, |
| 53 const WebPluginParams& params, | 55 const WebPluginParams& params, |
| 54 const WebPreferences& preferences, | 56 const WebPreferences& preferences, |
| 55 int template_id, | 57 int template_id, |
| 56 const string16& message, | 58 const string16& message, |
| 57 bool is_blocked_for_prerendering) | 59 bool is_blocked_for_prerendering) |
| 58 : RenderViewObserver(render_view), | 60 : RenderViewObserver(render_view), |
| 59 frame_(frame), | 61 frame_(frame), |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 WebMenuItemInfo hide_item; | 117 WebMenuItemInfo hide_item; |
| 116 hide_item.action = kMenuActionRemove; | 118 hide_item.action = kMenuActionRemove; |
| 117 hide_item.enabled = true; | 119 hide_item.enabled = true; |
| 118 hide_item.label = WebString::fromUTF8( | 120 hide_item.label = WebString::fromUTF8( |
| 119 l10n_util::GetStringUTF8(IDS_CONTENT_CONTEXT_PLUGIN_HIDE).c_str()); | 121 l10n_util::GetStringUTF8(IDS_CONTENT_CONTEXT_PLUGIN_HIDE).c_str()); |
| 120 custom_items[3] = hide_item; | 122 custom_items[3] = hide_item; |
| 121 | 123 |
| 122 menu_data.customItems.swap(custom_items); | 124 menu_data.customItems.swap(custom_items); |
| 123 menu_data.mousePosition = WebPoint(event.windowX, event.windowY); | 125 menu_data.mousePosition = WebPoint(event.windowX, event.windowY); |
| 124 render_view()->showContextMenu(NULL, menu_data); | 126 render_view()->showContextMenu(NULL, menu_data); |
| 127 gLastActiveMenu = this; |
| 125 } | 128 } |
| 126 | 129 |
| 127 bool BlockedPlugin::OnMessageReceived(const IPC::Message& message) { | 130 bool BlockedPlugin::OnMessageReceived(const IPC::Message& message) { |
| 128 // We don't swallow ViewMsg_CustomContextMenuAction because we listen for all | 131 // We don't swallow ViewMsg_CustomContextMenuAction because we listen for all |
| 129 // custom menu IDs, and not just our own. We don't swallow | 132 // custom menu IDs, and not just our own. We don't swallow |
| 130 // ViewMsg_LoadBlockedPlugins because multiple blocked plugins have an | 133 // ViewMsg_LoadBlockedPlugins because multiple blocked plugins have an |
| 131 // interest in it. | 134 // interest in it. |
| 132 if (message.type() == ViewMsg_CustomContextMenuAction::ID) { | 135 if (message.type() == ViewMsg_CustomContextMenuAction::ID && |
| 136 gLastActiveMenu == this) { |
| 133 ViewMsg_CustomContextMenuAction::Dispatch( | 137 ViewMsg_CustomContextMenuAction::Dispatch( |
| 134 &message, this, this, &BlockedPlugin::OnMenuItemSelected); | 138 &message, this, this, &BlockedPlugin::OnMenuItemSelected); |
| 135 } else if (message.type() == ViewMsg_LoadBlockedPlugins::ID) { | 139 } else if (message.type() == ViewMsg_LoadBlockedPlugins::ID) { |
| 136 LoadPlugin(); | 140 LoadPlugin(); |
| 137 } else if (message.type() == ViewMsg_DisplayPrerenderedPage::ID) { | 141 } else if (message.type() == ViewMsg_DisplayPrerenderedPage::ID) { |
| 138 if (is_blocked_for_prerendering_) | 142 if (is_blocked_for_prerendering_) |
| 139 LoadPlugin(); | 143 LoadPlugin(); |
| 140 } | 144 } |
| 141 | 145 |
| 142 return false; | 146 return false; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 if (element.hasAttribute("style")) { | 219 if (element.hasAttribute("style")) { |
| 216 WebString style_str = element.getAttribute("style"); | 220 WebString style_str = element.getAttribute("style"); |
| 217 if (width_regex.match(style_str) >= 0 && | 221 if (width_regex.match(style_str) >= 0 && |
| 218 height_regex.match(style_str) >= 0) | 222 height_regex.match(style_str) >= 0) |
| 219 element.setAttribute("style", "display: none;"); | 223 element.setAttribute("style", "display: none;"); |
| 220 } | 224 } |
| 221 } | 225 } |
| 222 } | 226 } |
| 223 } | 227 } |
| 224 | 228 |
| OLD | NEW |