Chromium Code Reviews| Index: chrome/renderer/chrome_content_renderer_client.cc |
| diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc |
| index 356f7af0751fd310b6ae8ef434f386299cbe1b46..659fa04bb2f3c39aec8248dd4dc2f1aede17a155 100644 |
| --- a/chrome/renderer/chrome_content_renderer_client.cc |
| +++ b/chrome/renderer/chrome_content_renderer_client.cc |
| @@ -70,6 +70,7 @@ |
| #include "components/visitedlink/renderer/visitedlink_slave.h" |
| #include "components/web_cache/renderer/web_cache_render_process_observer.h" |
| #include "content/public/common/content_constants.h" |
| +#include "content/public/renderer/plugin_instance_throttler.h" |
| #include "content/public/renderer/render_frame.h" |
| #include "content/public/renderer/render_thread.h" |
| #include "content/public/renderer/render_view.h" |
| @@ -152,6 +153,7 @@ using autofill::PasswordAutofillAgent; |
| using autofill::PasswordGenerationAgent; |
| using base::ASCIIToUTF16; |
| using base::UserMetricsAction; |
| +using content::PluginInstanceThrottler; |
| using content::RenderFrame; |
| using content::RenderThread; |
| using content::WebPluginInfo; |
| @@ -794,9 +796,9 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin( |
| } |
| #endif // !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS) |
| - RenderFrame::PluginPowerSaverMode power_saver_mode = |
| - RenderFrame::POWER_SAVER_MODE_ESSENTIAL; |
| #if defined(ENABLE_PLUGINS) |
| + PluginInstanceThrottler::PluginPowerSaverMode power_saver_mode = |
| + PluginInstanceThrottler::POWER_SAVER_MODE_ESSENTIAL; |
| bool show_poster = false; |
| GURL poster_url; |
| bool cross_origin_main_content = false; |
| @@ -807,14 +809,16 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin( |
| if (render_frame->ShouldThrottleContent(params, frame->document().url(), |
| &poster_url, |
| &cross_origin_main_content)) { |
| - if (status_value == |
| - ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent) { |
| + // TODO(tommycli): Apply throttler behavior to all plugins. |
| + if (status_value == ChromeViewHostMsg_GetPluginInfo_Status:: |
| + kPlayImportantContent && |
| + plugin.name == base::ASCIIToUTF16(content::kFlashPluginName)) { |
| power_saver_mode = |
| - RenderFrame::POWER_SAVER_MODE_PERIPHERAL_THROTTLED; |
| + PluginInstanceThrottler::POWER_SAVER_MODE_PERIPHERAL_THROTTLED; |
| show_poster = poster_url.is_valid(); |
| } else { |
| - power_saver_mode = |
| - RenderFrame::POWER_SAVER_MODE_PERIPHERAL_UNTHROTTLED; |
| + power_saver_mode = PluginInstanceThrottler:: |
| + POWER_SAVER_MODE_PERIPHERAL_UNTHROTTLED; |
| } |
| } |
| @@ -839,10 +843,18 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin( |
| GURL content_origin = GURL(params.url).GetOrigin(); |
| render_frame->WhitelistContentOrigin(content_origin); |
| } |
| -#endif // defined(ENABLE_PLUGINS) |
| + scoped_ptr<content::PluginInstanceThrottler> throttler; |
| + if (power_saver_mode != |
| + content::PluginInstanceThrottler::POWER_SAVER_MODE_ESSENTIAL) { |
| + throttler.reset(content::PluginInstanceThrottler::Create( |
| + render_frame, url, power_saver_mode).release()); |
|
piman
2015/01/14 19:15:43
nit: throttler = content::PluginInstanceThrottler:
tommycli
2015/01/14 19:22:05
Done.
|
| + } |
| return render_frame->CreatePlugin(frame, plugin, params, |
| - power_saver_mode); |
| + throttler.Pass()); |
| +#else // !defined(ENABLE_PLUGINS) |
| + return render_frame->CreatePlugin(frame, plugin, params, nullptr); |
| +#endif |
| } |
| case ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported: { |
| RenderThread::Get()->RecordAction( |