Unregister from GCM when the only GCM app is removed
[chromium-blink-merge.git] / chrome / renderer / plugins / chrome_plugin_placeholder.h
blobe9adb07f465c14edc3c173fbd2b05e89d974d347
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 struct ChromeViewHostMsg_GetPluginInfo_Status;
14 class ChromePluginPlaceholder : public plugins::LoadablePluginPlaceholder,
15 public content::RenderProcessObserver,
16 public content::ContextMenuClient {
17 public:
18 static const char kPluginPlaceholderDataURL[];
20 static ChromePluginPlaceholder* CreateBlockedPlugin(
21 content::RenderFrame* render_frame,
22 blink::WebLocalFrame* frame,
23 const blink::WebPluginParams& params,
24 const content::WebPluginInfo& info,
25 const std::string& identifier,
26 const base::string16& name,
27 int resource_id,
28 const base::string16& message,
29 const GURL& poster_url);
31 // Creates a new WebViewPlugin with a MissingPlugin as a delegate.
32 static ChromePluginPlaceholder* CreateMissingPlugin(
33 content::RenderFrame* render_frame,
34 blink::WebLocalFrame* frame,
35 const blink::WebPluginParams& params);
37 static ChromePluginPlaceholder* CreateErrorPlugin(
38 content::RenderFrame* render_frame,
39 const base::FilePath& plugin_path);
41 void SetStatus(const ChromeViewHostMsg_GetPluginInfo_Status& status);
43 #if defined(ENABLE_PLUGIN_INSTALLATION)
44 int32 CreateRoutingId();
45 #endif
47 private:
48 ChromePluginPlaceholder(content::RenderFrame* render_frame,
49 blink::WebLocalFrame* frame,
50 const blink::WebPluginParams& params,
51 const std::string& html_data,
52 const base::string16& title);
53 ~ChromePluginPlaceholder() override;
55 // WebViewPlugin::Delegate (via PluginPlaceholder) method
56 void BindWebFrame(blink::WebFrame* frame) override;
58 // gin::Wrappable (via PluginPlaceholder) method
59 gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
60 v8::Isolate* isolate) override;
62 // content::RenderViewObserver (via PluginPlaceholder) override:
63 bool OnMessageReceived(const IPC::Message& message) override;
65 // WebViewPlugin::Delegate (via PluginPlaceholder) methods:
66 void ShowContextMenu(const blink::WebMouseEvent&) override;
68 // content::RenderProcessObserver methods:
69 void PluginListChanged() override;
71 // content::ContextMenuClient methods:
72 void OnMenuAction(int request_id, unsigned action) override;
73 void OnMenuClosed(int request_id) override;
75 // Javascript callback opens chrome://plugins in a new tab.
76 void OpenAboutPluginsCallback();
78 #if defined(ENABLE_PLUGIN_INSTALLATION)
79 void OnDidNotFindMissingPlugin();
80 void OnFoundMissingPlugin(const base::string16& plugin_name);
81 void OnStartedDownloadingPlugin();
82 void OnFinishedDownloadingPlugin();
83 void OnErrorDownloadingPlugin(const std::string& error);
84 void OnCancelledDownloadingPlugin();
85 #endif
87 // We use a scoped_ptr so we can forward-declare the struct; it's defined in
88 // an IPC message file which can't be easily included in other header files.
89 scoped_ptr<ChromeViewHostMsg_GetPluginInfo_Status> status_;
91 base::string16 title_;
93 #if defined(ENABLE_PLUGIN_INSTALLATION)
94 // |routing_id()| is the routing ID of our associated RenderView, but we have
95 // a separate routing ID for messages specific to this placeholder.
96 int32 placeholder_routing_id_;
97 #endif
99 bool has_host_;
100 int context_menu_request_id_; // Nonzero when request pending.
101 base::string16 plugin_name_;
103 DISALLOW_COPY_AND_ASSIGN(ChromePluginPlaceholder);
106 #endif // CHROME_RENDERER_PLUGINS_CHROME_PLUGIN_PLACEHOLDER_H_