Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(516)

Unified Diff: components/plugins/renderer/loadable_plugin_placeholder.cc

Issue 1407913002: Plugin Power Saver: Fix play-icon positioning when poster specified. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/resources/plugins/plugin_poster.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(
« no previous file with comments | « chrome/renderer/resources/plugins/plugin_poster.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698