| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 static const char* const kBlockedPluginDataURL = "chrome://blockedplugindata/"; | 42 static const char* const kBlockedPluginDataURL = "chrome://blockedplugindata/"; |
| 43 static const unsigned kMenuActionLoad = 1; | 43 static const unsigned kMenuActionLoad = 1; |
| 44 static const unsigned kMenuActionRemove = 2; | 44 static const unsigned kMenuActionRemove = 2; |
| 45 | 45 |
| 46 BlockedPlugin::BlockedPlugin(RenderView* render_view, | 46 BlockedPlugin::BlockedPlugin(RenderView* render_view, |
| 47 WebFrame* frame, | 47 WebFrame* frame, |
| 48 const webkit::npapi::PluginGroup& info, | 48 const webkit::npapi::PluginGroup& info, |
| 49 const WebPluginParams& params, | 49 const WebPluginParams& params, |
| 50 const WebPreferences& preferences, | 50 const WebPreferences& preferences, |
| 51 int template_id, | 51 int template_id, |
| 52 const string16& message) | 52 const string16& message, |
| 53 bool is_blocked_for_prerendering) |
| 53 : RenderViewObserver(render_view), | 54 : RenderViewObserver(render_view), |
| 54 frame_(frame), | 55 frame_(frame), |
| 55 plugin_params_(params), | 56 plugin_params_(params), |
| 56 custom_menu_showing_(false) { | 57 custom_menu_showing_(false), |
| 58 is_blocked_for_prerendering_(is_blocked_for_prerendering) { |
| 57 const base::StringPiece template_html( | 59 const base::StringPiece template_html( |
| 58 ResourceBundle::GetSharedInstance().GetRawDataResource(template_id)); | 60 ResourceBundle::GetSharedInstance().GetRawDataResource(template_id)); |
| 59 | 61 |
| 60 DCHECK(!template_html.empty()) << "unable to load template. ID: " | 62 DCHECK(!template_html.empty()) << "unable to load template. ID: " |
| 61 << template_id; | 63 << template_id; |
| 62 | 64 |
| 63 DictionaryValue values; | 65 DictionaryValue values; |
| 64 values.SetString("message", message); | 66 values.SetString("message", message); |
| 65 name_ = info.GetGroupName(); | 67 name_ = info.GetGroupName(); |
| 66 values.SetString("name", name_); | 68 values.SetString("name", name_); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 if (custom_menu_showing_ && | 126 if (custom_menu_showing_ && |
| 125 message.type() == ViewMsg_CustomContextMenuAction::ID) { | 127 message.type() == ViewMsg_CustomContextMenuAction::ID) { |
| 126 ViewMsg_CustomContextMenuAction::Dispatch( | 128 ViewMsg_CustomContextMenuAction::Dispatch( |
| 127 &message, this, this, &BlockedPlugin::OnMenuItemSelected); | 129 &message, this, this, &BlockedPlugin::OnMenuItemSelected); |
| 128 return true; | 130 return true; |
| 129 } | 131 } |
| 130 | 132 |
| 131 // Don't want to swallow these messages. | 133 // Don't want to swallow these messages. |
| 132 if (message.type() == ViewMsg_LoadBlockedPlugins::ID) { | 134 if (message.type() == ViewMsg_LoadBlockedPlugins::ID) { |
| 133 LoadPlugin(); | 135 LoadPlugin(); |
| 136 } else if (message.type() == ViewMsg_DisplayPrerenderedPage::ID) { |
| 137 if (is_blocked_for_prerendering_) |
| 138 LoadPlugin(); |
| 134 } else if (message.type() == ViewMsg_ContextMenuClosed::ID) { | 139 } else if (message.type() == ViewMsg_ContextMenuClosed::ID) { |
| 135 custom_menu_showing_ = false; | 140 custom_menu_showing_ = false; |
| 136 } | 141 } |
| 137 | 142 |
| 138 return false; | 143 return false; |
| 139 } | 144 } |
| 140 | 145 |
| 141 void BlockedPlugin::OnMenuItemSelected(unsigned id) { | 146 void BlockedPlugin::OnMenuItemSelected(unsigned id) { |
| 142 if (id == kMenuActionLoad) { | 147 if (id == kMenuActionLoad) { |
| 143 LoadPlugin(); | 148 LoadPlugin(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 if (element.hasAttribute("style")) { | 210 if (element.hasAttribute("style")) { |
| 206 WebString style_str = element.getAttribute("style"); | 211 WebString style_str = element.getAttribute("style"); |
| 207 if (width_regex.match(style_str) >= 0 && | 212 if (width_regex.match(style_str) >= 0 && |
| 208 height_regex.match(style_str) >= 0) | 213 height_regex.match(style_str) >= 0) |
| 209 element.setAttribute("style", "display: none;"); | 214 element.setAttribute("style", "display: none;"); |
| 210 } | 215 } |
| 211 } | 216 } |
| 212 } | 217 } |
| 213 } | 218 } |
| 214 | 219 |
| OLD | NEW |