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

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

Issue 1114623002: Plugin Power Saver: Make PPS work well with prerendered pages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 5 years, 7 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 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 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 bool power_saver_enabled() const { return power_saver_enabled_; }
30
29 void set_power_saver_enabled(bool power_saver_enabled) { 31 void set_power_saver_enabled(bool power_saver_enabled) {
30 power_saver_enabled_ = power_saver_enabled; 32 power_saver_enabled_ = power_saver_enabled;
31 } 33 }
32 34
33 // Defer loading of plugin, and instead show the Power Saver poster image. 35 // Defer loading of plugin, and instead show the Power Saver poster image.
34 void BlockForPowerSaverPoster(); 36 void BlockForPowerSaverPoster();
35 #endif 37 #endif
36 38
37 void set_allow_loading(bool allow_loading) { allow_loading_ = allow_loading; } 39 void set_allow_loading(bool allow_loading) { allow_loading_ = allow_loading; }
38 40
(...skipping 14 matching lines...) Expand all
53 content::PluginInstanceThrottler::PowerSaverUnthrottleMethod method); 55 content::PluginInstanceThrottler::PowerSaverUnthrottleMethod method);
54 #endif 56 #endif
55 57
56 void OnLoadBlockedPlugins(const std::string& identifier); 58 void OnLoadBlockedPlugins(const std::string& identifier);
57 void OnSetIsPrerendering(bool is_prerendering); 59 void OnSetIsPrerendering(bool is_prerendering);
58 60
59 void SetMessage(const base::string16& message); 61 void SetMessage(const base::string16& message);
60 void SetPluginInfo(const content::WebPluginInfo& plugin_info); 62 void SetPluginInfo(const content::WebPluginInfo& plugin_info);
61 const content::WebPluginInfo& GetPluginInfo() const; 63 const content::WebPluginInfo& GetPluginInfo() const;
62 void SetIdentifier(const std::string& identifier); 64 void SetIdentifier(const std::string& identifier);
65 const std::string& GetIdentifier() const;
63 bool LoadingAllowed() const { return allow_loading_; } 66 bool LoadingAllowed() const { return allow_loading_; }
64 67
65 // Replace this placeholder with a different plugin (which could be 68 // Replace this placeholder with a different plugin (which could be
66 // a placeholder again). 69 // a placeholder again).
67 void ReplacePlugin(blink::WebPlugin* new_plugin); 70 void ReplacePlugin(blink::WebPlugin* new_plugin);
68 71
69 // Hide this placeholder. 72 // Hide this placeholder.
70 void HidePlugin(); 73 void HidePlugin();
71 74
72 // Load the blocked plugin. 75 // Load the blocked plugin.
(...skipping 20 matching lines...) Expand all
93 96
94 // Hide the blocked plugin by calling HidePlugin(). 97 // Hide the blocked plugin by calling HidePlugin().
95 void HideCallback(); 98 void HideCallback();
96 99
97 void DidFinishLoadingCallback(); 100 void DidFinishLoadingCallback();
98 101
99 void UpdateMessage(); 102 void UpdateMessage();
100 103
101 bool LoadingBlocked() const; 104 bool LoadingBlocked() const;
102 105
106 // Plugin creation is embedder-specific.
107 virtual blink::WebPlugin* CreatePlugin() = 0;
108
103 content::WebPluginInfo plugin_info_; 109 content::WebPluginInfo plugin_info_;
104 110
105 base::string16 message_; 111 base::string16 message_;
106 112
107 // 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.
108 // Plugin may be automatically loaded when the page is foregrounded. 114 // Plugin may be automatically loaded when the page is foregrounded.
109 bool is_blocked_for_background_tab_; 115 bool is_blocked_for_background_tab_;
110 116
111 // 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.
112 // Plugin may be automatically be loaded when the page is displayed. 118 // Plugin may be automatically be loaded when the page is displayed.
(...skipping 21 matching lines...) Expand all
134 std::string identifier_; 140 std::string identifier_;
135 141
136 base::WeakPtrFactory<LoadablePluginPlaceholder> weak_factory_; 142 base::WeakPtrFactory<LoadablePluginPlaceholder> weak_factory_;
137 143
138 DISALLOW_COPY_AND_ASSIGN(LoadablePluginPlaceholder); 144 DISALLOW_COPY_AND_ASSIGN(LoadablePluginPlaceholder);
139 }; 145 };
140 146
141 } // namespace plugins 147 } // namespace plugins
142 148
143 #endif // COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_ 149 #endif // COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698