Index: content/renderer/pepper/pepper_plugin_instance_impl.cc |
diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc |
index 97a85c90f253966dd8e964bd7232cfe7d199e90f..511e3f894c43fc68d5387fa4aace30115ab8f811 100644 |
--- a/content/renderer/pepper/pepper_plugin_instance_impl.cc |
+++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc |
@@ -583,13 +583,9 @@ PepperPluginInstanceImpl::PepperPluginInstanceImpl( |
GetContentClient()->renderer()->IsExternalPepperPlugin(module->name())) |
external_document_load_ = true; |
- // TODO(tommycli): Insert heuristics to determine whether plugin content |
- // is peripheral here. |
- bool is_peripheral_content = true; |
- power_saver_enabled_ = is_peripheral_content && |
- module->name() == kFlashPluginName && |
- CommandLine::ForCurrentProcess()->HasSwitch( |
- switches::kEnablePluginPowerSaver); |
+ power_saver_enabled_ = CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kEnablePluginPowerSaver) && |
+ IsPeripheralContent(); |
if (power_saver_enabled_) { |
throttler_.reset(new PepperPluginInstanceThrottler( |
@@ -3299,6 +3295,14 @@ void PepperPluginInstanceImpl::DidDataFromWebURLResponse( |
} |
} |
+bool PepperPluginInstanceImpl::IsPeripheralContent() const { |
+ if (module_->name() != kFlashPluginName) |
+ return false; |
+ |
+ GURL top_frame_url = render_frame_->GetWebFrame()->top()->document().url(); |
groby-ooo-7-16
2014/10/23 00:53:45
Using GetContainer()->element().document().url() w
raymes
2014/10/23 01:34:07
Are you sure you want the main frame?
Consider th
groby-ooo-7-16
2014/10/23 01:59:13
That'd be the iframe's URL, right? We definitely d
raymes
2014/10/23 03:53:38
I was thinking about a situation where origin X ha
piman
2014/10/23 03:56:32
If we're in an out-of-process iframe, I think this
groby-ooo-7-16
2014/10/23 05:51:19
Will GetContainer()->element().document().url( sti
groby-ooo-7-16
2014/10/23 05:51:19
This is indeed expected behavior - this CL is not
tommycli
2014/10/23 17:23:27
We need render_frame_->GetWebFrame()->top()->docum
Charlie Reis
2014/10/23 18:23:27
It seems like it's unclear to multiple reviewers w
tommycli
2014/10/23 19:32:23
I added some comments. It is indeed a confusing in
Charlie Reis
2014/10/23 19:51:08
Yes, see http://crbug.com/426512. It's a fairly b
|
+ return plugin_url_.GetOrigin() != top_frame_url.GetOrigin(); |
+} |
+ |
void PepperPluginInstanceImpl::SetPluginThrottled(bool throttled) { |
// Do not throttle if we've already disabled power saver. |
if (!power_saver_enabled_ && throttled) |