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

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

Issue 866173002: Plugin Power Saver: Add UI Overlay to throttled plugin using placeholder. (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 : public PluginPlaceholder { 16 class LoadablePluginPlaceholder
17 : public PluginPlaceholder,
18 public content::PluginInstanceThrottler::Observer {
17 public: 19 public:
18 void set_blocked_for_background_tab(bool blocked_for_background_tab) { 20 void set_blocked_for_background_tab(bool blocked_for_background_tab) {
19 is_blocked_for_background_tab_ = blocked_for_background_tab; 21 is_blocked_for_background_tab_ = blocked_for_background_tab;
20 } 22 }
21 23
22 void set_blocked_for_prerendering(bool blocked_for_prerendering) { 24 void set_blocked_for_prerendering(bool blocked_for_prerendering) {
23 is_blocked_for_prerendering_ = blocked_for_prerendering; 25 is_blocked_for_prerendering_ = blocked_for_prerendering;
24 } 26 }
25 27
26 #if defined(ENABLE_PLUGINS) 28 #if defined(ENABLE_PLUGINS)
27 void set_power_saver_mode(content::PluginPowerSaverMode power_saver_mode) { 29 void set_power_saver_mode(content::PluginPowerSaverMode power_saver_mode) {
28 power_saver_mode_ = power_saver_mode; 30 power_saver_mode_ = power_saver_mode;
29 } 31 }
30 32
31 // 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.
32 void BlockForPowerSaverPoster(); 34 void BlockForPowerSaverPoster();
33 #endif 35 #endif
34 36
35 void set_allow_loading(bool allow_loading) { allow_loading_ = allow_loading; } 37 void set_allow_loading(bool allow_loading) { allow_loading_ = allow_loading; }
36 38
39 // When we load the plugin, use this already-created plugin, not a new one.
40 void SetPremadePlugin(blink::WebPlugin* plugin,
41 content::PluginInstanceThrottler* throttler);
42
37 protected: 43 protected:
38 LoadablePluginPlaceholder(content::RenderFrame* render_frame, 44 LoadablePluginPlaceholder(content::RenderFrame* render_frame,
39 blink::WebLocalFrame* frame, 45 blink::WebLocalFrame* frame,
40 const blink::WebPluginParams& params, 46 const blink::WebPluginParams& params,
41 const std::string& html_data, 47 const std::string& html_data,
42 GURL placeholderDataUrl); 48 GURL placeholderDataUrl);
43 49
44 ~LoadablePluginPlaceholder() override; 50 ~LoadablePluginPlaceholder() override;
45 51
46 #if defined(ENABLE_PLUGINS) 52 #if defined(ENABLE_PLUGINS)
(...skipping 19 matching lines...) Expand all
66 72
67 // Load the blocked plugin. 73 // Load the blocked plugin.
68 void LoadPlugin(); 74 void LoadPlugin();
69 75
70 // gin::Wrappable method: 76 // gin::Wrappable method:
71 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( 77 gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
72 v8::Isolate* isolate) override; 78 v8::Isolate* isolate) override;
73 79
74 private: 80 private:
75 // WebViewPlugin::Delegate methods: 81 // WebViewPlugin::Delegate methods:
76 void ShowContextMenu(const blink::WebMouseEvent&) override; 82 void PluginDestroyed() override;
77 83
78 // RenderFrameObserver methods: 84 // RenderFrameObserver methods:
79 void WasShown() override; 85 void WasShown() override;
80 86
87 // content::PluginInstanceThrottler::Observer methods:
88 void OnThrottleStateChange() override;
89
81 // Javascript callbacks: 90 // Javascript callbacks:
82 91
83 // Load the blocked plugin by calling LoadPlugin(). 92 // Load the blocked plugin by calling LoadPlugin().
84 void LoadCallback(); 93 void LoadCallback();
85 94
86 // Hide the blocked plugin by calling HidePlugin(). 95 // Hide the blocked plugin by calling HidePlugin().
87 void HideCallback(); 96 void HideCallback();
88 97
89 void DidFinishLoadingCallback(); 98 void DidFinishLoadingCallback();
90 99
(...skipping 12 matching lines...) Expand all
103 // 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.
104 // Plugin may be automatically be loaded when the page is displayed. 113 // Plugin may be automatically be loaded when the page is displayed.
105 bool is_blocked_for_prerendering_; 114 bool is_blocked_for_prerendering_;
106 115
107 // 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.
108 bool is_blocked_for_power_saver_poster_; 117 bool is_blocked_for_power_saver_poster_;
109 118
110 // 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.
111 content::PluginPowerSaverMode power_saver_mode_; 120 content::PluginPowerSaverMode power_saver_mode_;
112 121
122 // When we load, uses this premade plugin instead of creating a new one.
123 blink::WebPlugin* premade_plugin_;
124 content::PluginInstanceThrottler* premade_throttler_;
125
113 bool allow_loading_; 126 bool allow_loading_;
114 127
115 // True if the placeholder was replaced with the real plugin. 128 // True if the placeholder was replaced with the real plugin.
116 bool placeholder_was_replaced_; 129 bool placeholder_was_replaced_;
117 130
118 bool hidden_; 131 bool hidden_;
119 bool finished_loading_; 132 bool finished_loading_;
120 std::string identifier_; 133 std::string identifier_;
121 134
122 base::WeakPtrFactory<LoadablePluginPlaceholder> weak_factory_; 135 base::WeakPtrFactory<LoadablePluginPlaceholder> weak_factory_;
123 136
124 DISALLOW_COPY_AND_ASSIGN(LoadablePluginPlaceholder); 137 DISALLOW_COPY_AND_ASSIGN(LoadablePluginPlaceholder);
125 }; 138 };
126 139
127 } // namespace plugins 140 } // namespace plugins
128 141
129 #endif // COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_ 142 #endif // COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_
OLDNEW
« no previous file with comments | « chrome/renderer/resources/plugin_poster.html ('k') | components/plugins/renderer/loadable_plugin_placeholder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698