Android Chromoting: Remove exit-fullscreen button.
[chromium-blink-merge.git] / components / plugins / renderer / loadable_plugin_placeholder.h
blobe67c86104537182898d1c84b85af0e75b5f07b05
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_
6 #define COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_
8 #include "base/memory/weak_ptr.h"
9 #include "components/plugins/renderer/plugin_placeholder.h"
10 #include "content/public/common/webplugininfo.h"
11 #include "content/public/renderer/plugin_instance_throttler.h"
13 namespace plugins {
14 // Placeholders can be used if a plugin is missing or not available
15 // (blocked or disabled).
16 class LoadablePluginPlaceholder
17 : public PluginPlaceholder,
18 public content::PluginInstanceThrottler::Observer {
19 public:
20 void set_blocked_for_background_tab(bool blocked_for_background_tab) {
21 is_blocked_for_background_tab_ = blocked_for_background_tab;
24 void set_blocked_for_prerendering(bool blocked_for_prerendering) {
25 is_blocked_for_prerendering_ = blocked_for_prerendering;
28 #if defined(ENABLE_PLUGINS)
29 void set_power_saver_enabled(bool power_saver_enabled) {
30 power_saver_enabled_ = power_saver_enabled;
33 // Defer loading of plugin, and instead show the Power Saver poster image.
34 void BlockForPowerSaverPoster();
35 #endif
37 void set_allow_loading(bool allow_loading) { allow_loading_ = allow_loading; }
39 // When we load the plugin, use this already-created plugin, not a new one.
40 void SetPremadePlugin(content::PluginInstanceThrottler* throttler);
42 protected:
43 LoadablePluginPlaceholder(content::RenderFrame* render_frame,
44 blink::WebLocalFrame* frame,
45 const blink::WebPluginParams& params,
46 const std::string& html_data,
47 GURL placeholderDataUrl);
49 ~LoadablePluginPlaceholder() override;
51 #if defined(ENABLE_PLUGINS)
52 void MarkPluginEssential(
53 content::PluginInstanceThrottler::PowerSaverUnthrottleMethod method);
54 #endif
56 void OnLoadBlockedPlugins(const std::string& identifier);
57 void OnSetIsPrerendering(bool is_prerendering);
59 void SetMessage(const base::string16& message);
60 void SetPluginInfo(const content::WebPluginInfo& plugin_info);
61 const content::WebPluginInfo& GetPluginInfo() const;
62 void SetIdentifier(const std::string& identifier);
63 bool LoadingAllowed() const { return allow_loading_; }
65 // Replace this placeholder with a different plugin (which could be
66 // a placeholder again).
67 void ReplacePlugin(blink::WebPlugin* new_plugin);
69 // Hide this placeholder.
70 void HidePlugin();
72 // Load the blocked plugin.
73 void LoadPlugin();
75 // gin::Wrappable method:
76 gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
77 v8::Isolate* isolate) override;
79 private:
80 // WebViewPlugin::Delegate methods:
81 void PluginDestroyed() override;
83 // RenderFrameObserver methods:
84 void WasShown() override;
86 // content::PluginInstanceThrottler::Observer methods:
87 void OnThrottleStateChange() override;
89 // Javascript callbacks:
91 // Load the blocked plugin by calling LoadPlugin().
92 void LoadCallback();
94 // Hide the blocked plugin by calling HidePlugin().
95 void HideCallback();
97 void DidFinishLoadingCallback();
99 void UpdateMessage();
101 bool LoadingBlocked() const;
103 content::WebPluginInfo plugin_info_;
105 base::string16 message_;
107 // 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.
109 bool is_blocked_for_background_tab_;
111 // True if the plugin was blocked because the page was being prerendered.
112 // Plugin may be automatically be loaded when the page is displayed.
113 bool is_blocked_for_prerendering_;
115 // True if the plugin load was deferred due to a Power Saver poster.
116 bool is_blocked_for_power_saver_poster_;
118 // This is independent of deferred plugin load due to a Power Saver poster.
119 bool power_saver_enabled_;
121 // True if the plugin has been marked essential.
122 bool plugin_marked_essential_;
124 // When we load, uses this premade plugin instead of creating a new one.
125 content::PluginInstanceThrottler* premade_throttler_;
127 bool allow_loading_;
129 // True if the placeholder was replaced with the real plugin.
130 bool placeholder_was_replaced_;
132 bool hidden_;
133 bool finished_loading_;
134 std::string identifier_;
136 base::WeakPtrFactory<LoadablePluginPlaceholder> weak_factory_;
138 DISALLOW_COPY_AND_ASSIGN(LoadablePluginPlaceholder);
141 } // namespace plugins
143 #endif // COMPONENTS_PLUGINS_RENDERER_LOADABLE_PLUGIN_PLACEHOLDER_H_