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 CHROME_RENDERER_PLUGINS_CHROME_PLUGIN_PLACEHOLDER_H_
6 #define CHROME_RENDERER_PLUGINS_CHROME_PLUGIN_PLACEHOLDER_H_
8 #include "components/plugins/renderer/loadable_plugin_placeholder.h"
9 #include "content/public/renderer/context_menu_client.h"
10 #include "content/public/renderer/render_process_observer.h"
16 enum class ChromeViewHostMsg_GetPluginInfo_Status
;
18 // This contains information specifying the poster image of plugin placeholders.
19 // The default constructor specifies no poster image.
20 struct PlaceholderPosterInfo
{
21 // The poster image specified in image 'srcset' attribute format.
22 std::string poster_attribute
;
24 // Used to resolve relative paths in |poster_attribute|.
27 // Specify this to provide partially obscured plugins a centered poster image.
28 gfx::Size custom_poster_size
;
31 class ChromePluginPlaceholder final
32 : public plugins::LoadablePluginPlaceholder
,
33 public content::RenderProcessObserver
,
34 public content::ContextMenuClient
,
35 public gin::Wrappable
<ChromePluginPlaceholder
> {
37 static gin::WrapperInfo kWrapperInfo
;
39 static ChromePluginPlaceholder
* CreateBlockedPlugin(
40 content::RenderFrame
* render_frame
,
41 blink::WebLocalFrame
* frame
,
42 const blink::WebPluginParams
& params
,
43 const content::WebPluginInfo
& info
,
44 const std::string
& identifier
,
45 const base::string16
& name
,
47 const base::string16
& message
,
48 const PlaceholderPosterInfo
& poster_info
);
50 // Creates a new WebViewPlugin with a MissingPlugin as a delegate.
51 static ChromePluginPlaceholder
* CreateLoadableMissingPlugin(
52 content::RenderFrame
* render_frame
,
53 blink::WebLocalFrame
* frame
,
54 const blink::WebPluginParams
& params
);
56 void SetStatus(ChromeViewHostMsg_GetPluginInfo_Status status
);
58 #if defined(ENABLE_PLUGIN_INSTALLATION)
59 int32
CreateRoutingId();
63 ChromePluginPlaceholder(content::RenderFrame
* render_frame
,
64 blink::WebLocalFrame
* frame
,
65 const blink::WebPluginParams
& params
,
66 const std::string
& html_data
,
67 const base::string16
& title
);
68 ~ChromePluginPlaceholder() override
;
70 // content::LoadablePluginPlaceholder method
71 blink::WebPlugin
* CreatePlugin() override
;
73 // gin::Wrappable (via PluginPlaceholder) method
74 gin::ObjectTemplateBuilder
GetObjectTemplateBuilder(
75 v8::Isolate
* isolate
) final
;
77 // content::RenderViewObserver (via PluginPlaceholder) override:
78 bool OnMessageReceived(const IPC::Message
& message
) override
;
80 // WebViewPlugin::Delegate (via PluginPlaceholder) methods:
81 v8::Local
<v8::Value
> GetV8Handle(v8::Isolate
* isolate
) override
;
82 void ShowContextMenu(const blink::WebMouseEvent
&) override
;
84 // content::RenderProcessObserver methods:
85 void PluginListChanged() override
;
87 // content::ContextMenuClient methods:
88 void OnMenuAction(int request_id
, unsigned action
) override
;
89 void OnMenuClosed(int request_id
) override
;
91 // Javascript callbacks:
92 // Open chrome://plugins in a new tab.
93 void OpenAboutPluginsCallback();
95 // IPC message handlers:
96 #if defined(ENABLE_PLUGIN_INSTALLATION)
97 void OnDidNotFindMissingPlugin();
98 void OnFoundMissingPlugin(const base::string16
& plugin_name
);
99 void OnStartedDownloadingPlugin();
100 void OnFinishedDownloadingPlugin();
101 void OnErrorDownloadingPlugin(const std::string
& error
);
102 void OnCancelledDownloadingPlugin();
105 ChromeViewHostMsg_GetPluginInfo_Status status_
;
107 base::string16 title_
;
109 #if defined(ENABLE_PLUGIN_INSTALLATION)
110 // |routing_id()| is the routing ID of our associated RenderView, but we have
111 // a separate routing ID for messages specific to this placeholder.
112 int32 placeholder_routing_id_
;
116 int context_menu_request_id_
; // Nonzero when request pending.
117 base::string16 plugin_name_
;
119 DISALLOW_COPY_AND_ASSIGN(ChromePluginPlaceholder
);
122 #endif // CHROME_RENDERER_PLUGINS_CHROME_PLUGIN_PLACEHOLDER_H_