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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 input_sequence); | 381 input_sequence); |
382 new_latency->TraceEventType(WebInputEventTraits::GetName(type)); | 382 new_latency->TraceEventType(WebInputEventTraits::GetName(type)); |
383 if (old_latency) { | 383 if (old_latency) { |
384 new_latency->CopyLatencyFrom(*old_latency, | 384 new_latency->CopyLatencyFrom(*old_latency, |
385 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT); | 385 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT); |
386 new_latency->CopyLatencyFrom(*old_latency, | 386 new_latency->CopyLatencyFrom(*old_latency, |
387 ui::INPUT_EVENT_LATENCY_UI_COMPONENT); | 387 ui::INPUT_EVENT_LATENCY_UI_COMPONENT); |
388 } | 388 } |
389 } | 389 } |
390 | 390 |
| 391 bool IsFlashPlugin(PluginModule* module) { |
| 392 return module->name() == kFlashPluginName; |
| 393 } |
| 394 |
391 } // namespace | 395 } // namespace |
392 | 396 |
393 // static | 397 // static |
394 PepperPluginInstanceImpl* PepperPluginInstanceImpl::Create( | 398 PepperPluginInstanceImpl* PepperPluginInstanceImpl::Create( |
395 RenderFrameImpl* render_frame, | 399 RenderFrameImpl* render_frame, |
396 PluginModule* module, | 400 PluginModule* module, |
397 WebPluginContainer* container, | 401 WebPluginContainer* container, |
398 const GURL& plugin_url) { | 402 const GURL& plugin_url) { |
399 base::Callback<const void*(const char*)> get_plugin_interface_func = | 403 base::Callback<const void*(const char*)> get_plugin_interface_func = |
400 base::Bind(&PluginModule::GetPluginInterface, module); | 404 base::Bind(&PluginModule::GetPluginInterface, module); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 | 589 |
586 power_saver_enabled_ = CommandLine::ForCurrentProcess()->HasSwitch( | 590 power_saver_enabled_ = CommandLine::ForCurrentProcess()->HasSwitch( |
587 switches::kEnablePluginPowerSaver) && | 591 switches::kEnablePluginPowerSaver) && |
588 IsPeripheralContent(); | 592 IsPeripheralContent(); |
589 | 593 |
590 if (power_saver_enabled_) { | 594 if (power_saver_enabled_) { |
591 throttler_.reset(new PepperPluginInstanceThrottler( | 595 throttler_.reset(new PepperPluginInstanceThrottler( |
592 base::Bind(&PepperPluginInstanceImpl::SetPluginThrottled, | 596 base::Bind(&PepperPluginInstanceImpl::SetPluginThrottled, |
593 weak_factory_.GetWeakPtr(), true /* throttled */))); | 597 weak_factory_.GetWeakPtr(), true /* throttled */))); |
594 } | 598 } |
| 599 |
| 600 if (IsFlashPlugin(module_.get())) { |
| 601 RenderThread::Get()->RecordAction( |
| 602 base::UserMetricsAction("Flash.PluginInstanceCreated")); |
| 603 } |
595 } | 604 } |
596 | 605 |
597 PepperPluginInstanceImpl::~PepperPluginInstanceImpl() { | 606 PepperPluginInstanceImpl::~PepperPluginInstanceImpl() { |
598 DCHECK(!fullscreen_container_); | 607 DCHECK(!fullscreen_container_); |
599 | 608 |
600 // Notify all the plugin objects of deletion. This will prevent blink from | 609 // Notify all the plugin objects of deletion. This will prevent blink from |
601 // calling into the plugin any more. | 610 // calling into the plugin any more. |
602 // | 611 // |
603 // Swap out the set so we can delete from it (the objects will try to | 612 // Swap out the set so we can delete from it (the objects will try to |
604 // unregister themselves inside the delete call). | 613 // unregister themselves inside the delete call). |
(...skipping 2684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3289 // Running out-of-process. Initiate an IPC call to notify the plugin | 3298 // Running out-of-process. Initiate an IPC call to notify the plugin |
3290 // process. | 3299 // process. |
3291 ppapi::proxy::HostDispatcher* dispatcher = | 3300 ppapi::proxy::HostDispatcher* dispatcher = |
3292 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); | 3301 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); |
3293 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( | 3302 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( |
3294 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); | 3303 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); |
3295 } | 3304 } |
3296 } | 3305 } |
3297 | 3306 |
3298 bool PepperPluginInstanceImpl::IsPeripheralContent() const { | 3307 bool PepperPluginInstanceImpl::IsPeripheralContent() const { |
3299 if (module_->name() != kFlashPluginName) | 3308 if (!IsFlashPlugin(module_.get())) |
3300 return false; | 3309 return false; |
3301 | 3310 |
3302 // Peripheral plugin content is defined to be peripheral when the plugin | 3311 // 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: | 3312 // content's origin differs from the top level frame's origin. For example: |
3304 // - Peripheral: a.com -> b.com/plugin.swf | 3313 // - Peripheral: a.com -> b.com/plugin.swf |
3305 // - Peripheral: a.com -> b.com/iframe.html -> b.com/plugin.swf | 3314 // - 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 | 3315 // - NOT peripheral: a.com -> b.com/iframe-to-a.html -> a.com/plugin.swf |
3307 | 3316 |
3308 // TODO(alexmos): Update this to use the origin of the RemoteFrame when 426512 | 3317 // 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 | 3318 // is fixed. For now, case 3 in the comment above doesn't work in |
3310 // --site-per-process mode. | 3319 // --site-per-process mode. |
3311 WebFrame* main_frame = render_frame_->GetWebFrame()->view()->mainFrame(); | 3320 WebFrame* main_frame = render_frame_->GetWebFrame()->view()->mainFrame(); |
3312 if (main_frame->isWebRemoteFrame()) | 3321 if (main_frame->isWebRemoteFrame()) |
3313 return true; | 3322 return true; |
3314 | 3323 |
3315 GURL main_frame_url = main_frame->document().url(); | 3324 GURL main_frame_url = main_frame->document().url(); |
3316 return plugin_url_.GetOrigin() != main_frame_url.GetOrigin(); | 3325 return plugin_url_.GetOrigin() != main_frame_url.GetOrigin(); |
3317 } | 3326 } |
3318 | 3327 |
3319 void PepperPluginInstanceImpl::SetPluginThrottled(bool throttled) { | 3328 void PepperPluginInstanceImpl::SetPluginThrottled(bool throttled) { |
3320 // Do not throttle if we've already disabled power saver. | 3329 // Do not throttle if we've already disabled power saver. |
3321 if (!power_saver_enabled_ && throttled) | 3330 if (!power_saver_enabled_ && throttled) |
3322 return; | 3331 return; |
3323 | 3332 |
3324 plugin_throttled_ = throttled; | 3333 plugin_throttled_ = throttled; |
3325 SendDidChangeView(); | 3334 SendDidChangeView(); |
3326 } | 3335 } |
3327 | 3336 |
3328 } // namespace content | 3337 } // namespace content |
OLD | NEW |