Chromium Code Reviews| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 message_ = message; | 138 message_ = message; |
| 139 if (finished_loading_) | 139 if (finished_loading_) |
| 140 UpdateMessage(); | 140 UpdateMessage(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void LoadablePluginPlaceholder::UpdateMessage() { | 143 void LoadablePluginPlaceholder::UpdateMessage() { |
| 144 if (!plugin()) | 144 if (!plugin()) |
| 145 return; | 145 return; |
| 146 std::string script = | 146 std::string script = |
| 147 "window.setMessage(" + base::GetQuotedJSONString(message_) + ")"; | 147 "window.setMessage(" + base::GetQuotedJSONString(message_) + ")"; |
| 148 plugin()->web_view()->MainFrame()->ExecuteScript( | 148 blink::WebFrame* main_frame = plugin()->web_view()->MainFrame(); |
| 149 if (!main_frame->IsWebLocalFrame()) { | |
|
dcheng
2017/06/04 10:37:22
As this is a WebViewPlugin, which is only used to
Łukasz Anforowicz
2017/06/05 17:10:57
Good point - done:
- I've exposed WebViewPlugin::
| |
| 150 NOTREACHED(); | |
| 151 return; | |
| 152 } | |
| 153 main_frame->ToWebLocalFrame()->ExecuteScript( | |
| 149 blink::WebScriptSource(blink::WebString::FromUTF8(script))); | 154 blink::WebScriptSource(blink::WebString::FromUTF8(script))); |
| 150 } | 155 } |
| 151 | 156 |
| 152 void LoadablePluginPlaceholder::PluginDestroyed() { | 157 void LoadablePluginPlaceholder::PluginDestroyed() { |
| 153 if (power_saver_enabled_) { | 158 if (power_saver_enabled_) { |
| 154 if (premade_throttler_) { | 159 if (premade_throttler_) { |
| 155 // Since the premade plugin has been detached from the container, it will | 160 // Since the premade plugin has been detached from the container, it will |
| 156 // not be automatically destroyed along with the page. | 161 // not be automatically destroyed along with the page. |
| 157 premade_throttler_->GetWebPlugin()->Destroy(); | 162 premade_throttler_->GetWebPlugin()->Destroy(); |
| 158 premade_throttler_ = nullptr; | 163 premade_throttler_ = nullptr; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 } | 250 } |
| 246 } | 251 } |
| 247 } | 252 } |
| 248 | 253 |
| 249 if (is_blocked_for_power_saver_poster_) { | 254 if (is_blocked_for_power_saver_poster_) { |
| 250 // Adjust poster container padding and dimensions to center play button for | 255 // Adjust poster container padding and dimensions to center play button for |
| 251 // plugins and plugin posters that have their top or left portions obscured. | 256 // plugins and plugin posters that have their top or left portions obscured. |
| 252 std::string script = base::StringPrintf( | 257 std::string script = base::StringPrintf( |
| 253 "window.resizePoster('%dpx', '%dpx', '%dpx', '%dpx')", x, y, width, | 258 "window.resizePoster('%dpx', '%dpx', '%dpx', '%dpx')", x, y, width, |
| 254 height); | 259 height); |
| 255 plugin()->web_view()->MainFrame()->ExecuteScript( | 260 blink::WebFrame* main_frame = plugin()->web_view()->MainFrame(); |
| 261 if (!main_frame->IsWebLocalFrame()) { | |
| 262 NOTREACHED(); | |
| 263 return; | |
| 264 } | |
| 265 main_frame->ToWebLocalFrame()->ExecuteScript( | |
| 256 blink::WebScriptSource(blink::WebString::FromUTF8(script))); | 266 blink::WebScriptSource(blink::WebString::FromUTF8(script))); |
| 257 } | 267 } |
| 258 } | 268 } |
| 259 | 269 |
| 260 void LoadablePluginPlaceholder::WasShown() { | 270 void LoadablePluginPlaceholder::WasShown() { |
| 261 if (is_blocked_for_background_tab_) { | 271 if (is_blocked_for_background_tab_) { |
| 262 is_blocked_for_background_tab_ = false; | 272 is_blocked_for_background_tab_ = false; |
| 263 if (!LoadingBlocked()) | 273 if (!LoadingBlocked()) |
| 264 LoadPlugin(); | 274 LoadPlugin(); |
| 265 } | 275 } |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 return identifier_; | 384 return identifier_; |
| 375 } | 385 } |
| 376 | 386 |
| 377 bool LoadablePluginPlaceholder::LoadingBlocked() const { | 387 bool LoadablePluginPlaceholder::LoadingBlocked() const { |
| 378 DCHECK(allow_loading_); | 388 DCHECK(allow_loading_); |
| 379 return is_blocked_for_tinyness_ || is_blocked_for_background_tab_ || | 389 return is_blocked_for_tinyness_ || is_blocked_for_background_tab_ || |
| 380 is_blocked_for_power_saver_poster_ || is_blocked_for_prerendering_; | 390 is_blocked_for_power_saver_poster_ || is_blocked_for_prerendering_; |
| 381 } | 391 } |
| 382 | 392 |
| 383 } // namespace plugins | 393 } // namespace plugins |
| OLD | NEW |