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

Side by Side Diff: components/plugins/renderer/loadable_plugin_placeholder.cc

Issue 1497623002: Plugin Power Saver: Improve Poster behavior for essential plugins. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/plugins/renderer/loadable_plugin_placeholder.h" 5 #include "components/plugins/renderer/loadable_plugin_placeholder.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/json/string_escape.h" 10 #include "base/json/string_escape.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 263
264 void LoadablePluginPlaceholder::DidFinishLoadingCallback() { 264 void LoadablePluginPlaceholder::DidFinishLoadingCallback() {
265 finished_loading_ = true; 265 finished_loading_ = true;
266 if (message_.length() > 0) 266 if (message_.length() > 0)
267 UpdateMessage(); 267 UpdateMessage();
268 268
269 // Wait for the placeholder to finish loading to hide the premade plugin. 269 // Wait for the placeholder to finish loading to hide the premade plugin.
270 // This is necessary to prevent a flicker. 270 // This is necessary to prevent a flicker.
271 if (premade_throttler_ && power_saver_enabled_) 271 if (premade_throttler_ && power_saver_enabled_)
272 premade_throttler_->SetHiddenForPlaceholder(true /* hidden */); 272 premade_throttler_->SetHiddenForPlaceholder(true /* hidden */);
273
274 // In case our initial geometry was reported before the placeholder finished
275 // loading, request another one. Needed for correct large poster unthrottling.
276 plugin()->container()->reportGeometry();
273 } 277 }
274 278
275 void LoadablePluginPlaceholder::DidFinishIconRepositionForTestingCallback() { 279 void LoadablePluginPlaceholder::DidFinishIconRepositionForTestingCallback() {
276 // Set an attribute and post an event, so browser tests can wait for the 280 // Set an attribute and post an event, so browser tests can wait for the
277 // placeholder to be ready to receive simulated user input. 281 // placeholder to be ready to receive simulated user input.
278 blink::WebElement element = plugin()->container()->element(); 282 blink::WebElement element = plugin()->container()->element();
279 element.setAttribute("placeholderReady", "true"); 283 element.setAttribute("placeholderReady", "true");
280 284
281 scoped_ptr<content::V8ValueConverter> converter( 285 scoped_ptr<content::V8ValueConverter> converter(
282 content::V8ValueConverter::create()); 286 content::V8ValueConverter::create());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 int x = roundf(unobscured_rect_.x() / zoom_factor); 344 int x = roundf(unobscured_rect_.x() / zoom_factor);
341 int y = roundf(unobscured_rect_.y() / zoom_factor); 345 int y = roundf(unobscured_rect_.y() / zoom_factor);
342 std::string script = base::StringPrintf( 346 std::string script = base::StringPrintf(
343 "window.resizePoster('%dpx', '%dpx', '%dpx', '%dpx')", x, y, width, 347 "window.resizePoster('%dpx', '%dpx', '%dpx', '%dpx')", x, y, width,
344 height); 348 height);
345 plugin()->web_view()->mainFrame()->executeScript( 349 plugin()->web_view()->mainFrame()->executeScript(
346 blink::WebScriptSource(base::UTF8ToUTF16(script))); 350 blink::WebScriptSource(base::UTF8ToUTF16(script)));
347 351
348 // On a size update check if we now qualify as a essential plugin. 352 // On a size update check if we now qualify as a essential plugin.
349 url::Origin content_origin = url::Origin(GetPluginParams().url); 353 url::Origin content_origin = url::Origin(GetPluginParams().url);
350 bool cross_origin_main_content = false; 354 auto status = render_frame()->GetPeripheralContentStatus(
351 if (!render_frame()->ShouldThrottleContent( 355 render_frame()->GetWebFrame()->top()->securityOrigin(), content_origin,
352 render_frame()->GetWebFrame()->top()->securityOrigin(), 356 gfx::Size(width, height));
353 content_origin, width, height, &cross_origin_main_content)) { 357 if (status != content::RenderFrame::CONTENT_STATUS_PERIPHERAL) {
354 MarkPluginEssential( 358 MarkPluginEssential(
355 heuristic_run_before_ 359 heuristic_run_before_
356 ? PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_SIZE_CHANGE 360 ? PluginInstanceThrottler::UNTHROTTLE_METHOD_BY_SIZE_CHANGE
357 : PluginInstanceThrottler::UNTHROTTLE_METHOD_DO_NOT_RECORD); 361 : PluginInstanceThrottler::UNTHROTTLE_METHOD_DO_NOT_RECORD);
358 362
359 if (cross_origin_main_content && !heuristic_run_before_) 363 if (!heuristic_run_before_ &&
364 status ==
365 content::RenderFrame::CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_BIG) {
360 render_frame()->WhitelistContentOrigin(content_origin); 366 render_frame()->WhitelistContentOrigin(content_origin);
367 }
361 } 368 }
362 369
363 heuristic_run_before_ = true; 370 heuristic_run_before_ = true;
364 } 371 }
365 } 372 }
366 373
367 } // namespace plugins 374 } // namespace plugins
OLDNEW
« 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