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

Side by Side Diff: chrome/renderer/blocked_plugin.cc

Issue 7768001: Add support for exporting IPC messages from component DLLs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/string_piece.h" 7 #include "base/string_piece.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/common/jstemplate_builder.h" 10 #include "chrome/common/jstemplate_builder.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 using WebKit::WebString; 44 using WebKit::WebString;
45 using WebKit::WebVector; 45 using WebKit::WebVector;
46 46
47 static const char* const kBlockedPluginDataURL = "chrome://blockedplugindata/"; 47 static const char* const kBlockedPluginDataURL = "chrome://blockedplugindata/";
48 // TODO(cevans) - move these to a shared header file so that there are no 48 // TODO(cevans) - move these to a shared header file so that there are no
49 // collisions in the longer term. Currently, blocked_plugin.cc is the only 49 // collisions in the longer term. Currently, blocked_plugin.cc is the only
50 // user of custom menu commands (extension menu items have their own range). 50 // user of custom menu commands (extension menu items have their own range).
51 static const unsigned kMenuActionLoad = 1; 51 static const unsigned kMenuActionLoad = 1;
52 static const unsigned kMenuActionRemove = 2; 52 static const unsigned kMenuActionRemove = 2;
53 53
54 static const BlockedPlugin* gLastActiveMenu; 54 static const BlockedPlugin* g_last_active_menu;
55 55
56 BlockedPlugin::BlockedPlugin(RenderView* render_view, 56 BlockedPlugin::BlockedPlugin(RenderView* render_view,
57 WebFrame* frame, 57 WebFrame* frame,
58 const webkit::npapi::PluginGroup& info, 58 const webkit::npapi::PluginGroup& info,
59 const WebPluginParams& params, 59 const WebPluginParams& params,
60 const WebPreferences& preferences, 60 const WebPreferences& preferences,
61 int template_id, 61 int template_id,
62 const string16& message, 62 const string16& message,
63 bool is_blocked_for_prerendering, 63 bool is_blocked_for_prerendering,
64 bool allow_loading) 64 bool allow_loading)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 hide_item.enabled = true; 132 hide_item.enabled = true;
133 hide_item.label = WebString::fromUTF8( 133 hide_item.label = WebString::fromUTF8(
134 l10n_util::GetStringUTF8(IDS_CONTENT_CONTEXT_PLUGIN_HIDE).c_str()); 134 l10n_util::GetStringUTF8(IDS_CONTENT_CONTEXT_PLUGIN_HIDE).c_str());
135 hide_item.hasTextDirectionOverride = false; 135 hide_item.hasTextDirectionOverride = false;
136 hide_item.textDirection = WebKit::WebTextDirectionDefault; 136 hide_item.textDirection = WebKit::WebTextDirectionDefault;
137 custom_items[3] = hide_item; 137 custom_items[3] = hide_item;
138 138
139 menu_data.customItems.swap(custom_items); 139 menu_data.customItems.swap(custom_items);
140 menu_data.mousePosition = WebPoint(event.windowX, event.windowY); 140 menu_data.mousePosition = WebPoint(event.windowX, event.windowY);
141 render_view()->showContextMenu(NULL, menu_data); 141 render_view()->showContextMenu(NULL, menu_data);
142 gLastActiveMenu = this; 142 g_last_active_menu = this;
143 } 143 }
144 144
145 bool BlockedPlugin::OnMessageReceived(const IPC::Message& message) { 145 bool BlockedPlugin::OnMessageReceived(const IPC::Message& message) {
146 // We don't swallow ViewMsg_CustomContextMenuAction because we listen for all 146 // We don't swallow ViewMsg_CustomContextMenuAction because we listen for all
147 // custom menu IDs, and not just our own. We don't swallow 147 // custom menu IDs, and not just our own. We don't swallow
148 // ViewMsg_LoadBlockedPlugins because multiple blocked plugins have an 148 // ViewMsg_LoadBlockedPlugins because multiple blocked plugins have an
149 // interest in it. 149 // interest in it.
150 if (message.type() == ViewMsg_CustomContextMenuAction::ID && 150 IPC_BEGIN_MESSAGE_MAP(BlockedPlugin, message)
151 gLastActiveMenu == this) { 151 IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction, OnMenuItemSelected)
152 ViewMsg_CustomContextMenuAction::Dispatch( 152 IPC_MESSAGE_HANDLER(ChromeViewMsg_LoadBlockedPlugins, OnLoadBlockedPlugins)
153 &message, this, this, &BlockedPlugin::OnMenuItemSelected); 153 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetIsPrerendering, OnSetIsPrerendering)
154 } else { 154 IPC_END_MESSAGE_MAP()
155 IPC_BEGIN_MESSAGE_MAP(BlockedPlugin, message)
156 IPC_MESSAGE_HANDLER(ChromeViewMsg_LoadBlockedPlugins,
157 OnLoadBlockedPlugins)
158 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetIsPrerendering, OnSetIsPrerendering)
159 IPC_END_MESSAGE_MAP()
160 }
161 155
162 return false; 156 return false;
163 } 157 }
164 158
165 void BlockedPlugin::OnMenuItemSelected( 159 void BlockedPlugin::OnMenuItemSelected(
166 const webkit_glue::CustomContextMenuContext& /* ignored */, 160 const webkit_glue::CustomContextMenuContext& /* ignored */,
167 unsigned id) { 161 unsigned id) {
162 if (g_last_active_menu != this)
163 return;
168 if (id == kMenuActionLoad) { 164 if (id == kMenuActionLoad) {
169 Send(new ViewHostMsg_UserMetricsRecordAction("Plugin_Load_Menu")); 165 Send(new ViewHostMsg_UserMetricsRecordAction("Plugin_Load_Menu"));
170 LoadPlugin(); 166 LoadPlugin();
171 } else if (id == kMenuActionRemove) { 167 } else if (id == kMenuActionRemove) {
172 Send(new ViewHostMsg_UserMetricsRecordAction("Plugin_Hide_Menu")); 168 Send(new ViewHostMsg_UserMetricsRecordAction("Plugin_Hide_Menu"));
173 HidePlugin(); 169 HidePlugin();
174 } 170 }
175 } 171 }
176 172
177 void BlockedPlugin::OnLoadBlockedPlugins() { 173 void BlockedPlugin::OnLoadBlockedPlugins() {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 element = parent.toConst<WebElement>(); 261 element = parent.toConst<WebElement>();
266 if (element.hasAttribute("style")) { 262 if (element.hasAttribute("style")) {
267 WebString style_str = element.getAttribute("style"); 263 WebString style_str = element.getAttribute("style");
268 if (width_regex.match(style_str) >= 0 && 264 if (width_regex.match(style_str) >= 0 &&
269 height_regex.match(style_str) >= 0) 265 height_regex.match(style_str) >= 0)
270 element.setAttribute("style", "display: none;"); 266 element.setAttribute("style", "display: none;");
271 } 267 }
272 } 268 }
273 } 269 }
274 } 270 }
OLDNEW
« no previous file with comments | « chrome/common/render_messages.h ('k') | content/browser/renderer_host/p2p/socket_host_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698