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

Unified Diff: chrome/renderer/plugins/plugin_preroller.cc

Issue 1015023002: Plugin Power Saver: Throttle 'large' plugins that appear small. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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/plugins/plugin_preroller.h ('k') | chrome/renderer/resources/plugin_poster.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/plugins/plugin_preroller.cc
diff --git a/chrome/renderer/plugins/plugin_preroller.cc b/chrome/renderer/plugins/plugin_preroller.cc
index a98e77738da7197950fa75940b9b1f579f0c6a98..65cbb4766aeb1ef7bfcd6ae4a725479dbc64f990 100644
--- a/chrome/renderer/plugins/plugin_preroller.cc
+++ b/chrome/renderer/plugins/plugin_preroller.cc
@@ -28,7 +28,9 @@ PluginPreroller::PluginPreroller(content::RenderFrame* render_frame,
identifier_(identifier),
name_(name),
message_(message),
- throttler_(throttler) {
+ throttler_(throttler),
+ keyframe_width_(0),
+ keyframe_height_(0) {
DCHECK(throttler);
throttler_->AddObserver(this);
}
@@ -52,16 +54,22 @@ void PluginPreroller::OnKeyframeExtracted(const SkBitmap* bitmap) {
std::string data_url_body;
base::Base64Encode(png_as_string, &data_url_body);
keyframe_data_url_ = GURL(data_url_header + data_url_body);
+ keyframe_width_ = bitmap->width();
Lei Zhang 2015/03/18 00:19:32 This is gfx::Size::SetToMin(), right?
tommycli 2015/03/18 00:39:33 Done.
+ keyframe_height_ = bitmap->height();
}
void PluginPreroller::OnThrottleStateChange() {
if (!throttler_->IsThrottled())
return;
+ int width = std::min(keyframe_width_, throttler_->GetWidth());
Lei Zhang 2015/03/18 00:19:32 This is gfx::Size::SetToMin() right?
tommycli 2015/03/18 00:39:33 Done.
+ int height = std::min(keyframe_height_, throttler_->GetHeight());
+
ChromePluginPlaceholder* placeholder =
ChromePluginPlaceholder::CreateBlockedPlugin(
render_frame(), frame_, params_, info_, identifier_, name_,
- IDR_PLUGIN_POSTER_HTML, message_, keyframe_data_url_.spec(), GURL());
+ IDR_PLUGIN_POSTER_HTML, message_, keyframe_data_url_.spec(), GURL(),
+ width, height);
placeholder->SetPremadePlugin(throttler_);
placeholder->set_power_saver_enabled(true);
placeholder->set_allow_loading(true);
« no previous file with comments | « chrome/renderer/plugins/plugin_preroller.h ('k') | chrome/renderer/resources/plugin_poster.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698