OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_ | 5 #ifndef COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_ |
6 #define COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_ | 6 #define COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_ |
7 | 7 |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "components/plugins/renderer/webview_plugin.h" | 9 #include "components/plugins/renderer/webview_plugin.h" |
10 #include "content/public/common/webplugininfo.h" | 10 #include "content/public/common/webplugininfo.h" |
11 #include "content/public/renderer/context_menu_client.h" | 11 #include "content/public/renderer/context_menu_client.h" |
12 #include "content/public/renderer/render_frame.h" | 12 #include "content/public/renderer/plugin_instance_throttler.h" |
13 #include "content/public/renderer/render_frame_observer.h" | 13 #include "content/public/renderer/render_frame_observer.h" |
14 #include "content/public/renderer/render_process_observer.h" | 14 #include "content/public/renderer/render_process_observer.h" |
15 #include "gin/wrappable.h" | 15 #include "gin/wrappable.h" |
16 #include "third_party/WebKit/public/web/WebPluginParams.h" | 16 #include "third_party/WebKit/public/web/WebPluginParams.h" |
17 | 17 |
18 namespace content { | 18 namespace content { |
| 19 class RenderFrame; |
19 struct WebPluginInfo; | 20 struct WebPluginInfo; |
20 } | 21 } |
21 | 22 |
22 namespace plugins { | 23 namespace plugins { |
23 // Placeholders can be used if a plug-in is missing or not available | 24 // Placeholders can be used if a plug-in is missing or not available |
24 // (blocked or disabled). | 25 // (blocked or disabled). |
25 class PluginPlaceholder : public content::RenderFrameObserver, | 26 class PluginPlaceholder : public content::RenderFrameObserver, |
26 public WebViewPlugin::Delegate, | 27 public WebViewPlugin::Delegate, |
27 public gin::Wrappable<PluginPlaceholder> { | 28 public gin::Wrappable<PluginPlaceholder> { |
28 public: | 29 public: |
29 static gin::WrapperInfo kWrapperInfo; | 30 static gin::WrapperInfo kWrapperInfo; |
30 | 31 |
31 WebViewPlugin* plugin() { return plugin_; } | 32 WebViewPlugin* plugin() { return plugin_; } |
32 | 33 |
33 void set_blocked_for_background_tab(bool blocked_for_background_tab) { | 34 void set_blocked_for_background_tab(bool blocked_for_background_tab) { |
34 is_blocked_for_background_tab_ = blocked_for_background_tab; | 35 is_blocked_for_background_tab_ = blocked_for_background_tab; |
35 } | 36 } |
36 | 37 |
37 void set_blocked_for_prerendering(bool blocked_for_prerendering) { | 38 void set_blocked_for_prerendering(bool blocked_for_prerendering) { |
38 is_blocked_for_prerendering_ = blocked_for_prerendering; | 39 is_blocked_for_prerendering_ = blocked_for_prerendering; |
39 } | 40 } |
40 | 41 |
41 #if defined(ENABLE_PLUGINS) | 42 #if defined(ENABLE_PLUGINS) |
42 void set_power_saver_mode( | 43 void set_power_saver_mode(content::PluginPowerSaverMode power_saver_mode) { |
43 content::RenderFrame::PluginPowerSaverMode power_saver_mode) { | |
44 power_saver_mode_ = power_saver_mode; | 44 power_saver_mode_ = power_saver_mode; |
45 } | 45 } |
46 | 46 |
47 // Defer loading of plug-in, and instead show the Power Saver poster image. | 47 // Defer loading of plug-in, and instead show the Power Saver poster image. |
48 void BlockForPowerSaverPoster(); | 48 void BlockForPowerSaverPoster(); |
49 #endif | 49 #endif |
50 | 50 |
51 void set_allow_loading(bool allow_loading) { allow_loading_ = allow_loading; } | 51 void set_allow_loading(bool allow_loading) { allow_loading_ = allow_loading; } |
52 | 52 |
53 protected: | 53 protected: |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 bool is_blocked_for_background_tab_; | 126 bool is_blocked_for_background_tab_; |
127 | 127 |
128 // True if the plugin was blocked because the page was being prerendered. | 128 // True if the plugin was blocked because the page was being prerendered. |
129 // Plugin may be automatically be loaded when the page is displayed. | 129 // Plugin may be automatically be loaded when the page is displayed. |
130 bool is_blocked_for_prerendering_; | 130 bool is_blocked_for_prerendering_; |
131 | 131 |
132 // True if the plugin load was deferred due to a Power Saver poster. | 132 // True if the plugin load was deferred due to a Power Saver poster. |
133 bool is_blocked_for_power_saver_poster_; | 133 bool is_blocked_for_power_saver_poster_; |
134 | 134 |
135 // This is independent of deferred plugin load due to a Power Saver poster. | 135 // This is independent of deferred plugin load due to a Power Saver poster. |
136 content::RenderFrame::PluginPowerSaverMode power_saver_mode_; | 136 content::PluginPowerSaverMode power_saver_mode_; |
137 | 137 |
138 bool allow_loading_; | 138 bool allow_loading_; |
139 | 139 |
140 bool hidden_; | 140 bool hidden_; |
141 bool finished_loading_; | 141 bool finished_loading_; |
142 std::string identifier_; | 142 std::string identifier_; |
143 | 143 |
144 base::WeakPtrFactory<PluginPlaceholder> weak_factory_; | 144 base::WeakPtrFactory<PluginPlaceholder> weak_factory_; |
145 | 145 |
146 DISALLOW_COPY_AND_ASSIGN(PluginPlaceholder); | 146 DISALLOW_COPY_AND_ASSIGN(PluginPlaceholder); |
147 }; | 147 }; |
148 | 148 |
149 } // namespace plugins | 149 } // namespace plugins |
150 | 150 |
151 #endif // COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_ | 151 #endif // COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_ |
OLD | NEW |