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

Side by Side Diff: chrome/renderer/plugins/plugin_preroller.cc

Issue 1497623002: Plugin Power Saver: Improve Poster behavior for essential plugins. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 unified diff | Download patch
OLDNEW
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 "chrome/renderer/plugins/plugin_preroller.h" 5 #include "chrome/renderer/plugins/plugin_preroller.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "chrome/grit/renderer_resources.h" 8 #include "chrome/grit/renderer_resources.h"
9 #include "chrome/renderer/plugins/chrome_plugin_placeholder.h" 9 #include "chrome/renderer/plugins/chrome_plugin_placeholder.h"
10 #include "chrome/renderer/plugins/power_saver_info.h"
10 #include "third_party/WebKit/public/platform/WebRect.h" 11 #include "third_party/WebKit/public/platform/WebRect.h"
11 #include "third_party/WebKit/public/web/WebElement.h" 12 #include "third_party/WebKit/public/web/WebElement.h"
12 #include "third_party/WebKit/public/web/WebPlugin.h" 13 #include "third_party/WebKit/public/web/WebPlugin.h"
13 #include "third_party/WebKit/public/web/WebPluginContainer.h" 14 #include "third_party/WebKit/public/web/WebPluginContainer.h"
14 #include "ui/gfx/codec/png_codec.h" 15 #include "ui/gfx/codec/png_codec.h"
15 16
16 PluginPreroller::PluginPreroller(content::RenderFrame* render_frame, 17 PluginPreroller::PluginPreroller(content::RenderFrame* render_frame,
17 blink::WebLocalFrame* frame, 18 blink::WebLocalFrame* frame,
18 const blink::WebPluginParams& params, 19 const blink::WebPluginParams& params,
19 const content::WebPluginInfo& info, 20 const content::WebPluginInfo& info,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 std::string data_url_header = "data:image/png;base64,"; 52 std::string data_url_header = "data:image/png;base64,";
52 std::string data_url_body; 53 std::string data_url_body;
53 base::Base64Encode(png_as_string, &data_url_body); 54 base::Base64Encode(png_as_string, &data_url_body);
54 keyframe_data_url_ = GURL(data_url_header + data_url_body); 55 keyframe_data_url_ = GURL(data_url_header + data_url_body);
55 } 56 }
56 57
57 void PluginPreroller::OnThrottleStateChange() { 58 void PluginPreroller::OnThrottleStateChange() {
58 if (!throttler_->IsThrottled()) 59 if (!throttler_->IsThrottled())
59 return; 60 return;
60 61
61 PlaceholderPosterInfo poster_info; 62 PowerSaverInfo power_saver_info;
62 poster_info.poster_attribute = keyframe_data_url_.spec(); 63 power_saver_info.power_saver_enabled = true;
63 poster_info.custom_poster_size = throttler_->GetSize(); 64 power_saver_info.poster_attribute = keyframe_data_url_.spec();
65 power_saver_info.custom_poster_size = throttler_->GetSize();
64 66
65 ChromePluginPlaceholder* placeholder = 67 ChromePluginPlaceholder* placeholder =
66 ChromePluginPlaceholder::CreateBlockedPlugin( 68 ChromePluginPlaceholder::CreateBlockedPlugin(
67 render_frame(), frame_, params_, info_, identifier_, name_, 69 render_frame(), frame_, params_, info_, identifier_, name_,
68 IDR_PLUGIN_POSTER_HTML, message_, poster_info); 70 IDR_PLUGIN_POSTER_HTML, message_, power_saver_info);
69 placeholder->SetPremadePlugin(throttler_); 71 placeholder->SetPremadePlugin(throttler_);
70 placeholder->set_power_saver_enabled(true);
71 placeholder->AllowLoading(); 72 placeholder->AllowLoading();
72 73
73 blink::WebPluginContainer* container = 74 blink::WebPluginContainer* container =
74 throttler_->GetWebPlugin()->container(); 75 throttler_->GetWebPlugin()->container();
75 container->setPlugin(placeholder->plugin()); 76 container->setPlugin(placeholder->plugin());
76 77
77 bool success = placeholder->plugin()->initialize(container); 78 bool success = placeholder->plugin()->initialize(container);
78 DCHECK(success); 79 DCHECK(success);
79 80
80 container->invalidate(); 81 container->invalidate();
81 container->reportGeometry(); 82 container->reportGeometry();
82 83
83 delete this; 84 delete this;
84 } 85 }
85 86
86 void PluginPreroller::OnThrottlerDestroyed() { 87 void PluginPreroller::OnThrottlerDestroyed() {
87 throttler_ = nullptr; 88 throttler_ = nullptr;
88 delete this; 89 delete this;
89 } 90 }
OLDNEW
« no previous file with comments | « chrome/renderer/plugins/chrome_plugin_placeholder.cc ('k') | chrome/renderer/plugins/power_saver_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698