Index: content/renderer/pepper/plugin_power_saver_helper.h |
diff --git a/content/renderer/pepper/plugin_power_saver_helper.h b/content/renderer/pepper/plugin_power_saver_helper.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7b2956460dfc0738edf5b507ba083b4d05749e2e |
--- /dev/null |
+++ b/content/renderer/pepper/plugin_power_saver_helper.h |
@@ -0,0 +1,69 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_RENDERER_PEPPER_PLUGIN_POWER_SAVER_HELPER_H_ |
+#define CONTENT_RENDERER_PEPPER_PLUGIN_POWER_SAVER_HELPER_H_ |
+ |
+#include <set> |
+#include <vector> |
+ |
+#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.
|
+#include "content/public/renderer/render_frame_observer.h" |
+#include "url/gurl.h" |
+ |
+namespace content { |
+ |
+// PluginPowerSaverWhitelist manages the plugin content origin whitelist for |
+// a single render frame. |
+class PluginPowerSaverHelper : public RenderFrameObserver { |
+ public: |
+ explicit PluginPowerSaverHelper(RenderFrame* render_frame); |
+ virtual ~PluginPowerSaverHelper(); |
+ |
+ // Returns true if this plugin should have power saver enabled. |
+ // |
+ // Power Saver is enabled for plugin content that are cross-origin and |
+ // heuristically determined to be not the "main attraction" of the webpage. |
+ // |
+ // Plugin content is defined to be cross-origin when the plugin source's |
+ // origin differs from the top level frame's origin. For example: |
+ // - Cross-origin: a.com -> b.com/plugin.swf |
+ // - Cross-origin: a.com -> b.com/iframe.html -> b.com/plugin.swf |
+ // - Same-origin: a.com -> b.com/iframe-to-a.html -> a.com/plugin.swf |
+ // |
+ // A plugin may be exempted from power saver by a temporary whitelist. |
+ // |unthrottle| may be called if this function returns true, but the |
+ // plugin origin is later whitelisted ex post facto. |
+ bool ShouldThrottleContent(const GURL& plugin_url, |
+ int width, |
+ int height, |
+ const base::Closure& unthrottle); |
+ |
+ private: |
+ struct PeripheralPlugin { |
+ PeripheralPlugin(const GURL& content_origin, |
+ const base::Closure& unthrottle); |
+ ~PeripheralPlugin(); |
Lei Zhang
2014/10/29 09:26:47
nit: blank line afterwards
tommycli
2014/10/29 19:59:23
Done.
|
+ GURL content_origin; |
+ base::Closure unthrottle; |
Lei Zhang
2014/10/29 09:26:47
unthrottle_callback ?
tommycli
2014/10/29 19:59:23
Done.
|
+ }; |
+ |
+ // RenderFrameObserver implementation. |
+ bool OnMessageReceived(const IPC::Message& message) override; |
+ |
+ void OnUpdatePluginContentOriginWhitelist( |
+ const std::set<GURL>& origin_whitelist); |
+ |
+ // Local copy of the whitelist for the entire tab. |
+ std::set<GURL> origin_whitelist_; |
+ |
+ // Set of peripheral plugins eligible to be unthrottled ex post facto. |
+ std::vector<PeripheralPlugin> peripheral_plugins_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PluginPowerSaverHelper); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_RENDERER_PEPPER_PLUGIN_POWER_SAVER_HELPER_H_ |