Index: components/plugins/renderer/loadable_plugin_placeholder.cc |
diff --git a/components/plugins/renderer/loadable_plugin_placeholder.cc b/components/plugins/renderer/loadable_plugin_placeholder.cc |
index 40c4a5a21b12754617878c9fbe7796a84f86933f..8a3d9fdbd0f430a9768514768a4ca1397c399396 100644 |
--- a/components/plugins/renderer/loadable_plugin_placeholder.cc |
+++ b/components/plugins/renderer/loadable_plugin_placeholder.cc |
@@ -184,7 +184,7 @@ v8::Local<v8::Object> LoadablePluginPlaceholder::GetV8ScriptableObject( |
void LoadablePluginPlaceholder::OnUnobscuredRectUpdate( |
const gfx::Rect& unobscured_rect) { |
DCHECK(content::RenderThread::Get()); |
- if (!power_saver_enabled_ || !premade_throttler_ || !finished_loading_) |
+ if (!power_saver_enabled_ || !finished_loading_) |
return; |
unobscured_rect_ = unobscured_rect; |
@@ -328,18 +328,24 @@ void LoadablePluginPlaceholder::RecheckSizeAndMaybeUnthrottle() { |
float zoom_factor = plugin()->container()->pageZoomFactor(); |
- // Adjust padding using clip coordinates to center play button for plugins |
- // that have their top or left portions obscured. |
+ // Adjust poster container padding and dimensions to center play button for |
+ // plugins and plugin posters that have their top or left portions obscured. |
if (is_blocked_for_power_saver_poster_) { |
int x = roundf(unobscured_rect_.x() / zoom_factor); |
int y = roundf(unobscured_rect_.y() / zoom_factor); |
- std::string script = |
- base::StringPrintf("window.setPosterMargin('%dpx', '%dpx')", x, y); |
+ int width = roundf(unobscured_rect_.width() / zoom_factor); |
+ int height = roundf(unobscured_rect_.height() / zoom_factor); |
+ std::string script = base::StringPrintf( |
+ "window.resizePoster('%dpx', '%dpx', '%dpx', '%dpx')", x, y, width, |
+ height); |
plugin()->web_view()->mainFrame()->executeScript( |
blink::WebScriptSource(base::UTF8ToUTF16(script))); |
} |
- if (PluginInstanceThrottler::IsLargeContent( |
+ // Only unthrottle on size increase for plugins without poster. |
+ // TODO(tommycli): Address this unfairness to plugins that specify a poster. |
+ if (premade_throttler_ && |
tommycli
2015/10/15 21:54:50
Needed to compensate for change in line 187.
Lei Zhang
2015/10/15 23:05:31
Sorry, it's been a while. You'll have to remind me
tommycli
2015/10/16 17:16:25
Discussed in person.
|
+ PluginInstanceThrottler::IsLargeContent( |
roundf(unobscured_rect_.width() / zoom_factor), |
roundf(unobscured_rect_.height() / zoom_factor))) { |
MarkPluginEssential( |