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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // TODO(cevans) - move these to a shared header file so that there are no | 49 // TODO(cevans) - move these to a shared header file so that there are no |
50 // collisions in the longer term. Currently, blocked_plugin.cc is the only | 50 // collisions in the longer term. Currently, blocked_plugin.cc is the only |
51 // user of custom menu commands (extension menu items have their own range). | 51 // user of custom menu commands (extension menu items have their own range). |
52 static const unsigned kMenuActionLoad = 1; | 52 static const unsigned kMenuActionLoad = 1; |
53 static const unsigned kMenuActionRemove = 2; | 53 static const unsigned kMenuActionRemove = 2; |
54 | 54 |
55 static const BlockedPlugin* g_last_active_menu; | 55 static const BlockedPlugin* g_last_active_menu; |
56 | 56 |
57 BlockedPlugin::BlockedPlugin(RenderView* render_view, | 57 BlockedPlugin::BlockedPlugin(RenderView* render_view, |
58 WebFrame* frame, | 58 WebFrame* frame, |
59 const webkit::npapi::PluginGroup& info, | |
60 const WebPluginParams& params, | 59 const WebPluginParams& params, |
61 const WebPreferences& preferences, | 60 const WebPreferences& preferences, |
62 int template_id, | 61 int template_id, |
| 62 const string16& name, |
63 const string16& message, | 63 const string16& message, |
64 bool is_blocked_for_prerendering, | 64 bool is_blocked_for_prerendering, |
65 bool allow_loading) | 65 bool allow_loading) |
66 : RenderViewObserver(render_view), | 66 : RenderViewObserver(render_view), |
67 frame_(frame), | 67 frame_(frame), |
68 plugin_params_(params), | 68 plugin_params_(params), |
| 69 name_(name), |
69 is_blocked_for_prerendering_(is_blocked_for_prerendering), | 70 is_blocked_for_prerendering_(is_blocked_for_prerendering), |
70 hidden_(false), | 71 hidden_(false), |
71 allow_loading_(allow_loading) { | 72 allow_loading_(allow_loading) { |
72 const base::StringPiece template_html( | 73 const base::StringPiece template_html( |
73 ResourceBundle::GetSharedInstance().GetRawDataResource(template_id)); | 74 ResourceBundle::GetSharedInstance().GetRawDataResource(template_id)); |
74 | 75 |
75 DCHECK(!template_html.empty()) << "unable to load template. ID: " | 76 DCHECK(!template_html.empty()) << "unable to load template. ID: " |
76 << template_id; | 77 << template_id; |
77 | 78 |
78 DictionaryValue values; | 79 DictionaryValue values; |
79 values.SetString("message", message); | 80 values.SetString("message", message); |
80 name_ = info.GetGroupName(); | |
81 values.SetString("name", name_); | 81 values.SetString("name", name_); |
82 values.SetString("hide", l10n_util::GetStringUTF8(IDS_PLUGIN_HIDE)); | 82 values.SetString("hide", l10n_util::GetStringUTF8(IDS_PLUGIN_HIDE)); |
83 | 83 |
84 // "t" is the id of the templates root node. | 84 // "t" is the id of the templates root node. |
85 std::string html_data = jstemplate_builder::GetTemplatesHtml( | 85 std::string html_data = jstemplate_builder::GetTemplatesHtml( |
86 template_html, &values, "t"); | 86 template_html, &values, "t"); |
87 | 87 |
88 plugin_ = webkit::npapi::WebViewPlugin::Create(this, | 88 plugin_ = webkit::npapi::WebViewPlugin::Create(this, |
89 preferences, | 89 preferences, |
90 html_data, | 90 html_data, |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 element = parent.toConst<WebElement>(); | 259 element = parent.toConst<WebElement>(); |
260 if (element.hasAttribute("style")) { | 260 if (element.hasAttribute("style")) { |
261 WebString style_str = element.getAttribute("style"); | 261 WebString style_str = element.getAttribute("style"); |
262 if (width_regex.match(style_str) >= 0 && | 262 if (width_regex.match(style_str) >= 0 && |
263 height_regex.match(style_str) >= 0) | 263 height_regex.match(style_str) >= 0) |
264 element.setAttribute("style", "display: none;"); | 264 element.setAttribute("style", "display: none;"); |
265 } | 265 } |
266 } | 266 } |
267 } | 267 } |
268 } | 268 } |
OLD | NEW |