OLD | NEW |
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 |
(...skipping 15 matching lines...) Expand all Loading... |
26 // Power Saver is enabled for plugin content that are cross-origin and | 26 // Power Saver is enabled for plugin content that are cross-origin and |
27 // heuristically determined to be not the "main attraction" of the webpage. | 27 // heuristically determined to be not the "main attraction" of the webpage. |
28 // | 28 // |
29 // Plugin content is defined to be cross-origin when the plugin source's | 29 // Plugin content is defined to be cross-origin when the plugin source's |
30 // origin differs from the top level frame's origin. For example: | 30 // origin differs from the top level frame's origin. For example: |
31 // - Cross-origin: a.com -> b.com/plugin.swf | 31 // - Cross-origin: a.com -> b.com/plugin.swf |
32 // - Cross-origin: a.com -> b.com/iframe.html -> b.com/plugin.swf | 32 // - Cross-origin: a.com -> b.com/iframe.html -> b.com/plugin.swf |
33 // - Same-origin: a.com -> b.com/iframe-to-a.html -> a.com/plugin.swf | 33 // - Same-origin: a.com -> b.com/iframe-to-a.html -> a.com/plugin.swf |
34 // | 34 // |
35 // |cross_origin| may not be NULL. | 35 // |cross_origin| may not be NULL. |
36 bool ShouldThrottleContent(const GURL& content_origin, | 36 virtual bool ShouldThrottleContent(const GURL& content_origin, |
37 int width, | 37 int width, |
38 int height, | 38 int height, |
39 bool* cross_origin) const; | 39 bool* cross_origin) const; |
40 | 40 |
41 // Registers a plugin that has been marked peripheral. If the origin | 41 // Registers a plugin that has been marked peripheral. If the origin |
42 // whitelist is later updated and includes |content_origin|, then | 42 // whitelist is later updated and includes |content_origin|, then |
43 // |unthrottle_callback| will be called. | 43 // |unthrottle_callback| will be called. |
44 void RegisterPeripheralPlugin(const GURL& content_origin, | 44 virtual void RegisterPeripheralPlugin( |
45 const base::Closure& unthrottle_callback); | 45 const GURL& content_origin, |
| 46 const base::Closure& unthrottle_callback); |
46 | 47 |
47 void WhitelistContentOrigin(const GURL& content_origin); | 48 virtual void WhitelistContentOrigin(const GURL& content_origin); |
48 | 49 |
49 private: | 50 private: |
50 struct PeripheralPlugin { | 51 struct PeripheralPlugin { |
51 PeripheralPlugin(const GURL& content_origin, | 52 PeripheralPlugin(const GURL& content_origin, |
52 const base::Closure& unthrottle_callback); | 53 const base::Closure& unthrottle_callback); |
53 ~PeripheralPlugin(); | 54 ~PeripheralPlugin(); |
54 | 55 |
55 GURL content_origin; | 56 GURL content_origin; |
56 base::Closure unthrottle_callback; | 57 base::Closure unthrottle_callback; |
57 }; | 58 }; |
(...skipping 10 matching lines...) Expand all Loading... |
68 | 69 |
69 // Set of peripheral plugins eligible to be unthrottled ex post facto. | 70 // Set of peripheral plugins eligible to be unthrottled ex post facto. |
70 std::vector<PeripheralPlugin> peripheral_plugins_; | 71 std::vector<PeripheralPlugin> peripheral_plugins_; |
71 | 72 |
72 DISALLOW_COPY_AND_ASSIGN(PluginPowerSaverHelper); | 73 DISALLOW_COPY_AND_ASSIGN(PluginPowerSaverHelper); |
73 }; | 74 }; |
74 | 75 |
75 } // namespace content | 76 } // namespace content |
76 | 77 |
77 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_POWER_SAVER_HELPER_H_ | 78 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_POWER_SAVER_HELPER_H_ |
OLD | NEW |