OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/plugins/renderer/loadable_plugin_placeholder.h" | 5 #include "components/plugins/renderer/loadable_plugin_placeholder.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/json/string_escape.h" | 10 #include "base/json/string_escape.h" |
11 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
12 #include "base/strings/string_util.h" | |
13 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
14 #include "base/values.h" | 13 #include "base/values.h" |
15 #include "content/public/child/v8_value_converter.h" | 14 #include "content/public/child/v8_value_converter.h" |
16 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.h" |
17 #include "content/public/renderer/render_frame.h" | 16 #include "content/public/renderer/render_frame.h" |
18 #include "content/public/renderer/render_thread.h" | 17 #include "content/public/renderer/render_thread.h" |
19 #include "gin/handle.h" | 18 #include "gin/handle.h" |
20 #include "gin/object_template_builder.h" | 19 #include "gin/object_template_builder.h" |
21 #include "third_party/WebKit/public/web/WebDOMMessageEvent.h" | 20 #include "third_party/WebKit/public/web/WebDOMMessageEvent.h" |
22 #include "third_party/WebKit/public/web/WebDocument.h" | 21 #include "third_party/WebKit/public/web/WebDocument.h" |
23 #include "third_party/WebKit/public/web/WebElement.h" | 22 #include "third_party/WebKit/public/web/WebElement.h" |
24 #include "third_party/WebKit/public/web/WebInputEvent.h" | 23 #include "third_party/WebKit/public/web/WebInputEvent.h" |
25 #include "third_party/WebKit/public/web/WebKit.h" | 24 #include "third_party/WebKit/public/web/WebKit.h" |
26 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 25 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
27 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 26 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
28 #include "third_party/WebKit/public/web/WebScriptSource.h" | 27 #include "third_party/WebKit/public/web/WebScriptSource.h" |
29 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" | 28 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" |
30 #include "third_party/WebKit/public/web/WebView.h" | 29 #include "third_party/WebKit/public/web/WebView.h" |
31 #include "third_party/re2/re2/re2.h" | |
32 | 30 |
33 using base::UserMetricsAction; | 31 using base::UserMetricsAction; |
34 using blink::WebElement; | |
35 using blink::WebLocalFrame; | |
36 using blink::WebMouseEvent; | |
37 using blink::WebNode; | |
38 using blink::WebPlugin; | |
39 using blink::WebPluginContainer; | |
40 using blink::WebPluginParams; | |
41 using blink::WebScriptSource; | |
42 using blink::WebURLRequest; | |
43 using content::PluginInstanceThrottler; | 32 using content::PluginInstanceThrottler; |
44 using content::RenderThread; | 33 using content::RenderThread; |
45 | 34 |
46 namespace plugins { | 35 namespace plugins { |
47 | 36 |
48 #if defined(ENABLE_PLUGINS) | |
49 void LoadablePluginPlaceholder::BlockForPowerSaverPoster() { | 37 void LoadablePluginPlaceholder::BlockForPowerSaverPoster() { |
50 DCHECK(!is_blocked_for_power_saver_poster_); | 38 DCHECK(!is_blocked_for_power_saver_poster_); |
51 is_blocked_for_power_saver_poster_ = true; | 39 is_blocked_for_power_saver_poster_ = true; |
52 | 40 |
53 render_frame()->RegisterPeripheralPlugin( | 41 render_frame()->RegisterPeripheralPlugin( |
54 GURL(GetPluginParams().url).GetOrigin(), | 42 GURL(GetPluginParams().url).GetOrigin(), |
55 base::Bind(&LoadablePluginPlaceholder::MarkPluginEssential, | 43 base::Bind(&LoadablePluginPlaceholder::MarkPluginEssential, |
56 weak_factory_.GetWeakPtr(), | 44 weak_factory_.GetWeakPtr(), |
57 PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_WHITELIST)); | 45 PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_WHITELIST)); |
58 } | 46 } |
59 | 47 |
60 void LoadablePluginPlaceholder::SetPremadePlugin( | 48 void LoadablePluginPlaceholder::SetPremadePlugin( |
61 content::PluginInstanceThrottler* throttler) { | 49 content::PluginInstanceThrottler* throttler) { |
62 DCHECK(throttler); | 50 DCHECK(throttler); |
63 DCHECK(!premade_throttler_); | 51 DCHECK(!premade_throttler_); |
64 premade_throttler_ = throttler; | 52 premade_throttler_ = throttler; |
65 } | 53 } |
66 #endif | |
67 | 54 |
68 LoadablePluginPlaceholder::LoadablePluginPlaceholder( | 55 LoadablePluginPlaceholder::LoadablePluginPlaceholder( |
69 content::RenderFrame* render_frame, | 56 content::RenderFrame* render_frame, |
70 WebLocalFrame* frame, | 57 blink::WebLocalFrame* frame, |
71 const WebPluginParams& params, | 58 const blink::WebPluginParams& params, |
72 const std::string& html_data, | 59 const std::string& html_data) |
73 GURL placeholderDataUrl) | 60 : PluginPlaceholder(render_frame, frame, params, html_data), |
74 : PluginPlaceholder(render_frame, | |
75 frame, | |
76 params, | |
77 html_data, | |
78 placeholderDataUrl), | |
79 is_blocked_for_background_tab_(false), | 61 is_blocked_for_background_tab_(false), |
80 is_blocked_for_prerendering_(false), | 62 is_blocked_for_prerendering_(false), |
81 is_blocked_for_power_saver_poster_(false), | 63 is_blocked_for_power_saver_poster_(false), |
82 power_saver_enabled_(false), | 64 power_saver_enabled_(false), |
83 premade_throttler_(nullptr), | 65 premade_throttler_(nullptr), |
84 allow_loading_(false), | 66 allow_loading_(true), |
85 hidden_(false), | |
86 finished_loading_(false), | 67 finished_loading_(false), |
87 weak_factory_(this) { | 68 weak_factory_(this) { |
88 } | 69 } |
89 | 70 |
90 LoadablePluginPlaceholder::~LoadablePluginPlaceholder() { | 71 LoadablePluginPlaceholder::~LoadablePluginPlaceholder() { |
91 } | 72 } |
92 | 73 |
93 #if defined(ENABLE_PLUGINS) | |
94 void LoadablePluginPlaceholder::MarkPluginEssential( | 74 void LoadablePluginPlaceholder::MarkPluginEssential( |
95 PluginInstanceThrottler::PowerSaverUnthrottleMethod method) { | 75 PluginInstanceThrottler::PowerSaverUnthrottleMethod method) { |
96 if (!power_saver_enabled_) | 76 if (!power_saver_enabled_) |
97 return; | 77 return; |
98 | 78 |
99 power_saver_enabled_ = false; | 79 power_saver_enabled_ = false; |
100 | 80 |
101 if (premade_throttler_) | 81 if (premade_throttler_) |
102 premade_throttler_->MarkPluginEssential(method); | 82 premade_throttler_->MarkPluginEssential(method); |
103 else | 83 else |
104 PluginInstanceThrottler::RecordUnthrottleMethodMetric(method); | 84 PluginInstanceThrottler::RecordUnthrottleMethodMetric(method); |
105 | 85 |
106 if (is_blocked_for_power_saver_poster_) { | 86 if (is_blocked_for_power_saver_poster_) { |
107 is_blocked_for_power_saver_poster_ = false; | 87 is_blocked_for_power_saver_poster_ = false; |
108 if (!LoadingBlocked()) | 88 if (!LoadingBlocked()) |
109 LoadPlugin(); | 89 LoadPlugin(); |
110 } | 90 } |
111 } | 91 } |
112 #endif | |
113 | |
114 void LoadablePluginPlaceholder::BindWebFrame(blink::WebFrame* frame) { | |
115 v8::Isolate* isolate = blink::mainThreadIsolate(); | |
116 v8::HandleScope handle_scope(isolate); | |
117 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); | |
118 DCHECK(!context.IsEmpty()); | |
119 | |
120 v8::Context::Scope context_scope(context); | |
121 v8::Local<v8::Object> global = context->Global(); | |
122 global->Set(gin::StringToV8(isolate, "plugin"), | |
123 gin::CreateHandle(isolate, this).ToV8()); | |
124 } | |
125 | 92 |
126 gin::ObjectTemplateBuilder LoadablePluginPlaceholder::GetObjectTemplateBuilder( | 93 gin::ObjectTemplateBuilder LoadablePluginPlaceholder::GetObjectTemplateBuilder( |
127 v8::Isolate* isolate) { | 94 v8::Isolate* isolate) { |
128 return gin::Wrappable<PluginPlaceholder>::GetObjectTemplateBuilder(isolate) | 95 return PluginPlaceholder::GetObjectTemplateBuilder(isolate) |
129 .SetMethod("load", &LoadablePluginPlaceholder::LoadCallback) | 96 .SetMethod("load", &LoadablePluginPlaceholder::LoadCallback) |
130 .SetMethod("hide", &LoadablePluginPlaceholder::HideCallback) | |
131 .SetMethod("didFinishLoading", | 97 .SetMethod("didFinishLoading", |
132 &LoadablePluginPlaceholder::DidFinishLoadingCallback); | 98 &LoadablePluginPlaceholder::DidFinishLoadingCallback); |
133 } | 99 } |
134 | 100 |
135 void LoadablePluginPlaceholder::ReplacePlugin(WebPlugin* new_plugin) { | 101 void LoadablePluginPlaceholder::ReplacePlugin(blink::WebPlugin* new_plugin) { |
136 CHECK(plugin()); | 102 CHECK(plugin()); |
137 if (!new_plugin) | 103 if (!new_plugin) |
138 return; | 104 return; |
139 WebPluginContainer* container = plugin()->container(); | 105 blink::WebPluginContainer* container = plugin()->container(); |
140 // Set the new plugin on the container before initializing it. | 106 // Set the new plugin on the container before initializing it. |
141 container->setPlugin(new_plugin); | 107 container->setPlugin(new_plugin); |
142 // Save the element in case the plugin is removed from the page during | 108 // Save the element in case the plugin is removed from the page during |
143 // initialization. | 109 // initialization. |
144 WebElement element = container->element(); | 110 blink::WebElement element = container->element(); |
145 bool plugin_needs_initialization = | 111 bool plugin_needs_initialization = |
146 !premade_throttler_ || new_plugin != premade_throttler_->GetWebPlugin(); | 112 !premade_throttler_ || new_plugin != premade_throttler_->GetWebPlugin(); |
147 if (plugin_needs_initialization && !new_plugin->initialize(container)) { | 113 if (plugin_needs_initialization && !new_plugin->initialize(container)) { |
148 // We couldn't initialize the new plugin. Restore the old one and abort. | 114 // We couldn't initialize the new plugin. Restore the old one and abort. |
149 container->setPlugin(plugin()); | 115 container->setPlugin(plugin()); |
150 return; | 116 return; |
151 } | 117 } |
152 | 118 |
153 // The plugin has been removed from the page. Destroy the old plugin. We | 119 // The plugin has been removed from the page. Destroy the old plugin. We |
154 // will be destroyed as soon as V8 garbage collects us. | 120 // will be destroyed as soon as V8 garbage collects us. |
155 if (!element.pluginContainer()) { | 121 if (!element.pluginContainer()) { |
156 plugin()->destroy(); | 122 plugin()->destroy(); |
157 return; | 123 return; |
158 } | 124 } |
159 | 125 |
160 // During initialization, the new plugin might have replaced itself in turn | 126 // During initialization, the new plugin might have replaced itself in turn |
161 // with another plugin. Make sure not to use the passed in |new_plugin| after | 127 // with another plugin. Make sure not to use the passed in |new_plugin| after |
162 // this point. | 128 // this point. |
163 new_plugin = container->plugin(); | 129 new_plugin = container->plugin(); |
164 | 130 |
165 plugin()->RestoreTitleText(); | 131 plugin()->RestoreTitleText(); |
166 container->invalidate(); | 132 container->invalidate(); |
167 container->reportGeometry(); | 133 container->reportGeometry(); |
168 plugin()->ReplayReceivedData(new_plugin); | 134 plugin()->ReplayReceivedData(new_plugin); |
169 plugin()->destroy(); | 135 plugin()->destroy(); |
170 } | 136 } |
171 | 137 |
172 void LoadablePluginPlaceholder::HidePlugin() { | |
173 hidden_ = true; | |
174 if (!plugin()) | |
175 return; | |
176 WebPluginContainer* container = plugin()->container(); | |
177 WebElement element = container->element(); | |
178 element.setAttribute("style", "display: none;"); | |
179 // If we have a width and height, search for a parent (often <div>) with the | |
180 // same dimensions. If we find such a parent, hide that as well. | |
181 // This makes much more uncovered page content usable (including clickable) | |
182 // as opposed to merely visible. | |
183 // TODO(cevans) -- it's a foul heuristic but we're going to tolerate it for | |
184 // now for these reasons: | |
185 // 1) Makes the user experience better. | |
186 // 2) Foulness is encapsulated within this single function. | |
187 // 3) Confidence in no fasle positives. | |
188 // 4) Seems to have a good / low false negative rate at this time. | |
189 if (element.hasAttribute("width") && element.hasAttribute("height")) { | |
190 std::string width_str("width:[\\s]*"); | |
191 width_str += element.getAttribute("width").utf8().data(); | |
192 if (EndsWith(width_str, "px", false)) { | |
193 width_str = width_str.substr(0, width_str.length() - 2); | |
194 } | |
195 base::TrimWhitespace(width_str, base::TRIM_TRAILING, &width_str); | |
196 width_str += "[\\s]*px"; | |
197 std::string height_str("height:[\\s]*"); | |
198 height_str += element.getAttribute("height").utf8().data(); | |
199 if (EndsWith(height_str, "px", false)) { | |
200 height_str = height_str.substr(0, height_str.length() - 2); | |
201 } | |
202 base::TrimWhitespace(height_str, base::TRIM_TRAILING, &height_str); | |
203 height_str += "[\\s]*px"; | |
204 WebNode parent = element; | |
205 while (!parent.parentNode().isNull()) { | |
206 parent = parent.parentNode(); | |
207 if (!parent.isElementNode()) | |
208 continue; | |
209 element = parent.toConst<WebElement>(); | |
210 if (element.hasAttribute("style")) { | |
211 std::string style_str = element.getAttribute("style").utf8(); | |
212 if (RE2::PartialMatch(style_str, width_str) && | |
213 RE2::PartialMatch(style_str, height_str)) | |
214 element.setAttribute("style", "display: none;"); | |
215 } | |
216 } | |
217 } | |
218 } | |
219 | |
220 void LoadablePluginPlaceholder::SetMessage(const base::string16& message) { | 138 void LoadablePluginPlaceholder::SetMessage(const base::string16& message) { |
221 message_ = message; | 139 message_ = message; |
222 if (finished_loading_) | 140 if (finished_loading_) |
223 UpdateMessage(); | 141 UpdateMessage(); |
224 } | 142 } |
225 | 143 |
226 void LoadablePluginPlaceholder::UpdateMessage() { | 144 void LoadablePluginPlaceholder::UpdateMessage() { |
227 if (!plugin()) | 145 if (!plugin()) |
228 return; | 146 return; |
229 std::string script = | 147 std::string script = |
230 "window.setMessage(" + base::GetQuotedJSONString(message_) + ")"; | 148 "window.setMessage(" + base::GetQuotedJSONString(message_) + ")"; |
231 plugin()->web_view()->mainFrame()->executeScript( | 149 plugin()->web_view()->mainFrame()->executeScript( |
232 WebScriptSource(base::UTF8ToUTF16(script))); | 150 blink::WebScriptSource(base::UTF8ToUTF16(script))); |
233 } | 151 } |
234 | 152 |
235 void LoadablePluginPlaceholder::PluginDestroyed() { | 153 void LoadablePluginPlaceholder::PluginDestroyed() { |
236 #if defined(ENABLE_PLUGINS) | |
237 if (power_saver_enabled_) { | 154 if (power_saver_enabled_) { |
238 if (premade_throttler_) { | 155 if (premade_throttler_) { |
239 // Since the premade plugin has been detached from the container, it will | 156 // Since the premade plugin has been detached from the container, it will |
240 // not be automatically destroyed along with the page. | 157 // not be automatically destroyed along with the page. |
241 premade_throttler_->GetWebPlugin()->destroy(); | 158 premade_throttler_->GetWebPlugin()->destroy(); |
242 premade_throttler_ = nullptr; | 159 premade_throttler_ = nullptr; |
243 } else if (is_blocked_for_power_saver_poster_) { | 160 } else if (is_blocked_for_power_saver_poster_) { |
244 // Record the NEVER unthrottle count only if there is no throttler. | 161 // Record the NEVER unthrottle count only if there is no throttler. |
245 PluginInstanceThrottler::RecordUnthrottleMethodMetric( | 162 PluginInstanceThrottler::RecordUnthrottleMethodMetric( |
246 PluginInstanceThrottler::UNTHROTTLE_METHOD_NEVER); | 163 PluginInstanceThrottler::UNTHROTTLE_METHOD_NEVER); |
247 } | 164 } |
248 | 165 |
249 // Prevent processing subsequent calls to MarkPluginEssential. | 166 // Prevent processing subsequent calls to MarkPluginEssential. |
250 power_saver_enabled_ = false; | 167 power_saver_enabled_ = false; |
251 } | 168 } |
252 #endif | |
253 | 169 |
254 PluginPlaceholder::PluginDestroyed(); | 170 PluginPlaceholder::PluginDestroyed(); |
255 } | 171 } |
256 | 172 |
257 v8::Local<v8::Object> LoadablePluginPlaceholder::GetV8ScriptableObject( | 173 v8::Local<v8::Object> LoadablePluginPlaceholder::GetV8ScriptableObject( |
258 v8::Isolate* isolate) const { | 174 v8::Isolate* isolate) const { |
259 #if defined(ENABLE_PLUGINS) | |
260 // Pass through JavaScript access to the underlying throttled plugin. | 175 // Pass through JavaScript access to the underlying throttled plugin. |
261 if (premade_throttler_ && premade_throttler_->GetWebPlugin()) { | 176 if (premade_throttler_ && premade_throttler_->GetWebPlugin()) { |
262 return premade_throttler_->GetWebPlugin()->v8ScriptableObject(isolate); | 177 return premade_throttler_->GetWebPlugin()->v8ScriptableObject(isolate); |
263 } | 178 } |
264 #endif | |
265 return v8::Local<v8::Object>(); | 179 return v8::Local<v8::Object>(); |
266 } | 180 } |
267 | 181 |
268 void LoadablePluginPlaceholder::WasShown() { | 182 void LoadablePluginPlaceholder::WasShown() { |
269 if (is_blocked_for_background_tab_) { | 183 if (is_blocked_for_background_tab_) { |
270 is_blocked_for_background_tab_ = false; | 184 is_blocked_for_background_tab_ = false; |
271 if (!LoadingBlocked()) | 185 if (!LoadingBlocked()) |
272 LoadPlugin(); | 186 LoadPlugin(); |
273 } | 187 } |
274 } | 188 } |
(...skipping 14 matching lines...) Expand all Loading... |
289 if (is_blocked_for_prerendering_) { | 203 if (is_blocked_for_prerendering_) { |
290 is_blocked_for_prerendering_ = false; | 204 is_blocked_for_prerendering_ = false; |
291 if (!LoadingBlocked()) | 205 if (!LoadingBlocked()) |
292 LoadPlugin(); | 206 LoadPlugin(); |
293 } | 207 } |
294 } | 208 } |
295 | 209 |
296 void LoadablePluginPlaceholder::LoadPlugin() { | 210 void LoadablePluginPlaceholder::LoadPlugin() { |
297 // This is not strictly necessary but is an important defense in case the | 211 // This is not strictly necessary but is an important defense in case the |
298 // event propagation changes between "close" vs. "click-to-play". | 212 // event propagation changes between "close" vs. "click-to-play". |
299 if (hidden_) | 213 if (hidden()) |
300 return; | 214 return; |
301 if (!plugin()) | 215 if (!plugin()) |
302 return; | 216 return; |
303 if (!allow_loading_) { | 217 if (!allow_loading_) { |
304 NOTREACHED(); | 218 NOTREACHED(); |
305 return; | 219 return; |
306 } | 220 } |
307 | 221 |
308 if (premade_throttler_) { | 222 if (premade_throttler_) { |
309 premade_throttler_->SetHiddenForPlaceholder(false /* hidden */); | 223 premade_throttler_->SetHiddenForPlaceholder(false /* hidden */); |
310 ReplacePlugin(premade_throttler_->GetWebPlugin()); | 224 ReplacePlugin(premade_throttler_->GetWebPlugin()); |
311 premade_throttler_ = nullptr; | 225 premade_throttler_ = nullptr; |
312 } else { | 226 } else { |
313 ReplacePlugin(CreatePlugin()); | 227 ReplacePlugin(CreatePlugin()); |
314 } | 228 } |
315 } | 229 } |
316 | 230 |
317 void LoadablePluginPlaceholder::LoadCallback() { | 231 void LoadablePluginPlaceholder::LoadCallback() { |
318 RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Load_Click")); | 232 RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Load_Click")); |
319 #if defined(ENABLE_PLUGINS) | |
320 // If the user specifically clicks on the plugin content's placeholder, | 233 // If the user specifically clicks on the plugin content's placeholder, |
321 // disable power saver throttling for this instance. | 234 // disable power saver throttling for this instance. |
322 MarkPluginEssential(PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_CLICK); | 235 MarkPluginEssential(PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_CLICK); |
323 #endif | |
324 LoadPlugin(); | 236 LoadPlugin(); |
325 } | 237 } |
326 | 238 |
327 void LoadablePluginPlaceholder::HideCallback() { | |
328 RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Hide_Click")); | |
329 HidePlugin(); | |
330 } | |
331 | |
332 void LoadablePluginPlaceholder::DidFinishLoadingCallback() { | 239 void LoadablePluginPlaceholder::DidFinishLoadingCallback() { |
333 finished_loading_ = true; | 240 finished_loading_ = true; |
334 if (message_.length() > 0) | 241 if (message_.length() > 0) |
335 UpdateMessage(); | 242 UpdateMessage(); |
336 | 243 |
337 // Wait for the placeholder to finish loading to hide the premade plugin. | 244 // Wait for the placeholder to finish loading to hide the premade plugin. |
338 // This is necessary to prevent a flicker. | 245 // This is necessary to prevent a flicker. |
339 if (premade_throttler_ && power_saver_enabled_) | 246 if (premade_throttler_ && power_saver_enabled_) |
340 premade_throttler_->SetHiddenForPlaceholder(true /* hidden */); | 247 premade_throttler_->SetHiddenForPlaceholder(true /* hidden */); |
341 | 248 |
342 // Set an attribute and post an event, so browser tests can wait for the | 249 // Set an attribute and post an event, so browser tests can wait for the |
343 // placeholder to be ready to receive simulated user input. | 250 // placeholder to be ready to receive simulated user input. |
344 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 251 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
345 switches::kEnablePluginPlaceholderTesting)) { | 252 switches::kEnablePluginPlaceholderTesting)) { |
346 WebElement element = plugin()->container()->element(); | 253 blink::WebElement element = plugin()->container()->element(); |
347 element.setAttribute("placeholderLoaded", "true"); | 254 element.setAttribute("placeholderLoaded", "true"); |
348 | 255 |
349 scoped_ptr<content::V8ValueConverter> converter( | 256 scoped_ptr<content::V8ValueConverter> converter( |
350 content::V8ValueConverter::create()); | 257 content::V8ValueConverter::create()); |
351 base::StringValue value("placeholderLoaded"); | 258 base::StringValue value("placeholderLoaded"); |
352 blink::WebSerializedScriptValue message_data = | 259 blink::WebSerializedScriptValue message_data = |
353 blink::WebSerializedScriptValue::serialize(converter->ToV8Value( | 260 blink::WebSerializedScriptValue::serialize(converter->ToV8Value( |
354 &value, element.document().frame()->mainWorldScriptContext())); | 261 &value, element.document().frame()->mainWorldScriptContext())); |
355 | 262 |
356 blink::WebDOMEvent event = element.document().createEvent("MessageEvent"); | 263 blink::WebDOMEvent event = element.document().createEvent("MessageEvent"); |
(...skipping 26 matching lines...) Expand all Loading... |
383 return identifier_; | 290 return identifier_; |
384 } | 291 } |
385 | 292 |
386 bool LoadablePluginPlaceholder::LoadingBlocked() const { | 293 bool LoadablePluginPlaceholder::LoadingBlocked() const { |
387 DCHECK(allow_loading_); | 294 DCHECK(allow_loading_); |
388 return is_blocked_for_background_tab_ || is_blocked_for_power_saver_poster_ || | 295 return is_blocked_for_background_tab_ || is_blocked_for_power_saver_poster_ || |
389 is_blocked_for_prerendering_; | 296 is_blocked_for_prerendering_; |
390 } | 297 } |
391 | 298 |
392 } // namespace plugins | 299 } // namespace plugins |
OLD | NEW |