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

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: 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 : 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
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 15 matching lines...) Expand all
86 89
87 // Javascript callbacks: 90 // Javascript callbacks:
88 void LoadCallback(); 91 void LoadCallback();
89 void HideCallback(); 92 void HideCallback();
90 void DidFinishLoadingCallback(); 93 void DidFinishLoadingCallback();
91 94
92 void UpdateMessage(); 95 void UpdateMessage();
93 96
94 bool LoadingBlocked() const; 97 bool LoadingBlocked() const;
95 98
99 // Plugin creation is embedder-specific.
100 virtual blink::WebPlugin* CreatePlugin() = 0;
101
96 content::WebPluginInfo plugin_info_; 102 content::WebPluginInfo plugin_info_;
97 103
98 base::string16 message_; 104 base::string16 message_;
99 105
100 // True if the plugin load was deferred due to page being a background tab. 106 // True if the plugin load was deferred due to page being a background tab.
101 // Plugin may be automatically loaded when the page is foregrounded. 107 // Plugin may be automatically loaded when the page is foregrounded.
102 bool is_blocked_for_background_tab_; 108 bool is_blocked_for_background_tab_;
103 109
104 // True if the plugin was blocked because the page was being prerendered. 110 // True if the plugin was blocked because the page was being prerendered.
105 // Plugin may be automatically be loaded when the page is displayed. 111 // Plugin may be automatically be loaded when the page is displayed.
(...skipping 16 matching lines...) Expand all
122 std::string identifier_; 128 std::string identifier_;
123 129
124 base::WeakPtrFactory<LoadablePluginPlaceholder> weak_factory_; 130 base::WeakPtrFactory<LoadablePluginPlaceholder> weak_factory_;
125 131
126 DISALLOW_COPY_AND_ASSIGN(LoadablePluginPlaceholder); 132 DISALLOW_COPY_AND_ASSIGN(LoadablePluginPlaceholder);
127 }; 133 };
128 134
129 } // namespace plugins 135 } // namespace plugins
130 136
131 #endif // COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_ 137 #endif // COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698