| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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()->web_view()->mainFrame()->executeScript( |
| 149 blink::WebScriptSource(base::UTF8ToUTF16(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; |
| 159 } else if (is_blocked_for_power_saver_poster_) { | 159 } else if (is_blocked_for_power_saver_poster_) { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 | 241 |
| 242 if (is_blocked_for_power_saver_poster_) { | 242 if (is_blocked_for_power_saver_poster_) { |
| 243 // Adjust poster container padding and dimensions to center play button for | 243 // Adjust poster container padding and dimensions to center play button for |
| 244 // plugins and plugin posters that have their top or left portions obscured. | 244 // plugins and plugin posters that have their top or left portions obscured. |
| 245 std::string script = base::StringPrintf( | 245 std::string script = base::StringPrintf( |
| 246 "window.resizePoster('%dpx', '%dpx', '%dpx', '%dpx')", x, y, width, | 246 "window.resizePoster('%dpx', '%dpx', '%dpx', '%dpx')", x, y, width, |
| 247 height); | 247 height); |
| 248 plugin()->web_view()->mainFrame()->executeScript( | 248 plugin()->web_view()->mainFrame()->executeScript( |
| 249 blink::WebScriptSource(base::UTF8ToUTF16(script))); | 249 blink::WebScriptSource(blink::WebString::fromUTF8(script))); |
| 250 } | 250 } |
| 251 } | 251 } |
| 252 | 252 |
| 253 void LoadablePluginPlaceholder::WasShown() { | 253 void LoadablePluginPlaceholder::WasShown() { |
| 254 if (is_blocked_for_background_tab_) { | 254 if (is_blocked_for_background_tab_) { |
| 255 is_blocked_for_background_tab_ = false; | 255 is_blocked_for_background_tab_ = false; |
| 256 if (!LoadingBlocked()) | 256 if (!LoadingBlocked()) |
| 257 LoadPlugin(); | 257 LoadPlugin(); |
| 258 } | 258 } |
| 259 } | 259 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 return identifier_; | 364 return identifier_; |
| 365 } | 365 } |
| 366 | 366 |
| 367 bool LoadablePluginPlaceholder::LoadingBlocked() const { | 367 bool LoadablePluginPlaceholder::LoadingBlocked() const { |
| 368 DCHECK(allow_loading_); | 368 DCHECK(allow_loading_); |
| 369 return is_blocked_for_tinyness_ || is_blocked_for_background_tab_ || | 369 return is_blocked_for_tinyness_ || is_blocked_for_background_tab_ || |
| 370 is_blocked_for_power_saver_poster_ || is_blocked_for_prerendering_; | 370 is_blocked_for_power_saver_poster_ || is_blocked_for_prerendering_; |
| 371 } | 371 } |
| 372 | 372 |
| 373 } // namespace plugins | 373 } // namespace plugins |
| OLD | NEW |