Make sure webrtc::VideoSource is released when WebRtcVideoTrackAdapter is destroyed.
[chromium-blink-merge.git] / components / plugins / renderer / plugin_placeholder.h
blob3427d40549069f42c99b537b317f9a66e0a199af
1 // Copyright 2013 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_PLUGIN_PLACEHOLDER_H_
6 #define COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_
8 #include "components/plugins/renderer/webview_plugin.h"
9 #include "content/public/common/webplugininfo.h"
10 #include "content/public/renderer/context_menu_client.h"
11 #include "content/public/renderer/render_frame_observer.h"
12 #include "content/public/renderer/render_process_observer.h"
13 #include "gin/wrappable.h"
14 #include "third_party/WebKit/public/web/WebPluginParams.h"
16 namespace content {
17 struct WebPluginInfo;
20 namespace plugins {
21 // Placeholders can be used if a plug-in is missing or not available
22 // (blocked or disabled).
23 class PluginPlaceholder : public content::RenderFrameObserver,
24 public WebViewPlugin::Delegate,
25 public gin::Wrappable<PluginPlaceholder> {
26 public:
27 static gin::WrapperInfo kWrapperInfo;
29 WebViewPlugin* plugin() { return plugin_; }
31 void set_blocked_for_prerendering(bool blocked_for_prerendering) {
32 is_blocked_for_prerendering_ = blocked_for_prerendering;
35 void set_allow_loading(bool allow_loading) { allow_loading_ = allow_loading; }
37 protected:
38 // |render_frame| and |frame| are weak pointers. If either one is going away,
39 // our |plugin_| will be destroyed as well and will notify us.
40 PluginPlaceholder(content::RenderFrame* render_frame,
41 blink::WebLocalFrame* frame,
42 const blink::WebPluginParams& params,
43 const std::string& html_data,
44 GURL placeholderDataUrl);
46 virtual ~PluginPlaceholder();
48 void OnLoadBlockedPlugins(const std::string& identifier);
49 void OnSetIsPrerendering(bool is_prerendering);
51 void SetMessage(const base::string16& message);
52 void SetPluginInfo(const content::WebPluginInfo& plugin_info);
53 const content::WebPluginInfo& GetPluginInfo() const;
54 void SetIdentifier(const std::string& identifier);
55 blink::WebLocalFrame* GetFrame();
56 const blink::WebPluginParams& GetPluginParams() const;
57 bool LoadingAllowed() const { return allow_loading_; }
59 // Replace this placeholder with a different plugin (which could be
60 // a placeholder again).
61 void ReplacePlugin(blink::WebPlugin* new_plugin);
63 // Hide this placeholder.
64 void HidePlugin();
66 // Load the blocked plugin.
67 void LoadPlugin();
69 // gin::Wrappable method:
70 virtual gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
71 v8::Isolate* isolate) OVERRIDE;
73 private:
74 // WebViewPlugin::Delegate methods:
75 virtual void ShowContextMenu(const blink::WebMouseEvent&) OVERRIDE;
76 virtual void PluginDestroyed() OVERRIDE;
78 // RenderFrameObserver methods:
79 virtual void OnDestruct() OVERRIDE;
81 // Javascript callbacks:
83 // Load the blocked plugin by calling LoadPlugin().
84 void LoadCallback();
86 // Hide the blocked plugin by calling HidePlugin().
87 void HideCallback();
89 void DidFinishLoadingCallback();
91 void UpdateMessage();
93 blink::WebLocalFrame* frame_;
94 blink::WebPluginParams plugin_params_;
95 WebViewPlugin* plugin_;
97 content::WebPluginInfo plugin_info_;
99 base::string16 message_;
101 // True iff the plugin was blocked because the page was being prerendered.
102 // Plugin will automatically be loaded when the page is displayed.
103 bool is_blocked_for_prerendering_;
104 bool allow_loading_;
106 bool hidden_;
107 bool finished_loading_;
108 std::string identifier_;
110 DISALLOW_COPY_AND_ASSIGN(PluginPlaceholder);
113 } // namespace plugins
115 #endif // COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_