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.
5 #ifndef CONTENT_RENDERER_PEPPER_PLUGIN_POWER_SAVER_HELPER_H_
6 #define CONTENT_RENDERER_PEPPER_PLUGIN_POWER_SAVER_HELPER_H_
11 #include "base/callback.h"
12 #include "content/common/content_export.h"
13 #include "content/public/renderer/render_frame_observer.h"
17 struct WebPluginParams
;
22 class CONTENT_EXPORT PluginPowerSaverHelper
: public RenderFrameObserver
{
24 explicit PluginPowerSaverHelper(RenderFrame
* render_frame
);
25 ~PluginPowerSaverHelper() override
;
27 // See RenderFrame for documentation.
28 void RegisterPeripheralPlugin(const GURL
& content_origin
,
29 const base::Closure
& unthrottle_callback
);
30 bool ShouldThrottleContent(const blink::WebPluginParams
& params
,
31 const GURL
& plugin_frame_url
,
33 bool* cross_origin_main_content
) const;
34 void WhitelistContentOrigin(const GURL
& content_origin
);
37 struct PeripheralPlugin
{
38 PeripheralPlugin(const GURL
& content_origin
,
39 const base::Closure
& unthrottle_callback
);
43 base::Closure unthrottle_callback
;
46 // RenderFrameObserver implementation.
47 void DidCommitProvisionalLoad(bool is_new_navigation
) override
;
48 bool OnMessageReceived(const IPC::Message
& message
) override
;
50 void OnUpdatePluginContentOriginWhitelist(
51 const std::set
<GURL
>& origin_whitelist
);
53 // Local copy of the whitelist for the entire tab.
54 std::set
<GURL
> origin_whitelist_
;
56 // Set of peripheral plugins eligible to be unthrottled ex post facto.
57 std::vector
<PeripheralPlugin
> peripheral_plugins_
;
59 DISALLOW_COPY_AND_ASSIGN(PluginPowerSaverHelper
);
62 } // namespace content
64 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_POWER_SAVER_HELPER_H_