From 9c7cbd939c735a69c551cfbf397f6cf707f8d22e Mon Sep 17 00:00:00 2001 From: tommycli Date: Fri, 18 Dec 2015 15:34:34 -0800 Subject: Reland: Plugin Power Saver: Improve Poster behavior for essential plugins. Reland of https://codereview.chromium.org/1497623002/ TBR= BUG=560590,569198 Review URL: https://codereview.chromium.org/1522173002 Cr-Commit-Position: refs/heads/master@{#366210} --- content/public/renderer/render_frame.h | 35 ++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'content/public/renderer') diff --git a/content/public/renderer/render_frame.h b/content/public/renderer/render_frame.h index 2011c4e..dc055ef 100644 --- a/content/public/renderer/render_frame.h +++ b/content/public/renderer/render_frame.h @@ -29,6 +29,7 @@ struct WebPluginParams; namespace gfx { class Range; +class Size; } namespace url { @@ -56,6 +57,24 @@ struct WebPreferences; class CONTENT_EXPORT RenderFrame : public IPC::Listener, public IPC::Sender { public: + // These numeric values are used in UMA logs; do not change them. + enum PeripheralContentStatus { + // Content is peripheral because it doesn't meet any of the below criteria. + CONTENT_STATUS_PERIPHERAL = 0, + // Content is essential because it's same-origin with the top-level frame. + CONTENT_STATUS_ESSENTIAL_SAME_ORIGIN = 1, + // Content is essential even though it's cross-origin, because it's large. + CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_BIG = 2, + // Content is essential because there's large content from the same origin. + CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_WHITELISTED = 3, + // Content is essential because it's tiny in size. + CONTENT_STATUS_ESSENTIAL_CROSS_ORIGIN_TINY = 4, + // Content is essential because it has an unknown size. + CONTENT_STATUS_ESSENTIAL_UNKNOWN_SIZE = 5, + // Must be last. + CONTENT_STATUS_NUM_ITEMS + }; + // Returns the RenderFrame given a WebFrame. static RenderFrame* FromWebFrame(blink::WebFrame* web_frame); @@ -131,7 +150,7 @@ class CONTENT_EXPORT RenderFrame : public IPC::Listener, const url::Origin& content_origin, const base::Closure& unthrottle_callback) = 0; - // Returns true if this plugin should have power saver enabled. + // Returns the peripheral content heuristic decision. // // Power Saver is enabled for plugin content that are cross-origin and // heuristically determined to be not essential to the web page content. @@ -146,15 +165,11 @@ class CONTENT_EXPORT RenderFrame : public IPC::Listener, // // |content_origin| is the origin of the plugin content. // - // |width| and |height| are zoom and device scale independent logical pixels. - // - // |cross_origin_main_content| may be NULL. It is set to true if the - // plugin content is cross-origin but still the "main attraction" of the page. - virtual bool ShouldThrottleContent(const url::Origin& main_frame_origin, - const url::Origin& content_origin, - int width, - int height, - bool* cross_origin_main_content) const = 0; + // |unobscured_size| are zoom and device scale independent logical pixels. + virtual PeripheralContentStatus GetPeripheralContentStatus( + const url::Origin& main_frame_origin, + const url::Origin& content_origin, + const gfx::Size& unobscured_size) const = 0; // Whitelists a |content_origin| so its content will never be throttled in // this RenderFrame. Whitelist is cleared by top level navigation. -- cgit v1.1