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 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
| |
3303 return plugin_url_.GetOrigin() != top_frame_url.GetOrigin(); | |
3304 } | |
3305 | |
3302 void PepperPluginInstanceImpl::SetPluginThrottled(bool throttled) { | 3306 void PepperPluginInstanceImpl::SetPluginThrottled(bool throttled) { |
3303 // Do not throttle if we've already disabled power saver. | 3307 // Do not throttle if we've already disabled power saver. |
3304 if (!power_saver_enabled_ && throttled) | 3308 if (!power_saver_enabled_ && throttled) |
3305 return; | 3309 return; |
3306 | 3310 |
3307 plugin_throttled_ = throttled; | 3311 plugin_throttled_ = throttled; |
3308 SendDidChangeView(); | 3312 SendDidChangeView(); |
3309 } | 3313 } |
3310 | 3314 |
3311 } // namespace content | 3315 } // namespace content |
OLD | NEW |