| 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( |
| 43 content::RenderFrame::PluginPowerSaverMode power_saver_mode) { | 44 content::PluginInstanceThrottler::PluginPowerSaverMode power_saver_mode) { |
| 44 power_saver_mode_ = power_saver_mode; | 45 power_saver_mode_ = power_saver_mode; |
| 45 } | 46 } |
| 46 | 47 |
| 47 // Defer loading of plug-in, and instead show the Power Saver poster image. | 48 // Defer loading of plug-in, and instead show the Power Saver poster image. |
| 48 void BlockForPowerSaverPoster(); | 49 void BlockForPowerSaverPoster(); |
| 49 #endif | 50 #endif |
| 50 | 51 |
| 51 void set_allow_loading(bool allow_loading) { allow_loading_ = allow_loading; } | 52 void set_allow_loading(bool allow_loading) { allow_loading_ = allow_loading; } |
| 52 | 53 |
| 53 protected: | 54 protected: |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 bool is_blocked_for_background_tab_; | 127 bool is_blocked_for_background_tab_; |
| 127 | 128 |
| 128 // True if the plugin was blocked because the page was being prerendered. | 129 // True if the plugin was blocked because the page was being prerendered. |
| 129 // Plugin may be automatically be loaded when the page is displayed. | 130 // Plugin may be automatically be loaded when the page is displayed. |
| 130 bool is_blocked_for_prerendering_; | 131 bool is_blocked_for_prerendering_; |
| 131 | 132 |
| 132 // True if the plugin load was deferred due to a Power Saver poster. | 133 // True if the plugin load was deferred due to a Power Saver poster. |
| 133 bool is_blocked_for_power_saver_poster_; | 134 bool is_blocked_for_power_saver_poster_; |
| 134 | 135 |
| 135 // This is independent of deferred plugin load due to a Power Saver poster. | 136 // This is independent of deferred plugin load due to a Power Saver poster. |
| 136 content::RenderFrame::PluginPowerSaverMode power_saver_mode_; | 137 content::PluginInstanceThrottler::PluginPowerSaverMode power_saver_mode_; |
| 137 | 138 |
| 138 bool allow_loading_; | 139 bool allow_loading_; |
| 139 | 140 |
| 140 bool hidden_; | 141 bool hidden_; |
| 141 bool finished_loading_; | 142 bool finished_loading_; |
| 142 std::string identifier_; | 143 std::string identifier_; |
| 143 | 144 |
| 144 base::WeakPtrFactory<PluginPlaceholder> weak_factory_; | 145 base::WeakPtrFactory<PluginPlaceholder> weak_factory_; |
| 145 | 146 |
| 146 DISALLOW_COPY_AND_ASSIGN(PluginPlaceholder); | 147 DISALLOW_COPY_AND_ASSIGN(PluginPlaceholder); |
| 147 }; | 148 }; |
| 148 | 149 |
| 149 } // namespace plugins | 150 } // namespace plugins |
| 150 | 151 |
| 151 #endif // COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_ | 152 #endif // COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_ |
| OLD | NEW |