| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_LOADABLE_PLUGIN_PLACEHOLDER_H_ | 5 #ifndef COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_ |
| 6 #define COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_ | 6 #define COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "components/plugins/renderer/plugin_placeholder.h" | 9 #include "components/plugins/renderer/plugin_placeholder.h" |
| 10 #include "content/public/common/webplugininfo.h" | 10 #include "content/public/common/webplugininfo.h" |
| 11 #include "content/public/renderer/plugin_instance_throttler.h" | 11 #include "content/public/renderer/plugin_instance_throttler.h" |
| 12 | 12 |
| 13 namespace plugins { | 13 namespace plugins { |
| 14 // Placeholders can be used if a plugin is missing or not available | 14 // Placeholders can be used if a plugin is missing or not available |
| 15 // (blocked or disabled). | 15 // (blocked or disabled). |
| 16 class LoadablePluginPlaceholder : public PluginPlaceholder { | 16 class LoadablePluginPlaceholder : public PluginPlaceholder { |
| 17 public: | 17 public: |
| 18 void set_blocked_for_background_tab(bool blocked_for_background_tab) { | 18 void set_blocked_for_background_tab(bool blocked_for_background_tab) { |
| 19 is_blocked_for_background_tab_ = blocked_for_background_tab; | 19 is_blocked_for_background_tab_ = blocked_for_background_tab; |
| 20 } | 20 } |
| 21 | 21 |
| 22 void set_blocked_for_prerendering(bool blocked_for_prerendering) { | 22 void set_blocked_for_prerendering(bool blocked_for_prerendering) { |
| 23 is_blocked_for_prerendering_ = blocked_for_prerendering; | 23 is_blocked_for_prerendering_ = blocked_for_prerendering; |
| 24 } | 24 } |
| 25 | 25 |
| 26 #if defined(ENABLE_PLUGINS) | 26 #if defined(ENABLE_PLUGINS) |
| 27 bool power_saver_enabled() const { return power_saver_enabled_; } |
| 28 |
| 27 void set_power_saver_enabled(bool power_saver_enabled) { | 29 void set_power_saver_enabled(bool power_saver_enabled) { |
| 28 power_saver_enabled_ = power_saver_enabled; | 30 power_saver_enabled_ = power_saver_enabled; |
| 29 } | 31 } |
| 30 | 32 |
| 31 // Defer loading of plugin, and instead show the Power Saver poster image. | 33 // Defer loading of plugin, and instead show the Power Saver poster image. |
| 32 void BlockForPowerSaverPoster(); | 34 void BlockForPowerSaverPoster(); |
| 33 | 35 |
| 34 // When we load the plugin, use this already-created plugin, not a new one. | 36 // When we load the plugin, use this already-created plugin, not a new one. |
| 35 void SetPremadePlugin(content::PluginInstanceThrottler* throttler); | 37 void SetPremadePlugin(content::PluginInstanceThrottler* throttler); |
| 36 #endif | 38 #endif |
| (...skipping 14 matching lines...) Expand all Loading... |
| 51 content::PluginInstanceThrottler::PowerSaverUnthrottleMethod method); | 53 content::PluginInstanceThrottler::PowerSaverUnthrottleMethod method); |
| 52 #endif | 54 #endif |
| 53 | 55 |
| 54 void OnLoadBlockedPlugins(const std::string& identifier); | 56 void OnLoadBlockedPlugins(const std::string& identifier); |
| 55 void OnSetIsPrerendering(bool is_prerendering); | 57 void OnSetIsPrerendering(bool is_prerendering); |
| 56 | 58 |
| 57 void SetMessage(const base::string16& message); | 59 void SetMessage(const base::string16& message); |
| 58 void SetPluginInfo(const content::WebPluginInfo& plugin_info); | 60 void SetPluginInfo(const content::WebPluginInfo& plugin_info); |
| 59 const content::WebPluginInfo& GetPluginInfo() const; | 61 const content::WebPluginInfo& GetPluginInfo() const; |
| 60 void SetIdentifier(const std::string& identifier); | 62 void SetIdentifier(const std::string& identifier); |
| 63 const std::string& GetIdentifier() const; |
| 61 bool LoadingAllowed() const { return allow_loading_; } | 64 bool LoadingAllowed() const { return allow_loading_; } |
| 62 | 65 |
| 63 // Replace this placeholder with a different plugin (which could be | 66 // Replace this placeholder with a different plugin (which could be |
| 64 // a placeholder again). | 67 // a placeholder again). |
| 65 void ReplacePlugin(blink::WebPlugin* new_plugin); | 68 void ReplacePlugin(blink::WebPlugin* new_plugin); |
| 66 | 69 |
| 67 // Hide this placeholder. | 70 // Hide this placeholder. |
| 68 void HidePlugin(); | 71 void HidePlugin(); |
| 69 | 72 |
| 70 // Load the blocked plugin. | 73 // Load the blocked plugin. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 88 | 91 |
| 89 // Hide the blocked plugin by calling HidePlugin(). | 92 // Hide the blocked plugin by calling HidePlugin(). |
| 90 void HideCallback(); | 93 void HideCallback(); |
| 91 | 94 |
| 92 void DidFinishLoadingCallback(); | 95 void DidFinishLoadingCallback(); |
| 93 | 96 |
| 94 void UpdateMessage(); | 97 void UpdateMessage(); |
| 95 | 98 |
| 96 bool LoadingBlocked() const; | 99 bool LoadingBlocked() const; |
| 97 | 100 |
| 101 // Plugin creation is embedder-specific. |
| 102 virtual blink::WebPlugin* CreatePlugin() = 0; |
| 103 |
| 98 content::WebPluginInfo plugin_info_; | 104 content::WebPluginInfo plugin_info_; |
| 99 | 105 |
| 100 base::string16 message_; | 106 base::string16 message_; |
| 101 | 107 |
| 102 // True if the plugin load was deferred due to page being a background tab. | 108 // True if the plugin load was deferred due to page being a background tab. |
| 103 // Plugin may be automatically loaded when the page is foregrounded. | 109 // Plugin may be automatically loaded when the page is foregrounded. |
| 104 bool is_blocked_for_background_tab_; | 110 bool is_blocked_for_background_tab_; |
| 105 | 111 |
| 106 // True if the plugin was blocked because the page was being prerendered. | 112 // True if the plugin was blocked because the page was being prerendered. |
| 107 // Plugin may be automatically be loaded when the page is displayed. | 113 // Plugin may be automatically be loaded when the page is displayed. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 124 std::string identifier_; | 130 std::string identifier_; |
| 125 | 131 |
| 126 base::WeakPtrFactory<LoadablePluginPlaceholder> weak_factory_; | 132 base::WeakPtrFactory<LoadablePluginPlaceholder> weak_factory_; |
| 127 | 133 |
| 128 DISALLOW_COPY_AND_ASSIGN(LoadablePluginPlaceholder); | 134 DISALLOW_COPY_AND_ASSIGN(LoadablePluginPlaceholder); |
| 129 }; | 135 }; |
| 130 | 136 |
| 131 } // namespace plugins | 137 } // namespace plugins |
| 132 | 138 |
| 133 #endif // COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_ | 139 #endif // COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_ |
| OLD | NEW |