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

Unified Diff: components/plugins/renderer/loadable_plugin_placeholder.cc

Issue 1522173002: Reland: Plugin Power Saver: Improve Poster behavior for essential plugins. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix an NPE crash/race on plugin destruction Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/plugins/power_saver_info.cc ('k') | content/public/renderer/render_frame.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/plugins/renderer/loadable_plugin_placeholder.cc
diff --git a/components/plugins/renderer/loadable_plugin_placeholder.cc b/components/plugins/renderer/loadable_plugin_placeholder.cc
index a47d910835c1910d986355816e16e37979b36602..2ec56a3c2d9c199dc0774393b083f40fb65697b7 100644
--- a/components/plugins/renderer/loadable_plugin_placeholder.cc
+++ b/components/plugins/renderer/loadable_plugin_placeholder.cc
@@ -270,6 +270,13 @@ void LoadablePluginPlaceholder::DidFinishLoadingCallback() {
// This is necessary to prevent a flicker.
if (premade_throttler_ && power_saver_enabled_)
premade_throttler_->SetHiddenForPlaceholder(true /* hidden */);
+
+ // In case our initial geometry was reported before the placeholder finished
+ // loading, request another one. Needed for correct large poster unthrottling.
+ if (plugin()) {
+ CHECK(plugin()->container());
tommycli 2015/12/14 21:17:55 The plugin / container semantics are kind-of under
+ plugin()->container()->reportGeometry();
+ }
}
void LoadablePluginPlaceholder::DidFinishIconRepositionForTestingCallback() {
@@ -347,17 +354,20 @@ void LoadablePluginPlaceholder::RecheckSizeAndMaybeUnthrottle() {
// On a size update check if we now qualify as a essential plugin.
url::Origin content_origin = url::Origin(GetPluginParams().url);
- bool cross_origin_main_content = false;
- if (!render_frame()->ShouldThrottleContent(
- render_frame()->GetWebFrame()->top()->securityOrigin(),
- content_origin, width, height, &cross_origin_main_content)) {
+ auto status = render_frame()->GetPeripheralContentStatus(
+ render_frame()->GetWebFrame()->top()->securityOrigin(), content_origin,
+ gfx::Size(width, height));
+ if (status != content::RenderFrame::CONTENT_STATUS_PERIPHERAL) {
MarkPluginEssential(
heuristic_run_before_
? PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_SIZE_CHANGE
: PluginInstanceThrottler::UNTHROTTLE_METHOD_DO_NOT_RECORD);
- if (cross_origin_main_content && !heuristic_run_before_)
+ if (!heuristic_run_before_ &&
+ status ==
+ content::RenderFrame::CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_BIG) {
render_frame()->WhitelistContentOrigin(content_origin);
+ }
}
heuristic_run_before_ = true;
« no previous file with comments | « chrome/renderer/plugins/power_saver_info.cc ('k') | content/public/renderer/render_frame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698