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 "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 Loading... |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |