| OLD | NEW |
| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 IPC_END_MESSAGE_MAP() | 158 IPC_END_MESSAGE_MAP() |
| 159 } | 159 } |
| 160 | 160 |
| 161 return false; | 161 return false; |
| 162 } | 162 } |
| 163 | 163 |
| 164 void BlockedPlugin::OnMenuItemSelected( | 164 void BlockedPlugin::OnMenuItemSelected( |
| 165 const webkit_glue::CustomContextMenuContext& /* ignored */, | 165 const webkit_glue::CustomContextMenuContext& /* ignored */, |
| 166 unsigned id) { | 166 unsigned id) { |
| 167 if (id == kMenuActionLoad) { | 167 if (id == kMenuActionLoad) { |
| 168 Send(new ViewHostMsg_UserMetricsRecordAction("Plugin_Load_Menu")); |
| 168 LoadPlugin(); | 169 LoadPlugin(); |
| 169 } else if (id == kMenuActionRemove) { | 170 } else if (id == kMenuActionRemove) { |
| 171 Send(new ViewHostMsg_UserMetricsRecordAction("Plugin_Hide_Menu")); |
| 170 HidePlugin(); | 172 HidePlugin(); |
| 171 } | 173 } |
| 172 } | 174 } |
| 173 | 175 |
| 174 void BlockedPlugin::OnLoadBlockedPlugins() { | 176 void BlockedPlugin::OnLoadBlockedPlugins() { |
| 177 Send(new ViewHostMsg_UserMetricsRecordAction("Plugin_Load_UI")); |
| 175 LoadPlugin(); | 178 LoadPlugin(); |
| 176 } | 179 } |
| 177 | 180 |
| 178 void BlockedPlugin::OnSetIsPrerendering(bool is_prerendering) { | 181 void BlockedPlugin::OnSetIsPrerendering(bool is_prerendering) { |
| 179 // Prerendering can only be enabled prior to a RenderView's first navigation, | 182 // Prerendering can only be enabled prior to a RenderView's first navigation, |
| 180 // so no BlockedPlugin should see the notification that enables prerendering. | 183 // so no BlockedPlugin should see the notification that enables prerendering. |
| 181 DCHECK(!is_prerendering); | 184 DCHECK(!is_prerendering); |
| 182 if (is_blocked_for_prerendering_ && !is_prerendering) | 185 if (is_blocked_for_prerendering_ && !is_prerendering) |
| 183 LoadPlugin(); | 186 LoadPlugin(); |
| 184 } | 187 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 202 plugin_->ReplayReceivedData(new_plugin); | 205 plugin_->ReplayReceivedData(new_plugin); |
| 203 plugin_->destroy(); | 206 plugin_->destroy(); |
| 204 } else { | 207 } else { |
| 205 MissingPluginReporter::GetInstance()->ReportPluginMissing( | 208 MissingPluginReporter::GetInstance()->ReportPluginMissing( |
| 206 plugin_params_.mimeType.utf8(), | 209 plugin_params_.mimeType.utf8(), |
| 207 plugin_params_.url); | 210 plugin_params_.url); |
| 208 } | 211 } |
| 209 } | 212 } |
| 210 | 213 |
| 211 void BlockedPlugin::Load(const CppArgumentList& args, CppVariant* result) { | 214 void BlockedPlugin::Load(const CppArgumentList& args, CppVariant* result) { |
| 215 Send(new ViewHostMsg_UserMetricsRecordAction("Plugin_Load_Click")); |
| 212 LoadPlugin(); | 216 LoadPlugin(); |
| 213 } | 217 } |
| 214 | 218 |
| 215 void BlockedPlugin::Hide(const CppArgumentList& args, CppVariant* result) { | 219 void BlockedPlugin::Hide(const CppArgumentList& args, CppVariant* result) { |
| 220 Send(new ViewHostMsg_UserMetricsRecordAction("Plugin_Hide_Click")); |
| 216 HidePlugin(); | 221 HidePlugin(); |
| 217 } | 222 } |
| 218 | 223 |
| 219 void BlockedPlugin::HidePlugin() { | 224 void BlockedPlugin::HidePlugin() { |
| 220 CHECK(plugin_); | 225 CHECK(plugin_); |
| 221 hidden_ = true; | 226 hidden_ = true; |
| 222 WebPluginContainer* container = plugin_->container(); | 227 WebPluginContainer* container = plugin_->container(); |
| 223 WebElement element = container->element(); | 228 WebElement element = container->element(); |
| 224 element.setAttribute("style", "display: none;"); | 229 element.setAttribute("style", "display: none;"); |
| 225 // If we have a width and height, search for a parent (often <div>) with the | 230 // If we have a width and height, search for a parent (often <div>) with the |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 element = parent.toConst<WebElement>(); | 264 element = parent.toConst<WebElement>(); |
| 260 if (element.hasAttribute("style")) { | 265 if (element.hasAttribute("style")) { |
| 261 WebString style_str = element.getAttribute("style"); | 266 WebString style_str = element.getAttribute("style"); |
| 262 if (width_regex.match(style_str) >= 0 && | 267 if (width_regex.match(style_str) >= 0 && |
| 263 height_regex.match(style_str) >= 0) | 268 height_regex.match(style_str) >= 0) |
| 264 element.setAttribute("style", "display: none;"); | 269 element.setAttribute("style", "display: none;"); |
| 265 } | 270 } |
| 266 } | 271 } |
| 267 } | 272 } |
| 268 } | 273 } |
| OLD | NEW |