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

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

Issue 5275007: Add the ability to remove blocked plugin containers from the page. For now,... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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
« no previous file with comments | « chrome/renderer/blocked_plugin.h ('k') | chrome/renderer/resources/blocked_plugin.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/string_piece.h" 9 #include "base/string_piece.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 76 }
77 77
78 BlockedPlugin::~BlockedPlugin() { 78 BlockedPlugin::~BlockedPlugin() {
79 render_view_->CustomMenuListenerDestroyed(this); 79 render_view_->CustomMenuListenerDestroyed(this);
80 render_view_->UnregisterBlockedPlugin(this); 80 render_view_->UnregisterBlockedPlugin(this);
81 } 81 }
82 82
83 void BlockedPlugin::BindWebFrame(WebFrame* frame) { 83 void BlockedPlugin::BindWebFrame(WebFrame* frame) {
84 BindToJavascript(frame, "plugin"); 84 BindToJavascript(frame, "plugin");
85 BindMethod("load", &BlockedPlugin::Load); 85 BindMethod("load", &BlockedPlugin::Load);
86 BindMethod("hide", &BlockedPlugin::Hide);
86 } 87 }
87 88
88 void BlockedPlugin::WillDestroyPlugin() { 89 void BlockedPlugin::WillDestroyPlugin() {
89 delete this; 90 delete this;
90 } 91 }
91 92
92 void BlockedPlugin::ShowContextMenu(const WebKit::WebMouseEvent& event) { 93 void BlockedPlugin::ShowContextMenu(const WebKit::WebMouseEvent& event) {
93 WebContextMenuData menu_data; 94 WebContextMenuData menu_data;
94 WebVector<WebMenuItemInfo> custom_items(static_cast<size_t>(4)); 95 WebVector<WebMenuItemInfo> custom_items(static_cast<size_t>(4));
95 96
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 container->reportGeometry(); 144 container->reportGeometry();
144 plugin_->ReplayReceivedData(new_plugin); 145 plugin_->ReplayReceivedData(new_plugin);
145 plugin_->destroy(); 146 plugin_->destroy();
146 } 147 }
147 } 148 }
148 149
149 void BlockedPlugin::Load(const CppArgumentList& args, CppVariant* result) { 150 void BlockedPlugin::Load(const CppArgumentList& args, CppVariant* result) {
150 LoadPlugin(); 151 LoadPlugin();
151 } 152 }
152 153
154 void BlockedPlugin::Hide(const CppArgumentList& args, CppVariant* result) {
155 HidePlugin();
156 }
157
153 void BlockedPlugin::HidePlugin() { 158 void BlockedPlugin::HidePlugin() {
154 CHECK(plugin_); 159 CHECK(plugin_);
155 WebPluginContainer* container = plugin_->container(); 160 WebPluginContainer* container = plugin_->container();
156 WebElement element = container->element(); 161 WebElement element = container->element();
157 element.setAttribute("style", "display: none;"); 162 element.setAttribute("style", "display: none;");
158 // If we have a width and height, search for a parent (often <div>) with the 163 // If we have a width and height, search for a parent (often <div>) with the
159 // same dimensions. If we find such a parent, hide that as well. 164 // same dimensions. If we find such a parent, hide that as well.
160 // This makes much more uncovered page content usable (including clickable) 165 // This makes much more uncovered page content usable (including clickable)
161 // as opposed to merely visible. 166 // as opposed to merely visible.
162 // TODO(cevans) -- it's a foul heurisitc but we're going to tolerate it for 167 // TODO(cevans) -- it's a foul heurisitc but we're going to tolerate it for
(...skipping 22 matching lines...) Expand all
185 if (element.hasAttribute("style")) { 190 if (element.hasAttribute("style")) {
186 WebString style_str = element.getAttribute("style"); 191 WebString style_str = element.getAttribute("style");
187 if (width_regex.match(style_str) >= 0 && 192 if (width_regex.match(style_str) >= 0 &&
188 height_regex.match(style_str) >= 0) 193 height_regex.match(style_str) >= 0)
189 element.setAttribute("style", "display: none;"); 194 element.setAttribute("style", "display: none;");
190 } 195 }
191 } 196 }
192 } 197 }
193 } 198 }
194 199
OLDNEW
« no previous file with comments | « chrome/renderer/blocked_plugin.h ('k') | chrome/renderer/resources/blocked_plugin.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698