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

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

Issue 1341563002: Plugin Power Saver: Improve origin handling esp. with OOPIF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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/origin.h"
15 15
16 namespace blink { 16 namespace blink {
17 struct WebPluginParams; 17 struct WebPluginParams;
18 struct WebRect; 18 struct WebRect;
19 } 19 }
20 20
21 namespace content { 21 namespace content {
22 22
23 class CONTENT_EXPORT PluginPowerSaverHelper : public RenderFrameObserver { 23 class CONTENT_EXPORT PluginPowerSaverHelper : public RenderFrameObserver {
24 public: 24 public:
25 explicit PluginPowerSaverHelper(RenderFrame* render_frame); 25 explicit PluginPowerSaverHelper(RenderFrame* render_frame);
26 ~PluginPowerSaverHelper() override; 26 ~PluginPowerSaverHelper() override;
27 27
28 // See RenderFrame for documentation. 28 // See RenderFrame for documentation.
29 void RegisterPeripheralPlugin(const GURL& content_origin, 29 void RegisterPeripheralPlugin(const url::Origin& content_origin,
30 const base::Closure& unthrottle_callback); 30 const base::Closure& unthrottle_callback);
31 31
32 // Returns true if this plugin should have power saver enabled. 32 // Returns true if this plugin should have power saver enabled.
33 // 33 //
34 // Power Saver is enabled for plugin content that are cross-origin and 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. 35 // heuristically determined to be not essential to the web page content.
36 // 36 //
37 // Plugin content is defined to be cross-origin when the plugin source's 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: 38 // origin differs from the top level frame's origin. For example:
39 // - Cross-origin: a.com -> b.com/plugin.swf 39 // - Cross-origin: a.com -> b.com/plugin.swf
40 // - Cross-origin: a.com -> b.com/iframe.html -> 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 41 // - Same-origin: a.com -> b.com/iframe-to-a.html -> a.com/plugin.swf
42 // 42 //
43 // |content_origin| is the origin of the plugin content. 43 // |content_origin| is the origin of the plugin content.
44 // 44 //
45 // |width| and |height| are zoom and device scale independent logical pixels. 45 // |width| and |height| are zoom and device scale independent logical pixels.
46 // 46 //
47 // |cross_origin_main_content| may be NULL. It is set to true if the 47 // |cross_origin_main_content| may be NULL. It is set to true if the
48 // plugin content is cross-origin but still the "main attraction" of the page. 48 // plugin content is cross-origin but still the "main attraction" of the page.
49 bool ShouldThrottleContent(const GURL& content_origin, 49 bool ShouldThrottleContent(const url::Origin& content_origin,
50 const std::string& plugin_module_name, 50 const std::string& plugin_module_name,
51 int width, 51 int width,
52 int height, 52 int height,
53 bool* cross_origin_main_content) const; 53 bool* cross_origin_main_content) const;
54 54
55 // Whitelists a |content_origin| so its content will never be throttled in 55 // Whitelists a |content_origin| so its content will never be throttled in
56 // this RenderFrame. Whitelist is cleared by top level navigation. 56 // this RenderFrame. Whitelist is cleared by top level navigation.
57 void WhitelistContentOrigin(const GURL& content_origin); 57 void WhitelistContentOrigin(const url::Origin& content_origin);
58 58
59 private: 59 private:
60 struct PeripheralPlugin { 60 struct PeripheralPlugin {
61 PeripheralPlugin(const GURL& content_origin, 61 PeripheralPlugin(const url::Origin& content_origin,
62 const base::Closure& unthrottle_callback); 62 const base::Closure& unthrottle_callback);
63 ~PeripheralPlugin(); 63 ~PeripheralPlugin();
64 64
65 GURL content_origin; 65 url::Origin content_origin;
66 base::Closure unthrottle_callback; 66 base::Closure unthrottle_callback;
67 }; 67 };
68 68
69 enum OverrideForTesting { 69 enum OverrideForTesting {
70 Normal, 70 Normal,
71 Never, 71 Never,
72 IgnoreList, 72 IgnoreList,
73 Always 73 Always
74 }; 74 };
75 75
76 // RenderFrameObserver implementation. 76 // RenderFrameObserver implementation.
77 void DidCommitProvisionalLoad(bool is_new_navigation, 77 void DidCommitProvisionalLoad(bool is_new_navigation,
78 bool is_same_page_navigation) override; 78 bool is_same_page_navigation) override;
79 bool OnMessageReceived(const IPC::Message& message) override; 79 bool OnMessageReceived(const IPC::Message& message) override;
80 80
81 void OnUpdatePluginContentOriginWhitelist( 81 void OnUpdatePluginContentOriginWhitelist(
82 const std::set<GURL>& origin_whitelist); 82 const std::set<url::Origin>& origin_whitelist);
83 83
84 OverrideForTesting override_for_testing_; 84 OverrideForTesting override_for_testing_;
85 85
86 // Local copy of the whitelist for the entire tab. 86 // Local copy of the whitelist for the entire tab.
87 std::set<GURL> origin_whitelist_; 87 std::set<url::Origin> origin_whitelist_;
88 88
89 // Set of peripheral plugins eligible to be unthrottled ex post facto. 89 // Set of peripheral plugins eligible to be unthrottled ex post facto.
90 std::vector<PeripheralPlugin> peripheral_plugins_; 90 std::vector<PeripheralPlugin> peripheral_plugins_;
91 91
92 DISALLOW_COPY_AND_ASSIGN(PluginPowerSaverHelper); 92 DISALLOW_COPY_AND_ASSIGN(PluginPowerSaverHelper);
93 }; 93 };
94 94
95 } // namespace content 95 } // namespace content
96 96
97 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_POWER_SAVER_HELPER_H_ 97 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_POWER_SAVER_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698