Chromium Code Reviews| 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..2d2d61ad00d12127c35282e2de2eb4047c22f035 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,26 @@ void PepperPluginInstanceImpl::DidDataFromWebURLResponse( |
| } |
| } |
| +bool PepperPluginInstanceImpl::IsPeripheralContent() const { |
| + if (module_->name() != kFlashPluginName) |
| + return false; |
| + |
| + // Peripheral plugin content is defined to be peripheral when the plugin |
| + // content's origin differs from the top level frame's origin. For example: |
| + // - Peripheral: a.com -> b.com/plugin.swf |
| + // - Peripheral: a.com -> b.com/iframe.html -> b.com/plugin.swf |
| + // - NOT peripheral: a.com -> b.com/iframe-to-a.html -> a.com/plugin.swf |
| + |
| + // TODO(alexmos): Update this to use the origin of the RemoteFrame when 426512 |
| + // is fixed. For now, case 3 in the comment above doesn't work in |
| + // --site-per-process mode. |
| + if (render_frame_->GetWebFrame()->top()->isWebRemoteFrame()) |
|
raymes
2014/10/23 21:09:03
creis@: As an aside, we have lots of places in thi
Charlie Reis
2014/10/23 21:51:33
Per my announcement to chromium-dev on Tuesday, I'
tommycli
2014/10/23 22:21:09
Testing this, I've discovered that cross-origin pl
Charlie Reis
2014/10/23 23:50:44
Nice find. Can you file a bug with the Cr-Interna
|
| + return true; |
| + |
| + GURL top_frame_url = render_frame_->GetWebFrame()->top()->document().url(); |
|
piman
2014/10/23 21:07:34
Can you save the result of render_frame_->GetWebFr
raymes
2014/10/23 21:09:03
nit: In the rest of this file we use render_frame_
Charlie Reis
2014/10/23 21:51:33
Assuming render_frame_->GetWebFrame() is a LocalFr
tommycli
2014/10/23 22:21:09
Done.
Looks like the other places of this file us
tommycli
2014/10/23 22:21:09
Done.
|
| + 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) |