| 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 <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
| 13 #include "components/plugins/renderer/plugin_placeholder.h" | 13 #include "components/plugins/renderer/plugin_placeholder.h" |
| 14 #include "content/public/common/webplugininfo.h" | 14 #include "content/public/common/webplugininfo.h" |
| 15 #include "content/public/renderer/plugin_instance_throttler.h" | 15 #include "content/public/renderer/plugin_instance_throttler.h" |
| 16 #include "content/public/renderer/render_frame.h" | 16 #include "content/public/renderer/render_frame.h" |
| 17 #include "content/public/renderer/render_thread.h" | 17 #include "content/public/renderer/render_thread.h" |
| 18 | 18 |
| 19 namespace plugins { | 19 namespace plugins { |
| 20 // Placeholders can be used if a plugin is missing or not available | 20 // Placeholders can be used if a plugin is missing or not available |
| 21 // (blocked or disabled). | 21 // (blocked or disabled). |
| 22 class LoadablePluginPlaceholder : public PluginPlaceholderBase { | 22 class LoadablePluginPlaceholder : public PluginPlaceholderBase { |
| 23 public: | 23 public: |
| 24 void set_delayed(bool delayed) { is_delayed_placeholder_ = delayed; } | 24 void set_blocked_for_tinyness(bool blocked_for_tinyness) { |
| 25 is_blocked_for_tinyness_ = blocked_for_tinyness; |
| 26 } |
| 25 | 27 |
| 26 void set_blocked_for_background_tab(bool blocked_for_background_tab) { | 28 void set_blocked_for_background_tab(bool blocked_for_background_tab) { |
| 27 is_blocked_for_background_tab_ = blocked_for_background_tab; | 29 is_blocked_for_background_tab_ = blocked_for_background_tab; |
| 28 } | 30 } |
| 29 | 31 |
| 30 void set_blocked_for_prerendering(bool blocked_for_prerendering) { | 32 void set_blocked_for_prerendering(bool blocked_for_prerendering) { |
| 31 is_blocked_for_prerendering_ = blocked_for_prerendering; | 33 is_blocked_for_prerendering_ = blocked_for_prerendering; |
| 32 } | 34 } |
| 33 | 35 |
| 34 bool power_saver_enabled() const { return power_saver_enabled_; } | 36 bool power_saver_enabled() const { return power_saver_enabled_; } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 46 void AllowLoading() { allow_loading_ = true; } | 48 void AllowLoading() { allow_loading_ = true; } |
| 47 | 49 |
| 48 protected: | 50 protected: |
| 49 LoadablePluginPlaceholder(content::RenderFrame* render_frame, | 51 LoadablePluginPlaceholder(content::RenderFrame* render_frame, |
| 50 blink::WebLocalFrame* frame, | 52 blink::WebLocalFrame* frame, |
| 51 const blink::WebPluginParams& params, | 53 const blink::WebPluginParams& params, |
| 52 const std::string& html_data); | 54 const std::string& html_data); |
| 53 | 55 |
| 54 ~LoadablePluginPlaceholder() override; | 56 ~LoadablePluginPlaceholder() override; |
| 55 | 57 |
| 56 void SetDelegate(std::unique_ptr<Delegate> delegate); | |
| 57 | |
| 58 void MarkPluginEssential( | 58 void MarkPluginEssential( |
| 59 content::PluginInstanceThrottler::PowerSaverUnthrottleMethod method); | 59 content::PluginInstanceThrottler::PowerSaverUnthrottleMethod method); |
| 60 | 60 |
| 61 void OnLoadBlockedPlugins(const std::string& identifier); | 61 void OnLoadBlockedPlugins(const std::string& identifier); |
| 62 void OnSetIsPrerendering(bool is_prerendering); | 62 void OnSetIsPrerendering(bool is_prerendering); |
| 63 | 63 |
| 64 void SetMessage(const base::string16& message); | 64 void SetMessage(const base::string16& message); |
| 65 void SetPluginInfo(const content::WebPluginInfo& plugin_info); | 65 void SetPluginInfo(const content::WebPluginInfo& plugin_info); |
| 66 const content::WebPluginInfo& GetPluginInfo() const; | 66 const content::WebPluginInfo& GetPluginInfo() const; |
| 67 void SetIdentifier(const std::string& identifier); | 67 void SetIdentifier(const std::string& identifier); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 92 // RenderFrameObserver methods: | 92 // RenderFrameObserver methods: |
| 93 void WasShown() override; | 93 void WasShown() override; |
| 94 | 94 |
| 95 void UpdateMessage(); | 95 void UpdateMessage(); |
| 96 | 96 |
| 97 bool LoadingBlocked() const; | 97 bool LoadingBlocked() const; |
| 98 | 98 |
| 99 // Plugin creation is embedder-specific. | 99 // Plugin creation is embedder-specific. |
| 100 virtual blink::WebPlugin* CreatePlugin() = 0; | 100 virtual blink::WebPlugin* CreatePlugin() = 0; |
| 101 | 101 |
| 102 // Handling of delayed behavior is embedder-specific. | 102 // Embedder-specific behavior. |
| 103 virtual void OnLoadedRectUpdate( | 103 virtual void OnBlockedTinyContent() = 0; |
| 104 const gfx::Rect& unobscured_rect, | |
| 105 content::RenderFrame::PeripheralContentStatus status) = 0; | |
| 106 | 104 |
| 107 content::WebPluginInfo plugin_info_; | 105 content::WebPluginInfo plugin_info_; |
| 108 | 106 |
| 109 base::string16 message_; | 107 base::string16 message_; |
| 110 | 108 |
| 111 // True if this is a "delayed" placeholder - one that will make a decision | 109 // True if the plugin load was deferred because this might be a tiny plugin. |
| 112 // on placeholder vs. plugin behavior once initial size has been determined. | 110 // Plugin may be automatically loaded if it receives non-tiny geometry. |
| 113 bool is_delayed_placeholder_; | 111 bool is_blocked_for_tinyness_; |
| 114 | 112 |
| 115 // True if the plugin load was deferred due to page being a background tab. | 113 // True if the plugin load was deferred due to page being a background tab. |
| 116 // Plugin may be automatically loaded when the page is foregrounded. | 114 // Plugin may be automatically loaded when the page is foregrounded. |
| 117 bool is_blocked_for_background_tab_; | 115 bool is_blocked_for_background_tab_; |
| 118 | 116 |
| 119 // True if the plugin was blocked because the page was being prerendered. | 117 // True if the plugin was blocked because the page was being prerendered. |
| 120 // Plugin may be automatically be loaded when the page is displayed. | 118 // Plugin may be automatically be loaded when the page is displayed. |
| 121 bool is_blocked_for_prerendering_; | 119 bool is_blocked_for_prerendering_; |
| 122 | 120 |
| 123 // True if the plugin load was deferred due to a Power Saver poster. | 121 // True if the plugin load was deferred due to a Power Saver poster. |
| 124 bool is_blocked_for_power_saver_poster_; | 122 bool is_blocked_for_power_saver_poster_; |
| 125 | 123 |
| 126 // True if power saver is enabled for this plugin and it has not been marked | 124 // True if power saver is enabled for this plugin and it has not been marked |
| 127 // essential (by a click or retroactive whitelisting). | 125 // essential (by a click or retroactive whitelisting). |
| 128 bool power_saver_enabled_; | 126 bool power_saver_enabled_; |
| 129 | 127 |
| 130 // When we load, uses this premade plugin instead of creating a new one. | 128 // When we load, uses this premade plugin instead of creating a new one. |
| 131 content::PluginInstanceThrottler* premade_throttler_; | 129 content::PluginInstanceThrottler* premade_throttler_; |
| 132 | 130 |
| 133 bool allow_loading_; | 131 bool allow_loading_; |
| 134 | 132 |
| 135 bool finished_loading_; | 133 bool finished_loading_; |
| 136 std::string identifier_; | 134 std::string identifier_; |
| 137 | 135 |
| 138 gfx::Rect unobscured_rect_; | 136 gfx::Rect unobscured_rect_; |
| 139 | 137 |
| 140 // True if the power saver heuristic has already been run on this content. | 138 // True if the power saver heuristic has already been run on this content. |
| 141 bool heuristic_run_before_; | 139 bool heuristic_run_before_; |
| 142 | 140 |
| 143 std::unique_ptr<Delegate> delegate_; | |
| 144 | |
| 145 base::WeakPtrFactory<LoadablePluginPlaceholder> weak_factory_; | 141 base::WeakPtrFactory<LoadablePluginPlaceholder> weak_factory_; |
| 146 | 142 |
| 147 DISALLOW_COPY_AND_ASSIGN(LoadablePluginPlaceholder); | 143 DISALLOW_COPY_AND_ASSIGN(LoadablePluginPlaceholder); |
| 148 }; | 144 }; |
| 149 | 145 |
| 150 } // namespace plugins | 146 } // namespace plugins |
| 151 | 147 |
| 152 #endif // COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_ | 148 #endif // COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_ |
| OLD | NEW |