Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/pepper/pepper_plugin_instance_impl.h" | 5 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 576 } | 576 } |
| 577 } | 577 } |
| 578 | 578 |
| 579 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host(); | 579 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host(); |
| 580 resource_creation_ = host_impl->CreateInProcessResourceCreationAPI(this); | 580 resource_creation_ = host_impl->CreateInProcessResourceCreationAPI(this); |
| 581 | 581 |
| 582 if (GetContentClient()->renderer() && // NULL in unit tests. | 582 if (GetContentClient()->renderer() && // NULL in unit tests. |
| 583 GetContentClient()->renderer()->IsExternalPepperPlugin(module->name())) | 583 GetContentClient()->renderer()->IsExternalPepperPlugin(module->name())) |
| 584 external_document_load_ = true; | 584 external_document_load_ = true; |
| 585 | 585 |
| 586 // TODO(tommycli): Insert heuristics to determine whether plugin content | 586 power_saver_enabled_ = CommandLine::ForCurrentProcess()->HasSwitch( |
| 587 // is peripheral here. | 587 switches::kEnablePluginPowerSaver) && |
| 588 bool is_peripheral_content = true; | 588 IsPeripheralContent(); |
| 589 power_saver_enabled_ = is_peripheral_content && | |
| 590 module->name() == kFlashPluginName && | |
| 591 CommandLine::ForCurrentProcess()->HasSwitch( | |
| 592 switches::kEnablePluginPowerSaver); | |
| 593 | 589 |
| 594 if (power_saver_enabled_) { | 590 if (power_saver_enabled_) { |
| 595 throttler_.reset(new PepperPluginInstanceThrottler( | 591 throttler_.reset(new PepperPluginInstanceThrottler( |
| 596 base::Bind(&PepperPluginInstanceImpl::SetPluginThrottled, | 592 base::Bind(&PepperPluginInstanceImpl::SetPluginThrottled, |
| 597 weak_factory_.GetWeakPtr(), true /* throttled */))); | 593 weak_factory_.GetWeakPtr(), true /* throttled */))); |
| 598 } | 594 } |
| 599 } | 595 } |
| 600 | 596 |
| 601 PepperPluginInstanceImpl::~PepperPluginInstanceImpl() { | 597 PepperPluginInstanceImpl::~PepperPluginInstanceImpl() { |
| 602 DCHECK(!fullscreen_container_); | 598 DCHECK(!fullscreen_container_); |
| (...skipping 2689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3292 } else { | 3288 } else { |
| 3293 // Running out-of-process. Initiate an IPC call to notify the plugin | 3289 // Running out-of-process. Initiate an IPC call to notify the plugin |
| 3294 // process. | 3290 // process. |
| 3295 ppapi::proxy::HostDispatcher* dispatcher = | 3291 ppapi::proxy::HostDispatcher* dispatcher = |
| 3296 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); | 3292 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); |
| 3297 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( | 3293 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( |
| 3298 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); | 3294 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); |
| 3299 } | 3295 } |
| 3300 } | 3296 } |
| 3301 | 3297 |
| 3298 bool PepperPluginInstanceImpl::IsPeripheralContent() const { | |
| 3299 if (module_->name() != kFlashPluginName) | |
| 3300 return false; | |
| 3301 | |
| 3302 // Peripheral plugin content is defined to be peripheral when the plugin | |
| 3303 // content's origin differs from the top level frame's origin. For example: | |
| 3304 // - Peripheral: a.com -> b.com/plugin.swf | |
| 3305 // - Peripheral: a.com -> b.com/iframe.html -> b.com/plugin.swf | |
| 3306 // - NOT peripheral: a.com -> b.com/iframe-to-a.html -> a.com/plugin.swf | |
| 3307 | |
| 3308 // TODO(alexmos): Update this to use the origin of the RemoteFrame when 426512 | |
| 3309 // is fixed. For now, case 3 in the comment above doesn't work in | |
| 3310 // --site-per-process mode. | |
| 3311 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
| |
| 3312 return true; | |
| 3313 | |
| 3314 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.
| |
| 3315 return plugin_url_.GetOrigin() != top_frame_url.GetOrigin(); | |
| 3316 } | |
| 3317 | |
| 3302 void PepperPluginInstanceImpl::SetPluginThrottled(bool throttled) { | 3318 void PepperPluginInstanceImpl::SetPluginThrottled(bool throttled) { |
| 3303 // Do not throttle if we've already disabled power saver. | 3319 // Do not throttle if we've already disabled power saver. |
| 3304 if (!power_saver_enabled_ && throttled) | 3320 if (!power_saver_enabled_ && throttled) |
| 3305 return; | 3321 return; |
| 3306 | 3322 |
| 3307 plugin_throttled_ = throttled; | 3323 plugin_throttled_ = throttled; |
| 3308 SendDidChangeView(); | 3324 SendDidChangeView(); |
| 3309 } | 3325 } |
| 3310 | 3326 |
| 3311 } // namespace content | 3327 } // namespace content |
| OLD | NEW |