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

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

Issue 1111893003: Plugin Power Saver: Fix double-counting NEVER case in LoadablePluginPlaceholder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add a correction 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 : public PluginPlaceholder {
17 : public PluginPlaceholder,
18 public content::PluginInstanceThrottler::Observer {
19 public: 17 public:
20 void set_blocked_for_background_tab(bool blocked_for_background_tab) { 18 void set_blocked_for_background_tab(bool blocked_for_background_tab) {
21 is_blocked_for_background_tab_ = blocked_for_background_tab; 19 is_blocked_for_background_tab_ = blocked_for_background_tab;
22 } 20 }
23 21
24 void set_blocked_for_prerendering(bool blocked_for_prerendering) { 22 void set_blocked_for_prerendering(bool blocked_for_prerendering) {
25 is_blocked_for_prerendering_ = blocked_for_prerendering; 23 is_blocked_for_prerendering_ = blocked_for_prerendering;
26 } 24 }
27 25
28 #if defined(ENABLE_PLUGINS) 26 #if defined(ENABLE_PLUGINS)
29 void set_power_saver_enabled(bool power_saver_enabled) { 27 void set_power_saver_enabled(bool power_saver_enabled) {
30 power_saver_enabled_ = power_saver_enabled; 28 power_saver_enabled_ = power_saver_enabled;
31 } 29 }
32 30
33 // Defer loading of plugin, and instead show the Power Saver poster image. 31 // Defer loading of plugin, and instead show the Power Saver poster image.
34 void BlockForPowerSaverPoster(); 32 void BlockForPowerSaverPoster();
33
34 // When we load the plugin, use this already-created plugin, not a new one.
35 void SetPremadePlugin(content::PluginInstanceThrottler* throttler);
35 #endif 36 #endif
36 37
37 void set_allow_loading(bool allow_loading) { allow_loading_ = allow_loading; } 38 void set_allow_loading(bool allow_loading) { allow_loading_ = allow_loading; }
38 39
39 // When we load the plugin, use this already-created plugin, not a new one.
40 void SetPremadePlugin(content::PluginInstanceThrottler* throttler);
41
42 protected: 40 protected:
43 LoadablePluginPlaceholder(content::RenderFrame* render_frame, 41 LoadablePluginPlaceholder(content::RenderFrame* render_frame,
44 blink::WebLocalFrame* frame, 42 blink::WebLocalFrame* frame,
45 const blink::WebPluginParams& params, 43 const blink::WebPluginParams& params,
46 const std::string& html_data, 44 const std::string& html_data,
47 GURL placeholderDataUrl); 45 GURL placeholderDataUrl);
48 46
49 ~LoadablePluginPlaceholder() override; 47 ~LoadablePluginPlaceholder() override;
50 48
51 #if defined(ENABLE_PLUGINS) 49 #if defined(ENABLE_PLUGINS)
(...skipping 24 matching lines...) Expand all
76 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( 74 gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
77 v8::Isolate* isolate) override; 75 v8::Isolate* isolate) override;
78 76
79 private: 77 private:
80 // WebViewPlugin::Delegate methods: 78 // WebViewPlugin::Delegate methods:
81 void PluginDestroyed() override; 79 void PluginDestroyed() override;
82 80
83 // RenderFrameObserver methods: 81 // RenderFrameObserver methods:
84 void WasShown() override; 82 void WasShown() override;
85 83
86 // content::PluginInstanceThrottler::Observer methods:
87 void OnThrottleStateChange() override;
88
89 // Javascript callbacks: 84 // Javascript callbacks:
90 85
91 // Load the blocked plugin by calling LoadPlugin(). 86 // Load the blocked plugin by calling LoadPlugin().
92 void LoadCallback(); 87 void LoadCallback();
93 88
94 // Hide the blocked plugin by calling HidePlugin(). 89 // Hide the blocked plugin by calling HidePlugin().
95 void HideCallback(); 90 void HideCallback();
96 91
97 void DidFinishLoadingCallback(); 92 void DidFinishLoadingCallback();
98 93
99 void UpdateMessage(); 94 void UpdateMessage();
100 95
101 bool LoadingBlocked() const; 96 bool LoadingBlocked() const;
102 97
103 content::WebPluginInfo plugin_info_; 98 content::WebPluginInfo plugin_info_;
104 99
105 base::string16 message_; 100 base::string16 message_;
106 101
107 // True if the plugin load was deferred due to page being a background tab. 102 // 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. 103 // Plugin may be automatically loaded when the page is foregrounded.
109 bool is_blocked_for_background_tab_; 104 bool is_blocked_for_background_tab_;
110 105
111 // True if the plugin was blocked because the page was being prerendered. 106 // True if the plugin was blocked because the page was being prerendered.
112 // Plugin may be automatically be loaded when the page is displayed. 107 // Plugin may be automatically be loaded when the page is displayed.
113 bool is_blocked_for_prerendering_; 108 bool is_blocked_for_prerendering_;
114 109
115 // True if the plugin load was deferred due to a Power Saver poster. 110 // True if the plugin load was deferred due to a Power Saver poster.
116 bool is_blocked_for_power_saver_poster_; 111 bool is_blocked_for_power_saver_poster_;
117 112
118 // This is independent of deferred plugin load due to a Power Saver poster. 113 // True if power saver is enabled for this plugin and it has not been marked
114 // essential (by a click or retroactive whitelisting).
119 bool power_saver_enabled_; 115 bool power_saver_enabled_;
120 116
121 // True if the plugin has been marked essential.
122 bool plugin_marked_essential_;
123
124 // When we load, uses this premade plugin instead of creating a new one. 117 // When we load, uses this premade plugin instead of creating a new one.
125 content::PluginInstanceThrottler* premade_throttler_; 118 content::PluginInstanceThrottler* premade_throttler_;
126 119
127 bool allow_loading_; 120 bool allow_loading_;
128 121
129 // True if the placeholder was replaced with the real plugin.
130 bool placeholder_was_replaced_;
131
132 bool hidden_; 122 bool hidden_;
133 bool finished_loading_; 123 bool finished_loading_;
134 std::string identifier_; 124 std::string identifier_;
135 125
136 base::WeakPtrFactory<LoadablePluginPlaceholder> weak_factory_; 126 base::WeakPtrFactory<LoadablePluginPlaceholder> weak_factory_;
137 127
138 DISALLOW_COPY_AND_ASSIGN(LoadablePluginPlaceholder); 128 DISALLOW_COPY_AND_ASSIGN(LoadablePluginPlaceholder);
139 }; 129 };
140 130
141 } // namespace plugins 131 } // namespace plugins
142 132
143 #endif // COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_ 133 #endif // COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698