| 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 plugin()->main_frame()->ExecuteScript( |
| 149 blink::WebScriptSource(blink::WebString::FromUTF8(script))); | 149 blink::WebScriptSource(blink::WebString::FromUTF8(script))); |
| 150 } | 150 } |
| 151 | 151 |
| 152 void LoadablePluginPlaceholder::PluginDestroyed() { | 152 void LoadablePluginPlaceholder::PluginDestroyed() { |
| 153 if (power_saver_enabled_) { | 153 if (power_saver_enabled_) { |
| 154 if (premade_throttler_) { | 154 if (premade_throttler_) { |
| 155 // Since the premade plugin has been detached from the container, it will | 155 // Since the premade plugin has been detached from the container, it will |
| 156 // not be automatically destroyed along with the page. | 156 // not be automatically destroyed along with the page. |
| 157 premade_throttler_->GetWebPlugin()->Destroy(); | 157 premade_throttler_->GetWebPlugin()->Destroy(); |
| 158 premade_throttler_ = nullptr; | 158 premade_throttler_ = nullptr; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 } | 245 } |
| 246 } | 246 } |
| 247 } | 247 } |
| 248 | 248 |
| 249 if (is_blocked_for_power_saver_poster_) { | 249 if (is_blocked_for_power_saver_poster_) { |
| 250 // Adjust poster container padding and dimensions to center play button for | 250 // Adjust poster container padding and dimensions to center play button for |
| 251 // plugins and plugin posters that have their top or left portions obscured. | 251 // plugins and plugin posters that have their top or left portions obscured. |
| 252 std::string script = base::StringPrintf( | 252 std::string script = base::StringPrintf( |
| 253 "window.resizePoster('%dpx', '%dpx', '%dpx', '%dpx')", x, y, width, | 253 "window.resizePoster('%dpx', '%dpx', '%dpx', '%dpx')", x, y, width, |
| 254 height); | 254 height); |
| 255 plugin()->web_view()->MainFrame()->ExecuteScript( | 255 plugin()->main_frame()->ExecuteScript( |
| 256 blink::WebScriptSource(blink::WebString::FromUTF8(script))); | 256 blink::WebScriptSource(blink::WebString::FromUTF8(script))); |
| 257 } | 257 } |
| 258 } | 258 } |
| 259 | 259 |
| 260 void LoadablePluginPlaceholder::WasShown() { | 260 void LoadablePluginPlaceholder::WasShown() { |
| 261 if (is_blocked_for_background_tab_) { | 261 if (is_blocked_for_background_tab_) { |
| 262 is_blocked_for_background_tab_ = false; | 262 is_blocked_for_background_tab_ = false; |
| 263 if (!LoadingBlocked()) | 263 if (!LoadingBlocked()) |
| 264 LoadPlugin(); | 264 LoadPlugin(); |
| 265 } | 265 } |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 return identifier_; | 374 return identifier_; |
| 375 } | 375 } |
| 376 | 376 |
| 377 bool LoadablePluginPlaceholder::LoadingBlocked() const { | 377 bool LoadablePluginPlaceholder::LoadingBlocked() const { |
| 378 DCHECK(allow_loading_); | 378 DCHECK(allow_loading_); |
| 379 return is_blocked_for_tinyness_ || is_blocked_for_background_tab_ || | 379 return is_blocked_for_tinyness_ || is_blocked_for_background_tab_ || |
| 380 is_blocked_for_power_saver_poster_ || is_blocked_for_prerendering_; | 380 is_blocked_for_power_saver_poster_ || is_blocked_for_prerendering_; |
| 381 } | 381 } |
| 382 | 382 |
| 383 } // namespace plugins | 383 } // namespace plugins |
| OLD | NEW |