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

Side by Side Diff: content/renderer/pepper/plugin_power_saver_helper.h

Issue 904913003: Plugin Power Saver: Fix implicitly sized and below the fold plugins. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef CONTENT_RENDERER_PEPPER_PLUGIN_POWER_SAVER_HELPER_H_ 5 #ifndef CONTENT_RENDERER_PEPPER_PLUGIN_POWER_SAVER_HELPER_H_
6 #define CONTENT_RENDERER_PEPPER_PLUGIN_POWER_SAVER_HELPER_H_ 6 #define CONTENT_RENDERER_PEPPER_PLUGIN_POWER_SAVER_HELPER_H_
7 7
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "content/common/content_export.h" 12 #include "content/common/content_export.h"
13 #include "content/public/renderer/render_frame_observer.h" 13 #include "content/public/renderer/render_frame_observer.h"
14 #include "url/gurl.h" 14 #include "url/gurl.h"
15 15
16 namespace blink { 16 namespace blink {
17 struct WebPluginParams; 17 struct WebPluginParams;
18 struct WebRect;
18 } 19 }
19 20
20 namespace content { 21 namespace content {
21 22
22 class CONTENT_EXPORT PluginPowerSaverHelper : public RenderFrameObserver { 23 class CONTENT_EXPORT PluginPowerSaverHelper : public RenderFrameObserver {
23 public: 24 public:
24 explicit PluginPowerSaverHelper(RenderFrame* render_frame); 25 explicit PluginPowerSaverHelper(RenderFrame* render_frame);
25 ~PluginPowerSaverHelper() override; 26 ~PluginPowerSaverHelper() override;
26 27
27 // See RenderFrame for documentation. 28 // See RenderFrame for documentation.
28 void RegisterPeripheralPlugin(const GURL& content_origin, 29 void RegisterPeripheralPlugin(const GURL& content_origin,
29 const base::Closure& unthrottle_callback); 30 const base::Closure& unthrottle_callback);
30 bool ShouldThrottleContent(const blink::WebPluginParams& params, 31
31 const GURL& plugin_frame_url, 32 // Returns true if this plugin should have power saver enabled.
32 GURL* poster_image, 33 //
34 // Power Saver is enabled for plugin content that are cross-origin and
35 // heuristically determined to be not essential to the web page content.
36 //
37 // Plugin content is defined to be cross-origin when the plugin source's
38 // origin differs from the top level frame's origin. For example:
39 // - Cross-origin: a.com -> b.com/plugin.swf
40 // - Cross-origin: a.com -> b.com/iframe.html -> b.com/plugin.swf
41 // - Same-origin: a.com -> b.com/iframe-to-a.html -> a.com/plugin.swf
42 //
43 // |page_frame_url| is the URL of the frame containing the plugin, which may
44 // be different from the URL of the top level document.
45 //
46 // |poster_image| may be NULL. It is set to the absolute URL of the poster
47 // image if it exists and this method returns true. Otherwise, an empty GURL.
48 //
49 // |cross_origin_main_content| may be NULL. It is set to true if the
50 // plugin content is cross-origin but still the "main attraction" of the page.
51 bool ShouldThrottleContent(const GURL& content_origin,
52 const std::string& plugin_module_name,
53 int width,
54 int height,
33 bool* cross_origin_main_content) const; 55 bool* cross_origin_main_content) const;
56
57 // Whitelists a |content_origin| so its content will never be throttled in
58 // this RenderFrame. Whitelist is cleared by top level navigation.
34 void WhitelistContentOrigin(const GURL& content_origin); 59 void WhitelistContentOrigin(const GURL& content_origin);
35 60
36 private: 61 private:
37 struct PeripheralPlugin { 62 struct PeripheralPlugin {
38 PeripheralPlugin(const GURL& content_origin, 63 PeripheralPlugin(const GURL& content_origin,
39 const base::Closure& unthrottle_callback); 64 const base::Closure& unthrottle_callback);
40 ~PeripheralPlugin(); 65 ~PeripheralPlugin();
41 66
42 GURL content_origin; 67 GURL content_origin;
43 base::Closure unthrottle_callback; 68 base::Closure unthrottle_callback;
(...skipping 11 matching lines...) Expand all
55 80
56 // Set of peripheral plugins eligible to be unthrottled ex post facto. 81 // Set of peripheral plugins eligible to be unthrottled ex post facto.
57 std::vector<PeripheralPlugin> peripheral_plugins_; 82 std::vector<PeripheralPlugin> peripheral_plugins_;
58 83
59 DISALLOW_COPY_AND_ASSIGN(PluginPowerSaverHelper); 84 DISALLOW_COPY_AND_ASSIGN(PluginPowerSaverHelper);
60 }; 85 };
61 86
62 } // namespace content 87 } // namespace content
63 88
64 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_POWER_SAVER_HELPER_H_ 89 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_POWER_SAVER_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698