14e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
24e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
34e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// found in the LICENSE file.
44e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
54e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#ifndef CHROME_RENDERER_PLUGINS_CHROME_PLUGIN_PLACEHOLDER_H_
64e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#define CHROME_RENDERER_PLUGINS_CHROME_PLUGIN_PLACEHOLDER_H_
74e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
84e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include "components/plugins/renderer/plugin_placeholder.h"
94e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
104e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)struct ChromeViewHostMsg_GetPluginInfo_Status;
114e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
124e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)class ChromePluginPlaceholder : public plugins::PluginPlaceholder,
134e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)                                public content::RenderProcessObserver,
144e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)                                public content::ContextMenuClient {
154e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) public:
164e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  static const char kPluginPlaceholderDataURL[];
174e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
184e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  static ChromePluginPlaceholder* CreateBlockedPlugin(
19a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      content::RenderFrame* render_frame,
20a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch      blink::WebLocalFrame* frame,
21f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      const blink::WebPluginParams& params,
224e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      const content::WebPluginInfo& info,
234e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      const std::string& identifier,
24a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      const base::string16& name,
254e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      int resource_id,
26a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      const base::string16& message);
274e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
284e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // Creates a new WebViewPlugin with a MissingPlugin as a delegate.
294e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  static ChromePluginPlaceholder* CreateMissingPlugin(
30a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      content::RenderFrame* render_frame,
31a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch      blink::WebLocalFrame* frame,
32f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      const blink::WebPluginParams& params);
334e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
344e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  static ChromePluginPlaceholder* CreateErrorPlugin(
35a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      content::RenderFrame* render_frame,
364e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      const base::FilePath& plugin_path);
374e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
384e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  void SetStatus(const ChromeViewHostMsg_GetPluginInfo_Status& status);
394e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
404e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#if defined(ENABLE_PLUGIN_INSTALLATION)
414e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  int32 CreateRoutingId();
424e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#endif
434e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
444e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) private:
45a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  ChromePluginPlaceholder(content::RenderFrame* render_frame,
46a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch                          blink::WebLocalFrame* frame,
47f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)                          const blink::WebPluginParams& params,
484e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)                          const std::string& html_data,
49a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                          const base::string16& title);
504e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  virtual ~ChromePluginPlaceholder();
514e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
524e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // WebViewPlugin::Delegate (via PluginPlaceholder) method
53f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  virtual void BindWebFrame(blink::WebFrame* frame) OVERRIDE;
544e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // gin::Wrappable (via PluginPlaceholder) method
565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      v8::Isolate* isolate) OVERRIDE;
585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
594e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // content::RenderViewObserver (via PluginPlaceholder) override:
604e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
614e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
624e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // WebViewPlugin::Delegate (via PluginPlaceholder) methods:
63f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  virtual void ShowContextMenu(const blink::WebMouseEvent&) OVERRIDE;
644e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
654e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // content::RenderProcessObserver methods:
664e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  virtual void PluginListChanged() OVERRIDE;
674e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
684e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // content::ContextMenuClient methods:
694e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  virtual void OnMenuAction(int request_id, unsigned action) OVERRIDE;
704e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  virtual void OnMenuClosed(int request_id) OVERRIDE;
714e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
724e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // Javascript callback opens chrome://plugins in a new tab.
735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void OpenAboutPluginsCallback();
744e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
754e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  void OnLoadBlockedPlugins(const std::string& identifier);
764e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  void OnSetIsPrerendering(bool is_prerendering);
774e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#if defined(ENABLE_PLUGIN_INSTALLATION)
784e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  void OnDidNotFindMissingPlugin();
79a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  void OnFoundMissingPlugin(const base::string16& plugin_name);
804e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  void OnStartedDownloadingPlugin();
814e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  void OnFinishedDownloadingPlugin();
824e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  void OnErrorDownloadingPlugin(const std::string& error);
834e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  void OnCancelledDownloadingPlugin();
844e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#endif
854e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
864e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // We use a scoped_ptr so we can forward-declare the struct; it's defined in
874e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // an IPC message file which can't be easily included in other header files.
884e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  scoped_ptr<ChromeViewHostMsg_GetPluginInfo_Status> status_;
894e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
90a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  base::string16 title_;
914e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
924e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#if defined(ENABLE_PLUGIN_INSTALLATION)
934e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // |routing_id()| is the routing ID of our associated RenderView, but we have
944e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // a separate routing ID for messages specific to this placeholder.
954e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  int32 placeholder_routing_id_;
964e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#endif
974e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
984e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  bool has_host_;
994e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  int context_menu_request_id_;  // Nonzero when request pending.
100a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  base::string16 plugin_name_;
101a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
1024e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(ChromePluginPlaceholder);
1034e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)};
1044e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
1054e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#endif  // CHROME_RENDERER_PLUGINS_CHROME_PLUGIN_PLACEHOLDER_H_
106