| 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 |
| 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.h" |
| 13 #include "content/public/renderer/render_frame_observer.h" | 14 #include "content/public/renderer/render_frame_observer.h" |
| 14 #include "url/origin.h" | 15 #include "url/origin.h" |
| 15 | 16 |
| 16 namespace blink { | 17 namespace blink { |
| 17 struct WebPluginParams; | 18 struct WebPluginParams; |
| 18 struct WebRect; | 19 struct WebRect; |
| 19 } | 20 } |
| 20 | 21 |
| 22 namespace gfx { |
| 23 class Size; |
| 24 } |
| 25 |
| 21 namespace content { | 26 namespace content { |
| 22 | 27 |
| 23 class CONTENT_EXPORT PluginPowerSaverHelper : public RenderFrameObserver { | 28 class CONTENT_EXPORT PluginPowerSaverHelper : public RenderFrameObserver { |
| 24 public: | 29 public: |
| 25 explicit PluginPowerSaverHelper(RenderFrame* render_frame); | 30 explicit PluginPowerSaverHelper(RenderFrame* render_frame); |
| 26 ~PluginPowerSaverHelper() override; | 31 ~PluginPowerSaverHelper() override; |
| 27 | 32 |
| 28 private: | 33 private: |
| 29 friend class RenderFrameImpl; | 34 friend class RenderFrameImpl; |
| 30 | 35 |
| 31 struct PeripheralPlugin { | 36 struct PeripheralPlugin { |
| 32 PeripheralPlugin(const url::Origin& content_origin, | 37 PeripheralPlugin(const url::Origin& content_origin, |
| 33 const base::Closure& unthrottle_callback); | 38 const base::Closure& unthrottle_callback); |
| 34 ~PeripheralPlugin(); | 39 ~PeripheralPlugin(); |
| 35 | 40 |
| 36 url::Origin content_origin; | 41 url::Origin content_origin; |
| 37 base::Closure unthrottle_callback; | 42 base::Closure unthrottle_callback; |
| 38 }; | 43 }; |
| 39 | 44 |
| 40 // See RenderFrame for documentation. | 45 // See RenderFrame for documentation. |
| 41 void RegisterPeripheralPlugin(const url::Origin& content_origin, | 46 void RegisterPeripheralPlugin(const url::Origin& content_origin, |
| 42 const base::Closure& unthrottle_callback); | 47 const base::Closure& unthrottle_callback); |
| 43 bool ShouldThrottleContent(const url::Origin& main_frame_origin, | 48 RenderFrame::PeripheralContentStatus GetPeripheralContentStatus( |
| 44 const url::Origin& content_origin, | 49 const url::Origin& main_frame_origin, |
| 45 int width, | 50 const url::Origin& content_origin, |
| 46 int height, | 51 const gfx::Size& unobscured_size) const; |
| 47 bool* cross_origin_main_content) const; | |
| 48 void WhitelistContentOrigin(const url::Origin& content_origin); | 52 void WhitelistContentOrigin(const url::Origin& content_origin); |
| 49 | 53 |
| 50 // RenderFrameObserver implementation. | 54 // RenderFrameObserver implementation. |
| 51 void DidCommitProvisionalLoad(bool is_new_navigation, | 55 void DidCommitProvisionalLoad(bool is_new_navigation, |
| 52 bool is_same_page_navigation) override; | 56 bool is_same_page_navigation) override; |
| 53 bool OnMessageReceived(const IPC::Message& message) override; | 57 bool OnMessageReceived(const IPC::Message& message) override; |
| 54 | 58 |
| 55 void OnUpdatePluginContentOriginWhitelist( | 59 void OnUpdatePluginContentOriginWhitelist( |
| 56 const std::set<url::Origin>& origin_whitelist); | 60 const std::set<url::Origin>& origin_whitelist); |
| 57 | 61 |
| 58 // Local copy of the whitelist for the entire tab. | 62 // Local copy of the whitelist for the entire tab. |
| 59 std::set<url::Origin> origin_whitelist_; | 63 std::set<url::Origin> origin_whitelist_; |
| 60 | 64 |
| 61 // Set of peripheral plugins eligible to be unthrottled ex post facto. | 65 // Set of peripheral plugins eligible to be unthrottled ex post facto. |
| 62 std::vector<PeripheralPlugin> peripheral_plugins_; | 66 std::vector<PeripheralPlugin> peripheral_plugins_; |
| 63 | 67 |
| 64 DISALLOW_COPY_AND_ASSIGN(PluginPowerSaverHelper); | 68 DISALLOW_COPY_AND_ASSIGN(PluginPowerSaverHelper); |
| 65 }; | 69 }; |
| 66 | 70 |
| 67 } // namespace content | 71 } // namespace content |
| 68 | 72 |
| 69 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_POWER_SAVER_HELPER_H_ | 73 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_POWER_SAVER_HELPER_H_ |
| OLD | NEW |