Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: components/plugins/renderer/loadable_plugin_placeholder.h

Issue 904913003: Plugin Power Saver: Fix implicitly sized and below the fold plugins. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 plug-in is missing or not available 14 // Placeholders can be used if a plug-in is missing or not available
15 // (blocked or disabled). 15 // (blocked or disabled).
16 class LoadablePluginPlaceholder 16 class LoadablePluginPlaceholder
17 : public PluginPlaceholder, 17 : public PluginPlaceholder,
18 public content::PluginInstanceThrottler::Observer { 18 public content::PluginInstanceThrottler::Observer {
19 public: 19 public:
20 void set_blocked_for_background_tab(bool blocked_for_background_tab) { 20 void set_blocked_for_background_tab(bool blocked_for_background_tab) {
21 is_blocked_for_background_tab_ = blocked_for_background_tab; 21 is_blocked_for_background_tab_ = blocked_for_background_tab;
22 } 22 }
23 23
24 void set_blocked_for_prerendering(bool blocked_for_prerendering) { 24 void set_blocked_for_prerendering(bool blocked_for_prerendering) {
25 is_blocked_for_prerendering_ = blocked_for_prerendering; 25 is_blocked_for_prerendering_ = blocked_for_prerendering;
26 } 26 }
27 27
28 #if defined(ENABLE_PLUGINS) 28 #if defined(ENABLE_PLUGINS)
29 void set_power_saver_mode(content::PluginPowerSaverMode power_saver_mode) { 29 void set_power_saver_enabled(bool power_saver_enabled) {
30 power_saver_mode_ = power_saver_mode; 30 power_saver_enabled_ = power_saver_enabled;
31 } 31 }
32 32
33 // Defer loading of plug-in, and instead show the Power Saver poster image. 33 // Defer loading of plug-in, and instead show the Power Saver poster image.
34 void BlockForPowerSaverPoster(); 34 void BlockForPowerSaverPoster();
35 #endif 35 #endif
36 36
37 void set_allow_loading(bool allow_loading) { allow_loading_ = allow_loading; } 37 void set_allow_loading(bool allow_loading) { allow_loading_ = allow_loading; }
38 38
39 // When we load the plugin, use this already-created plugin, not a new one. 39 // When we load the plugin, use this already-created plugin, not a new one.
40 void SetPremadePlugin(blink::WebPlugin* plugin, 40 void SetPremadePlugin(blink::WebPlugin* plugin,
41 content::PluginInstanceThrottler* throttler); 41 content::PluginInstanceThrottler* throttler);
42 42
43 protected: 43 protected:
44 LoadablePluginPlaceholder(content::RenderFrame* render_frame, 44 LoadablePluginPlaceholder(content::RenderFrame* render_frame,
45 blink::WebLocalFrame* frame, 45 blink::WebLocalFrame* frame,
46 const blink::WebPluginParams& params, 46 const blink::WebPluginParams& params,
47 const std::string& html_data, 47 const std::string& html_data,
48 GURL placeholderDataUrl); 48 GURL placeholderDataUrl);
49 49
50 ~LoadablePluginPlaceholder() override; 50 ~LoadablePluginPlaceholder() override;
51 51
52 #if defined(ENABLE_PLUGINS) 52 #if defined(ENABLE_PLUGINS)
53 void DisablePowerSaverForInstance( 53 void MarkPluginEssential(
54 content::PluginInstanceThrottler::PowerSaverUnthrottleMethod method); 54 content::PluginInstanceThrottler::PowerSaverUnthrottleMethod method);
55 #endif 55 #endif
56 56
57 void OnLoadBlockedPlugins(const std::string& identifier); 57 void OnLoadBlockedPlugins(const std::string& identifier);
58 void OnSetIsPrerendering(bool is_prerendering); 58 void OnSetIsPrerendering(bool is_prerendering);
59 59
60 void SetMessage(const base::string16& message); 60 void SetMessage(const base::string16& message);
61 void SetPluginInfo(const content::WebPluginInfo& plugin_info); 61 void SetPluginInfo(const content::WebPluginInfo& plugin_info);
62 const content::WebPluginInfo& GetPluginInfo() const; 62 const content::WebPluginInfo& GetPluginInfo() const;
63 void SetIdentifier(const std::string& identifier); 63 void SetIdentifier(const std::string& identifier);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 bool is_blocked_for_background_tab_; 110 bool is_blocked_for_background_tab_;
111 111
112 // 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.
113 // Plugin may be automatically be loaded when the page is displayed. 113 // Plugin may be automatically be loaded when the page is displayed.
114 bool is_blocked_for_prerendering_; 114 bool is_blocked_for_prerendering_;
115 115
116 // True if the plugin load was deferred due to a Power Saver poster. 116 // True if the plugin load was deferred due to a Power Saver poster.
117 bool is_blocked_for_power_saver_poster_; 117 bool is_blocked_for_power_saver_poster_;
118 118
119 // This is independent of deferred plugin load due to a Power Saver poster. 119 // This is independent of deferred plugin load due to a Power Saver poster.
120 content::PluginPowerSaverMode power_saver_mode_; 120 bool power_saver_enabled_;
121
122 // True if the plugin has been marked essential.
123 bool plugin_marked_essential_;
121 124
122 // When we load, uses this premade plugin instead of creating a new one. 125 // When we load, uses this premade plugin instead of creating a new one.
123 blink::WebPlugin* premade_plugin_; 126 blink::WebPlugin* premade_plugin_;
124 content::PluginInstanceThrottler* premade_throttler_; 127 content::PluginInstanceThrottler* premade_throttler_;
125 128
126 bool allow_loading_; 129 bool allow_loading_;
127 130
128 // True if the placeholder was replaced with the real plugin. 131 // True if the placeholder was replaced with the real plugin.
129 bool placeholder_was_replaced_; 132 bool placeholder_was_replaced_;
130 133
131 bool hidden_; 134 bool hidden_;
132 bool finished_loading_; 135 bool finished_loading_;
133 std::string identifier_; 136 std::string identifier_;
134 137
135 base::WeakPtrFactory<LoadablePluginPlaceholder> weak_factory_; 138 base::WeakPtrFactory<LoadablePluginPlaceholder> weak_factory_;
136 139
137 DISALLOW_COPY_AND_ASSIGN(LoadablePluginPlaceholder); 140 DISALLOW_COPY_AND_ASSIGN(LoadablePluginPlaceholder);
138 }; 141 };
139 142
140 } // namespace plugins 143 } // namespace plugins
141 144
142 #endif // COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_ 145 #endif // COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_
OLDNEW
« no previous file with comments | « chrome/renderer/plugins/plugin_preroller.cc ('k') | components/plugins/renderer/loadable_plugin_placeholder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698