Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(834)

Side by Side Diff: content/renderer/pepper/pepper_plugin_instance_impl.cc

Issue 669703003: Plugin Power Saver: Restrict Power Saver to cross-origin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 } 388 }
389 } 389 }
390 390
391 } // namespace 391 } // namespace
392 392
393 // static 393 // static
394 PepperPluginInstanceImpl* PepperPluginInstanceImpl::Create( 394 PepperPluginInstanceImpl* PepperPluginInstanceImpl::Create(
395 RenderFrameImpl* render_frame, 395 RenderFrameImpl* render_frame,
396 PluginModule* module, 396 PluginModule* module,
397 WebPluginContainer* container, 397 WebPluginContainer* container,
398 const GURL& plugin_url) { 398 const GURL& plugin_url,
399 const GURL& top_frame_url) {
399 base::Callback<const void*(const char*)> get_plugin_interface_func = 400 base::Callback<const void*(const char*)> get_plugin_interface_func =
400 base::Bind(&PluginModule::GetPluginInterface, module); 401 base::Bind(&PluginModule::GetPluginInterface, module);
401 PPP_Instance_Combined* ppp_instance_combined = 402 PPP_Instance_Combined* ppp_instance_combined =
402 PPP_Instance_Combined::Create(get_plugin_interface_func); 403 PPP_Instance_Combined::Create(get_plugin_interface_func);
403 if (!ppp_instance_combined) 404 if (!ppp_instance_combined)
404 return NULL; 405 return NULL;
405 406
406 return new PepperPluginInstanceImpl(render_frame, 407 return new PepperPluginInstanceImpl(render_frame,
407 module, 408 module,
408 ppp_instance_combined, 409 ppp_instance_combined,
409 container, 410 container,
410 plugin_url); 411 plugin_url,
412 top_frame_url);
411 } 413 }
412 414
413 PepperPluginInstanceImpl::ExternalDocumentLoader::ExternalDocumentLoader() 415 PepperPluginInstanceImpl::ExternalDocumentLoader::ExternalDocumentLoader()
414 : finished_loading_(false) {} 416 : finished_loading_(false) {}
415 417
416 PepperPluginInstanceImpl::ExternalDocumentLoader::~ExternalDocumentLoader() {} 418 PepperPluginInstanceImpl::ExternalDocumentLoader::~ExternalDocumentLoader() {}
417 419
418 void PepperPluginInstanceImpl::ExternalDocumentLoader::ReplayReceivedData( 420 void PepperPluginInstanceImpl::ExternalDocumentLoader::ReplayReceivedData(
419 WebURLLoaderClient* document_loader) { 421 WebURLLoaderClient* document_loader) {
420 for (std::list<std::string>::iterator it = data_.begin(); it != data_.end(); 422 for (std::list<std::string>::iterator it = data_.begin(); it != data_.end();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 blink::WebGamepads webkit_data; 473 blink::WebGamepads webkit_data;
472 RenderThreadImpl::current()->SampleGamepads(&webkit_data); 474 RenderThreadImpl::current()->SampleGamepads(&webkit_data);
473 ConvertWebKitGamepadData(bit_cast<ppapi::WebKitGamepads>(webkit_data), data); 475 ConvertWebKitGamepadData(bit_cast<ppapi::WebKitGamepads>(webkit_data), data);
474 } 476 }
475 477
476 PepperPluginInstanceImpl::PepperPluginInstanceImpl( 478 PepperPluginInstanceImpl::PepperPluginInstanceImpl(
477 RenderFrameImpl* render_frame, 479 RenderFrameImpl* render_frame,
478 PluginModule* module, 480 PluginModule* module,
479 ppapi::PPP_Instance_Combined* instance_interface, 481 ppapi::PPP_Instance_Combined* instance_interface,
480 WebPluginContainer* container, 482 WebPluginContainer* container,
481 const GURL& plugin_url) 483 const GURL& plugin_url,
484 const GURL& top_frame_url)
482 : RenderFrameObserver(render_frame), 485 : RenderFrameObserver(render_frame),
483 render_frame_(render_frame), 486 render_frame_(render_frame),
484 module_(module), 487 module_(module),
485 instance_interface_(instance_interface), 488 instance_interface_(instance_interface),
486 pp_instance_(0), 489 pp_instance_(0),
487 container_(container), 490 container_(container),
488 layer_bound_to_fullscreen_(false), 491 layer_bound_to_fullscreen_(false),
489 layer_is_hardware_(false), 492 layer_is_hardware_(false),
490 plugin_url_(plugin_url), 493 plugin_url_(plugin_url),
491 power_saver_enabled_(false), 494 power_saver_enabled_(false),
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 } 580 }
578 581
579 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host(); 582 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host();
580 resource_creation_ = host_impl->CreateInProcessResourceCreationAPI(this); 583 resource_creation_ = host_impl->CreateInProcessResourceCreationAPI(this);
581 584
582 if (GetContentClient()->renderer() && // NULL in unit tests. 585 if (GetContentClient()->renderer() && // NULL in unit tests.
583 GetContentClient()->renderer()->IsExternalPepperPlugin(module->name())) 586 GetContentClient()->renderer()->IsExternalPepperPlugin(module->name()))
584 external_document_load_ = true; 587 external_document_load_ = true;
585 588
586 // TODO(tommycli): Insert heuristics to determine whether plugin content 589 // TODO(tommycli): Insert heuristics to determine whether plugin content
587 // is peripheral here. 590 // is peripheral here.
groby-ooo-7-16 2014/10/23 00:17:21 I think now would be a good time to add a heuristi
raymes 2014/10/23 00:21:28 Yes, please pull all this out into a function :)
tommycli 2014/10/23 00:46:12 Done.
tommycli 2014/10/23 00:46:12 Done.
588 bool is_peripheral_content = true; 591 bool is_peripheral_content = true;
589 power_saver_enabled_ = is_peripheral_content && 592 power_saver_enabled_ = is_peripheral_content &&
590 module->name() == kFlashPluginName && 593 module->name() == kFlashPluginName &&
591 CommandLine::ForCurrentProcess()->HasSwitch( 594 CommandLine::ForCurrentProcess()->HasSwitch(
592 switches::kEnablePluginPowerSaver); 595 switches::kEnablePluginPowerSaver);
593 596
594 if (power_saver_enabled_) { 597 if (power_saver_enabled_ &&
598 plugin_url.GetOrigin() != top_frame_url.GetOrigin()) {
595 throttler_.reset(new PepperPluginInstanceThrottler( 599 throttler_.reset(new PepperPluginInstanceThrottler(
596 base::Bind(&PepperPluginInstanceImpl::SetPluginThrottled, 600 base::Bind(&PepperPluginInstanceImpl::SetPluginThrottled,
597 weak_factory_.GetWeakPtr(), true /* throttled */))); 601 weak_factory_.GetWeakPtr(), true /* throttled */)));
598 } 602 }
599 } 603 }
600 604
601 PepperPluginInstanceImpl::~PepperPluginInstanceImpl() { 605 PepperPluginInstanceImpl::~PepperPluginInstanceImpl() {
602 DCHECK(!fullscreen_container_); 606 DCHECK(!fullscreen_container_);
603 607
604 // Notify all the plugin objects of deletion. This will prevent blink from 608 // Notify all the plugin objects of deletion. This will prevent blink from
(...skipping 2697 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698