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

Side by Side Diff: components/plugins/renderer/plugin_placeholder.cc

Issue 849723002: Plugin Power Saver: Make PepperPluginInstanceThrottler interface public. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « components/plugins/renderer/plugin_placeholder.h ('k') | content/content_renderer.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/plugin_placeholder.h" 5 #include "components/plugins/renderer/plugin_placeholder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/json/string_escape.h" 9 #include "base/json/string_escape.h"
10 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
(...skipping 17 matching lines...) Expand all
28 using base::UserMetricsAction; 28 using base::UserMetricsAction;
29 using blink::WebElement; 29 using blink::WebElement;
30 using blink::WebLocalFrame; 30 using blink::WebLocalFrame;
31 using blink::WebMouseEvent; 31 using blink::WebMouseEvent;
32 using blink::WebNode; 32 using blink::WebNode;
33 using blink::WebPlugin; 33 using blink::WebPlugin;
34 using blink::WebPluginContainer; 34 using blink::WebPluginContainer;
35 using blink::WebPluginParams; 35 using blink::WebPluginParams;
36 using blink::WebScriptSource; 36 using blink::WebScriptSource;
37 using blink::WebURLRequest; 37 using blink::WebURLRequest;
38 using content::PluginPowerSaverMode;
38 using content::RenderThread; 39 using content::RenderThread;
39 40
40 namespace plugins { 41 namespace plugins {
41 42
42 gin::WrapperInfo PluginPlaceholder::kWrapperInfo = {gin::kEmbedderNativeGin}; 43 gin::WrapperInfo PluginPlaceholder::kWrapperInfo = {gin::kEmbedderNativeGin};
43 44
44 #if defined(ENABLE_PLUGINS) 45 #if defined(ENABLE_PLUGINS)
45 void PluginPlaceholder::BlockForPowerSaverPoster() { 46 void PluginPlaceholder::BlockForPowerSaverPoster() {
46 DCHECK(!is_blocked_for_power_saver_poster_); 47 DCHECK(!is_blocked_for_power_saver_poster_);
47 is_blocked_for_power_saver_poster_ = true; 48 is_blocked_for_power_saver_poster_ = true;
(...skipping 13 matching lines...) Expand all
61 : content::RenderFrameObserver(render_frame), 62 : content::RenderFrameObserver(render_frame),
62 frame_(frame), 63 frame_(frame),
63 plugin_params_(params), 64 plugin_params_(params),
64 plugin_(WebViewPlugin::Create(this, 65 plugin_(WebViewPlugin::Create(this,
65 render_frame->GetWebkitPreferences(), 66 render_frame->GetWebkitPreferences(),
66 html_data, 67 html_data,
67 placeholderDataUrl)), 68 placeholderDataUrl)),
68 is_blocked_for_background_tab_(false), 69 is_blocked_for_background_tab_(false),
69 is_blocked_for_prerendering_(false), 70 is_blocked_for_prerendering_(false),
70 is_blocked_for_power_saver_poster_(false), 71 is_blocked_for_power_saver_poster_(false),
71 power_saver_mode_(content::RenderFrame::POWER_SAVER_MODE_ESSENTIAL), 72 power_saver_mode_(PluginPowerSaverMode::POWER_SAVER_MODE_ESSENTIAL),
72 allow_loading_(false), 73 allow_loading_(false),
73 hidden_(false), 74 hidden_(false),
74 finished_loading_(false), 75 finished_loading_(false),
75 weak_factory_(this) { 76 weak_factory_(this) {
76 } 77 }
77 78
78 PluginPlaceholder::~PluginPlaceholder() {} 79 PluginPlaceholder::~PluginPlaceholder() {}
79 80
80 #if defined(ENABLE_PLUGINS) 81 #if defined(ENABLE_PLUGINS)
81 void PluginPlaceholder::DisablePowerSaverForInstance() { 82 void PluginPlaceholder::DisablePowerSaverForInstance() {
82 power_saver_mode_ = content::RenderFrame::POWER_SAVER_MODE_ESSENTIAL; 83 power_saver_mode_ = PluginPowerSaverMode::POWER_SAVER_MODE_ESSENTIAL;
83 if (is_blocked_for_power_saver_poster_) { 84 if (is_blocked_for_power_saver_poster_) {
84 is_blocked_for_power_saver_poster_ = false; 85 is_blocked_for_power_saver_poster_ = false;
85 if (!LoadingBlocked()) 86 if (!LoadingBlocked())
86 LoadPlugin(); 87 LoadPlugin();
87 } 88 }
88 } 89 }
89 #endif 90 #endif
90 91
91 gin::ObjectTemplateBuilder PluginPlaceholder::GetObjectTemplateBuilder( 92 gin::ObjectTemplateBuilder PluginPlaceholder::GetObjectTemplateBuilder(
92 v8::Isolate* isolate) { 93 v8::Isolate* isolate) {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 if (!plugin_) 244 if (!plugin_)
244 return; 245 return;
245 if (!allow_loading_) { 246 if (!allow_loading_) {
246 NOTREACHED(); 247 NOTREACHED();
247 return; 248 return;
248 } 249 }
249 250
250 // TODO(mmenke): In the case of prerendering, feed into 251 // TODO(mmenke): In the case of prerendering, feed into
251 // ChromeContentRendererClient::CreatePlugin instead, to 252 // ChromeContentRendererClient::CreatePlugin instead, to
252 // reduce the chance of future regressions. 253 // reduce the chance of future regressions.
254 scoped_ptr<content::PluginInstanceThrottler> throttler;
255 #if defined(ENABLE_PLUGINS)
256 throttler = content::PluginInstanceThrottler::Get(
257 render_frame(), plugin_params_.url, power_saver_mode_);
258 #endif
253 WebPlugin* plugin = render_frame()->CreatePlugin( 259 WebPlugin* plugin = render_frame()->CreatePlugin(
254 frame_, plugin_info_, plugin_params_, power_saver_mode_); 260 frame_, plugin_info_, plugin_params_, throttler.Pass());
255 ReplacePlugin(plugin); 261 ReplacePlugin(plugin);
256 } 262 }
257 263
258 void PluginPlaceholder::LoadCallback() { 264 void PluginPlaceholder::LoadCallback() {
259 RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Load_Click")); 265 RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Load_Click"));
260 // If the user specifically clicks on the plug-in content's placeholder, 266 // If the user specifically clicks on the plug-in content's placeholder,
261 // disable power saver throttling for this instance. 267 // disable power saver throttling for this instance.
262 #if defined(ENABLE_PLUGINS) 268 #if defined(ENABLE_PLUGINS)
263 DisablePowerSaverForInstance(); 269 DisablePowerSaverForInstance();
264 #endif 270 #endif
(...skipping 30 matching lines...) Expand all
295 return plugin_params_; 301 return plugin_params_;
296 } 302 }
297 303
298 bool PluginPlaceholder::LoadingBlocked() const { 304 bool PluginPlaceholder::LoadingBlocked() const {
299 DCHECK(allow_loading_); 305 DCHECK(allow_loading_);
300 return is_blocked_for_background_tab_ || is_blocked_for_power_saver_poster_ || 306 return is_blocked_for_background_tab_ || is_blocked_for_power_saver_poster_ ||
301 is_blocked_for_prerendering_; 307 is_blocked_for_prerendering_;
302 } 308 }
303 309
304 } // namespace plugins 310 } // namespace plugins
OLDNEW
« no previous file with comments | « components/plugins/renderer/plugin_placeholder.h ('k') | content/content_renderer.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698