Implement HasPermission() method in PermissionService.
[chromium-blink-merge.git] / content / renderer / pepper / plugin_power_saver_helper.h
blob67a9471adce033d4ebfcd36c2bded025fe85ec04
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_
8 #include <set>
9 #include <vector>
11 #include "base/callback.h"
12 #include "content/common/content_export.h"
13 #include "content/public/renderer/render_frame_observer.h"
14 #include "url/gurl.h"
16 namespace blink {
17 struct WebPluginParams;
20 namespace content {
22 class CONTENT_EXPORT PluginPowerSaverHelper : public RenderFrameObserver {
23 public:
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,
32 GURL* poster_image,
33 bool* cross_origin_main_content) const;
34 void WhitelistContentOrigin(const GURL& content_origin);
36 private:
37 struct PeripheralPlugin {
38 PeripheralPlugin(const GURL& content_origin,
39 const base::Closure& unthrottle_callback);
40 ~PeripheralPlugin();
42 GURL content_origin;
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_