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..102bc8e520b39ca04bb49b3a8cb85c64717b2e65 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,17 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin( |
GURL content_origin = GURL(params.url).GetOrigin(); |
render_frame->WhitelistContentOrigin(content_origin); |
} |
-#endif // defined(ENABLE_PLUGINS) |
- return render_frame->CreatePlugin(frame, plugin, params, |
- power_saver_mode); |
+ content::PluginInstanceThrottler* throttler = nullptr; |
+ if (power_saver_mode != |
+ content::PluginInstanceThrottler::POWER_SAVER_MODE_ESSENTIAL) { |
+ throttler = new content::PluginInstanceThrottler(render_frame, url, |
+ power_saver_mode); |
+ } |
+ return render_frame->CreatePlugin(frame, plugin, params, throttler); |
+#else // !defined(ENABLE_PLUGINS) |
+ return render_frame->CreatePlugin(frame, plugin, params, nullptr); |
+#endif |
} |
case ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported: { |
RenderThread::Get()->RecordAction( |