Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / chrome / renderer / plugins / chrome_plugin_placeholder.h
blobd7ecf76a3df2f7601239af645e3d873f139cec6c
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"
12 namespace gfx {
13 class Size;
16 struct 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|.
25 GURL base_url;
27 // Specify this to provide partially obscured plugins a centered poster image.
28 gfx::Size custom_poster_size;
31 class ChromePluginPlaceholder : public plugins::LoadablePluginPlaceholder,
32 public content::RenderProcessObserver,
33 public content::ContextMenuClient {
34 public:
35 static const char kPluginPlaceholderDataURL[];
37 static ChromePluginPlaceholder* CreateBlockedPlugin(
38 content::RenderFrame* render_frame,
39 blink::WebLocalFrame* frame,
40 const blink::WebPluginParams& params,
41 const content::WebPluginInfo& info,
42 const std::string& identifier,
43 const base::string16& name,
44 int resource_id,
45 const base::string16& message,
46 const PlaceholderPosterInfo& poster_info);
48 // Creates a new WebViewPlugin with a MissingPlugin as a delegate.
49 static ChromePluginPlaceholder* CreateMissingPlugin(
50 content::RenderFrame* render_frame,
51 blink::WebLocalFrame* frame,
52 const blink::WebPluginParams& params);
54 static ChromePluginPlaceholder* CreateErrorPlugin(
55 content::RenderFrame* render_frame,
56 const base::FilePath& plugin_path);
58 void SetStatus(const ChromeViewHostMsg_GetPluginInfo_Status& status);
60 #if defined(ENABLE_PLUGIN_INSTALLATION)
61 int32 CreateRoutingId();
62 #endif
64 private:
65 ChromePluginPlaceholder(content::RenderFrame* render_frame,
66 blink::WebLocalFrame* frame,
67 const blink::WebPluginParams& params,
68 const std::string& html_data,
69 const base::string16& title);
70 ~ChromePluginPlaceholder() override;
72 // WebViewPlugin::Delegate (via PluginPlaceholder) method
73 void BindWebFrame(blink::WebFrame* frame) override;
75 // gin::Wrappable (via PluginPlaceholder) method
76 gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
77 v8::Isolate* isolate) override;
79 // content::RenderViewObserver (via PluginPlaceholder) override:
80 bool OnMessageReceived(const IPC::Message& message) override;
82 // WebViewPlugin::Delegate (via PluginPlaceholder) methods:
83 void ShowContextMenu(const blink::WebMouseEvent&) override;
85 // content::RenderProcessObserver methods:
86 void PluginListChanged() override;
88 // content::ContextMenuClient methods:
89 void OnMenuAction(int request_id, unsigned action) override;
90 void OnMenuClosed(int request_id) override;
92 // Javascript callback opens chrome://plugins in a new tab.
93 void OpenAboutPluginsCallback();
95 #if defined(ENABLE_PLUGIN_INSTALLATION)
96 void OnDidNotFindMissingPlugin();
97 void OnFoundMissingPlugin(const base::string16& plugin_name);
98 void OnStartedDownloadingPlugin();
99 void OnFinishedDownloadingPlugin();
100 void OnErrorDownloadingPlugin(const std::string& error);
101 void OnCancelledDownloadingPlugin();
102 #endif
104 // We use a scoped_ptr so we can forward-declare the struct; it's defined in
105 // an IPC message file which can't be easily included in other header files.
106 scoped_ptr<ChromeViewHostMsg_GetPluginInfo_Status> status_;
108 base::string16 title_;
110 #if defined(ENABLE_PLUGIN_INSTALLATION)
111 // |routing_id()| is the routing ID of our associated RenderView, but we have
112 // a separate routing ID for messages specific to this placeholder.
113 int32 placeholder_routing_id_;
114 #endif
116 bool has_host_;
117 int context_menu_request_id_; // Nonzero when request pending.
118 base::string16 plugin_name_;
120 DISALLOW_COPY_AND_ASSIGN(ChromePluginPlaceholder);
123 #endif // CHROME_RENDERER_PLUGINS_CHROME_PLUGIN_PLACEHOLDER_H_