OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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. | |
4 | |
5 #ifndef CHROME_RENDERER_BLOCKED_PLUGIN_H_ | |
6 #define CHROME_RENDERER_BLOCKED_PLUGIN_H_ | |
7 #pragma once | |
8 | |
9 #include "content/public/renderer/render_view_observer.h" | |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" | |
11 #include "webkit/glue/cpp_bound_class.h" | |
12 #include "webkit/plugins/npapi/webview_plugin.h" | |
13 #include "webkit/plugins/webplugininfo.h" | |
14 | |
15 class BlockedPlugin : public content::RenderViewObserver, | |
16 public CppBoundClass, | |
17 public webkit::npapi::WebViewPlugin::Delegate { | |
18 public: | |
19 BlockedPlugin(content::RenderView* render_view, | |
20 WebKit::WebFrame* frame, | |
21 const webkit::WebPluginInfo& info, | |
22 const WebKit::WebPluginParams& params, | |
23 const WebPreferences& settings, | |
24 int template_id, | |
25 const string16& name, | |
26 const string16& message, | |
27 bool is_blocked_for_prerendering, | |
28 bool allow_loading); | |
29 | |
30 webkit::npapi::WebViewPlugin* plugin() { return plugin_; } | |
31 | |
32 // WebViewPlugin::Delegate methods: | |
33 virtual void BindWebFrame(WebKit::WebFrame* frame) OVERRIDE; | |
34 virtual void WillDestroyPlugin() OVERRIDE; | |
35 virtual void ShowContextMenu(const WebKit::WebMouseEvent&) OVERRIDE; | |
36 | |
37 private: | |
38 virtual ~BlockedPlugin(); | |
39 | |
40 // RenderViewObserver methods: | |
41 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
42 virtual void ContextMenuAction(unsigned id) OVERRIDE; | |
43 | |
44 void OnLoadBlockedPlugins(); | |
45 void OnSetIsPrerendering(bool is_prerendering); | |
46 | |
47 // Javascript callbacks: | |
48 // Load the blocked plugin by calling LoadPlugin(). | |
49 // Takes no arguments, and returns nothing. | |
50 void LoadCallback(const CppArgumentList& args, CppVariant* result); | |
51 | |
52 // Hide the blocked plugin by calling HidePlugin(). | |
53 // Takes no arguments, and returns nothing. | |
54 void HideCallback(const CppArgumentList& args, CppVariant* result); | |
55 | |
56 // Opens a URL in a new tab. | |
57 // Takes one argument, a string specifying the URL to open. Returns nothing. | |
58 void OpenUrlCallback(const CppArgumentList& args, CppVariant* result); | |
59 | |
60 // Load the blocked plugin. | |
61 void LoadPlugin(); | |
62 | |
63 // Hide the blocked plugin. | |
64 void HidePlugin(); | |
65 | |
66 WebKit::WebFrame* frame_; | |
67 webkit::WebPluginInfo plugin_info_; | |
68 WebKit::WebPluginParams plugin_params_; | |
69 webkit::npapi::WebViewPlugin* plugin_; | |
70 // The name of the plugin that was blocked. | |
71 string16 name_; | |
72 // True iff the plugin was blocked because the page was being prerendered. | |
73 // Plugin will automatically be loaded when the page is displayed. | |
74 bool is_blocked_for_prerendering_; | |
75 bool hidden_; | |
76 bool allow_loading_; | |
77 }; | |
78 | |
79 #endif // CHROME_RENDERER_BLOCKED_PLUGIN_H_ | |
OLD | NEW |