summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/blocked_plugin.h
blob: 53859bc71a612e8a265c7cf9c8a05c61905a3c4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_RENDERER_BLOCKED_PLUGIN_H_
#define CHROME_RENDERER_BLOCKED_PLUGIN_H_
#pragma once

#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
#include "chrome/renderer/custom_menu_listener.h"
#include "third_party/WebKit/WebKit/chromium/public/WebPluginParams.h"
#include "webkit/glue/cpp_bound_class.h"
#include "webkit/glue/plugins/webview_plugin.h"

class GURL;
class PluginGroup;
class RenderView;

class BlockedPlugin : public CppBoundClass,
                      public WebViewPlugin::Delegate,
                      public NotificationObserver,
                      public CustomMenuListener {
 public:
  BlockedPlugin(RenderView* render_view,
                WebKit::WebFrame* frame,
                const PluginGroup& info,
                const WebKit::WebPluginParams& params,
                const WebPreferences& settings,
                int template_id,
                const string16& message);

  WebViewPlugin* plugin() { return plugin_; }

  // WebViewPlugin::Delegate methods:
  virtual void BindWebFrame(WebKit::WebFrame* frame);
  virtual void WillDestroyPlugin();
  virtual void ShowContextMenu(const WebKit::WebMouseEvent&);

  // NotificationObserver methods:
  virtual void Observe(NotificationType type,
                       const NotificationSource& source,
                       const NotificationDetails& details);

  // CustomMenuListener methods:
  virtual void MenuItemSelected(unsigned id);

 private:
  virtual ~BlockedPlugin();

  // Javascript callbacks:
  // Load the blocked plugin by calling LoadPlugin() below.
  // Takes no arguments, and returns nothing.
  void Load(const CppArgumentList& args, CppVariant* result);

  // Load the blocked plugin.
  void LoadPlugin();

  // Hide the blocked plugin.
  void HidePlugin();

  RenderView* render_view_;
  WebKit::WebFrame* frame_;
  WebKit::WebPluginParams plugin_params_;
  WebViewPlugin* plugin_;
  // The name of the plugin that was blocked.
  string16 name_;

  NotificationRegistrar registrar_;
};

#endif  // CHROME_RENDERER_BLOCKED_PLUGIN_H_