OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_RENDERER_BLOCKED_PLUGIN_H_ | 5 #ifndef CHROME_RENDERER_BLOCKED_PLUGIN_H_ |
6 #define CHROME_RENDERER_BLOCKED_PLUGIN_H_ | 6 #define CHROME_RENDERER_BLOCKED_PLUGIN_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "chrome/renderer/custom_menu_listener.h" | 9 #include "chrome/renderer/render_view_observer.h" |
10 #include "third_party/WebKit/WebKit/chromium/public/WebPluginParams.h" | 10 #include "third_party/WebKit/WebKit/chromium/public/WebPluginParams.h" |
11 #include "webkit/glue/cpp_bound_class.h" | 11 #include "webkit/glue/cpp_bound_class.h" |
12 #include "webkit/plugins/npapi/webview_plugin.h" | 12 #include "webkit/plugins/npapi/webview_plugin.h" |
13 | 13 |
14 class GURL; | 14 class GURL; |
15 class RenderView; | |
16 | |
17 | 15 |
18 namespace webkit { | 16 namespace webkit { |
19 namespace npapi { | 17 namespace npapi { |
20 class PluginGroup; | 18 class PluginGroup; |
21 } | 19 } |
22 } | 20 } |
23 | 21 |
24 class BlockedPlugin : public CppBoundClass, | 22 class BlockedPlugin : public RenderViewObserver, |
25 public webkit::npapi::WebViewPlugin::Delegate, | 23 public CppBoundClass, |
26 public CustomMenuListener { | 24 public webkit::npapi::WebViewPlugin::Delegate { |
27 public: | 25 public: |
28 BlockedPlugin(RenderView* render_view, | 26 BlockedPlugin(RenderView* render_view, |
29 WebKit::WebFrame* frame, | 27 WebKit::WebFrame* frame, |
30 const webkit::npapi::PluginGroup& info, | 28 const webkit::npapi::PluginGroup& info, |
31 const WebKit::WebPluginParams& params, | 29 const WebKit::WebPluginParams& params, |
32 const WebPreferences& settings, | 30 const WebPreferences& settings, |
33 int template_id, | 31 int template_id, |
34 const string16& message); | 32 const string16& message); |
35 | 33 |
36 webkit::npapi::WebViewPlugin* plugin() { return plugin_; } | 34 webkit::npapi::WebViewPlugin* plugin() { return plugin_; } |
37 | 35 |
38 // WebViewPlugin::Delegate methods: | 36 // WebViewPlugin::Delegate methods: |
39 virtual void BindWebFrame(WebKit::WebFrame* frame); | 37 virtual void BindWebFrame(WebKit::WebFrame* frame); |
40 virtual void WillDestroyPlugin(); | 38 virtual void WillDestroyPlugin(); |
41 virtual void ShowContextMenu(const WebKit::WebMouseEvent&); | 39 virtual void ShowContextMenu(const WebKit::WebMouseEvent&); |
42 | 40 |
43 // CustomMenuListener methods: | 41 private: |
44 virtual void MenuItemSelected(unsigned id); | 42 virtual ~BlockedPlugin(); |
| 43 |
| 44 // RenderViewObserver methods: |
| 45 virtual bool OnMessageReceived(const IPC::Message& message); |
| 46 |
| 47 void OnMenuItemSelected(unsigned id); |
45 | 48 |
46 // Load the blocked plugin. | 49 // Load the blocked plugin. |
47 void LoadPlugin(); | 50 void LoadPlugin(); |
48 | 51 |
49 private: | |
50 virtual ~BlockedPlugin(); | |
51 | |
52 // Javascript callbacks: | 52 // Javascript callbacks: |
53 // Load the blocked plugin by calling LoadPlugin(). | 53 // Load the blocked plugin by calling LoadPlugin(). |
54 // Takes no arguments, and returns nothing. | 54 // Takes no arguments, and returns nothing. |
55 void Load(const CppArgumentList& args, CppVariant* result); | 55 void Load(const CppArgumentList& args, CppVariant* result); |
56 | 56 |
57 // Hide the blocked plugin by calling HidePlugin(). | 57 // Hide the blocked plugin by calling HidePlugin(). |
58 // Takes no arguments, and returns nothing. | 58 // Takes no arguments, and returns nothing. |
59 void Hide(const CppArgumentList& args, CppVariant* result); | 59 void Hide(const CppArgumentList& args, CppVariant* result); |
60 | 60 |
61 // Hide the blocked plugin. | 61 // Hide the blocked plugin. |
62 void HidePlugin(); | 62 void HidePlugin(); |
63 | 63 |
64 RenderView* render_view_; | |
65 WebKit::WebFrame* frame_; | 64 WebKit::WebFrame* frame_; |
66 WebKit::WebPluginParams plugin_params_; | 65 WebKit::WebPluginParams plugin_params_; |
67 webkit::npapi::WebViewPlugin* plugin_; | 66 webkit::npapi::WebViewPlugin* plugin_; |
68 // The name of the plugin that was blocked. | 67 // The name of the plugin that was blocked. |
69 string16 name_; | 68 string16 name_; |
| 69 // True iff we're showing a custom menu. |
| 70 bool custom_menu_showing_; |
70 }; | 71 }; |
71 | 72 |
72 #endif // CHROME_RENDERER_BLOCKED_PLUGIN_H_ | 73 #endif // CHROME_RENDERER_BLOCKED_PLUGIN_H_ |
OLD | NEW |