OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_RENDERER_PEPPER_PLUGIN_POWER_SAVER_HELPER_H_ | |
6 #define CONTENT_RENDERER_PEPPER_PLUGIN_POWER_SAVER_HELPER_H_ | |
7 | |
8 #include <set> | |
9 #include <vector> | |
10 | |
11 #include "base/callback.h" | |
Lei Zhang
2014/10/29 09:26:47
You can use callback_forward.h
tommycli
2014/10/29 19:59:23
Done.
| |
12 #include "content/public/renderer/render_frame_observer.h" | |
13 #include "url/gurl.h" | |
14 | |
15 namespace content { | |
16 | |
17 // PluginPowerSaverWhitelist manages the plugin content origin whitelist for | |
18 // a single render frame. | |
19 class PluginPowerSaverHelper : public RenderFrameObserver { | |
20 public: | |
21 explicit PluginPowerSaverHelper(RenderFrame* render_frame); | |
22 virtual ~PluginPowerSaverHelper(); | |
23 | |
24 // Returns true if this plugin should have power saver enabled. | |
25 // | |
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. | |
28 // | |
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: | |
31 // - Cross-origin: a.com -> 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 | |
34 // | |
35 // A plugin may be exempted from power saver by a temporary whitelist. | |
36 // |unthrottle| may be called if this function returns true, but the | |
37 // plugin origin is later whitelisted ex post facto. | |
38 bool ShouldThrottleContent(const GURL& plugin_url, | |
39 int width, | |
40 int height, | |
41 const base::Closure& unthrottle); | |
42 | |
43 private: | |
44 struct PeripheralPlugin { | |
45 PeripheralPlugin(const GURL& content_origin, | |
46 const base::Closure& unthrottle); | |
47 ~PeripheralPlugin(); | |
Lei Zhang
2014/10/29 09:26:47
nit: blank line afterwards
tommycli
2014/10/29 19:59:23
Done.
| |
48 GURL content_origin; | |
49 base::Closure unthrottle; | |
Lei Zhang
2014/10/29 09:26:47
unthrottle_callback ?
tommycli
2014/10/29 19:59:23
Done.
| |
50 }; | |
51 | |
52 // RenderFrameObserver implementation. | |
53 bool OnMessageReceived(const IPC::Message& message) override; | |
54 | |
55 void OnUpdatePluginContentOriginWhitelist( | |
56 const std::set<GURL>& origin_whitelist); | |
57 | |
58 // Local copy of the whitelist for the entire tab. | |
59 std::set<GURL> origin_whitelist_; | |
60 | |
61 // Set of peripheral plugins eligible to be unthrottled ex post facto. | |
62 std::vector<PeripheralPlugin> peripheral_plugins_; | |
63 | |
64 DISALLOW_COPY_AND_ASSIGN(PluginPowerSaverHelper); | |
65 }; | |
66 | |
67 } // namespace content | |
68 | |
69 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_POWER_SAVER_HELPER_H_ | |
OLD | NEW |