Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1279)

Side by Side Diff: components/plugins/renderer/plugin_placeholder.h

Issue 69953006: Bind plugin placeholder directly to v8 instead of over CppBoundClass (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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 COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_ 5 #ifndef COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_
6 #define COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_ 6 #define COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_
7 7
8 #include "components/plugins/renderer/webview_plugin.h" 8 #include "components/plugins/renderer/webview_plugin.h"
9 #include "content/public/common/webplugininfo.h" 9 #include "content/public/common/webplugininfo.h"
10 #include "content/public/renderer/context_menu_client.h" 10 #include "content/public/renderer/context_menu_client.h"
11 #include "content/public/renderer/render_process_observer.h" 11 #include "content/public/renderer/render_process_observer.h"
12 #include "content/public/renderer/render_view_observer.h" 12 #include "content/public/renderer/render_view_observer.h"
13 #include "third_party/WebKit/public/web/WebPluginParams.h" 13 #include "third_party/WebKit/public/web/WebPluginParams.h"
14 #include "webkit/renderer/cpp_bound_class.h" 14 #include "v8/include/v8.h"
15 15
16 namespace content { 16 namespace content {
17 struct WebPluginInfo; 17 struct WebPluginInfo;
18 } 18 }
19 19
20 namespace plugins { 20 namespace plugins {
21 // Placeholders can be used if a plug-in is missing or not available 21 // Placeholders can be used if a plug-in is missing or not available
22 // (blocked or disabled). 22 // (blocked or disabled).
23 class PluginPlaceholder : public content::RenderViewObserver, 23 class PluginPlaceholder : public content::RenderViewObserver,
24 public webkit_glue::CppBoundClass,
25 public WebViewPlugin::Delegate { 24 public WebViewPlugin::Delegate {
26 public: 25 public:
27 26
28 WebViewPlugin* plugin() { return plugin_; } 27 WebViewPlugin* plugin() { return plugin_; }
29 28
30 void set_blocked_for_prerendering(bool blocked_for_prerendering) { 29 void set_blocked_for_prerendering(bool blocked_for_prerendering) {
31 is_blocked_for_prerendering_ = blocked_for_prerendering; 30 is_blocked_for_prerendering_ = blocked_for_prerendering;
32 } 31 }
33 32
34 void set_allow_loading(bool allow_loading) { allow_loading_ = allow_loading; } 33 void set_allow_loading(bool allow_loading) { allow_loading_ = allow_loading; }
35 34
36 protected: 35 protected:
37 // |render_view| and |frame| are weak pointers. If either one is going away, 36 // |render_view| and |frame| are weak pointers. If either one is going away,
38 // our |plugin_| will be destroyed as well and will notify us. 37 // our |plugin_| will be destroyed as well and will notify us.
39 PluginPlaceholder(content::RenderView* render_view, 38 PluginPlaceholder(content::RenderView* render_view,
40 blink::WebFrame* frame, 39 blink::WebFrame* frame,
41 const blink::WebPluginParams& params, 40 const blink::WebPluginParams& params,
42 const std::string& html_data, 41 const std::string& html_data,
43 GURL placeholderDataUrl); 42 GURL placeholderDataUrl);
44 43
45 virtual ~PluginPlaceholder(); 44 virtual ~PluginPlaceholder();
46 45
46 // Derived classes can override this method to install additional V8
47 // properties on the prototype of the window.plugin object.
48 virtual void InstallAdditionalCallbacks(v8::Handle<v8::Template> prototype);
Bernhard Bauer 2013/11/12 16:37:20 Super-nit: From the description of the method it s
49
47 void OnLoadBlockedPlugins(const std::string& identifier); 50 void OnLoadBlockedPlugins(const std::string& identifier);
48 void OnSetIsPrerendering(bool is_prerendering); 51 void OnSetIsPrerendering(bool is_prerendering);
49 52
50 void SetMessage(const string16& message); 53 void SetMessage(const string16& message);
51 void SetPluginInfo(const content::WebPluginInfo& plugin_info); 54 void SetPluginInfo(const content::WebPluginInfo& plugin_info);
52 const content::WebPluginInfo& GetPluginInfo() const; 55 const content::WebPluginInfo& GetPluginInfo() const;
53 void SetIdentifier(const std::string& identifier); 56 void SetIdentifier(const std::string& identifier);
54 blink::WebFrame* GetFrame(); 57 blink::WebFrame* GetFrame();
55 const blink::WebPluginParams& GetPluginParams() const; 58 const blink::WebPluginParams& GetPluginParams() const;
56 bool LoadingAllowed() const { return allow_loading_; } 59 bool LoadingAllowed() const { return allow_loading_; }
(...skipping 10 matching lines...) Expand all
67 70
68 // WebViewPlugin::Delegate method: 71 // WebViewPlugin::Delegate method:
69 virtual void BindWebFrame(blink::WebFrame* frame) OVERRIDE; 72 virtual void BindWebFrame(blink::WebFrame* frame) OVERRIDE;
70 73
71 private: 74 private:
72 // WebViewPlugin::Delegate methods: 75 // WebViewPlugin::Delegate methods:
73 virtual void WillDestroyPlugin() OVERRIDE; 76 virtual void WillDestroyPlugin() OVERRIDE;
74 virtual void ShowContextMenu(const blink::WebMouseEvent&) OVERRIDE; 77 virtual void ShowContextMenu(const blink::WebMouseEvent&) OVERRIDE;
75 78
76 // Javascript callbacks: 79 // Javascript callbacks:
77 // All ignore arguments (which are, however, required by caller) and return
78 // nothing.
79 80
80 // Load the blocked plugin by calling LoadPlugin(). 81 // Load the blocked plugin by calling LoadPlugin().
81 void LoadCallback(const webkit_glue::CppArgumentList& args, 82 static void LoadCallback(const v8::FunctionCallbackInfo<v8::Value>& args);
82 webkit_glue::CppVariant* result);
83 83
84 // Hide the blocked plugin by calling HidePlugin(). 84 // Hide the blocked plugin by calling HidePlugin().
85 void HideCallback(const webkit_glue::CppArgumentList& args, 85 static void HideCallback(const v8::FunctionCallbackInfo<v8::Value>& args);
86 webkit_glue::CppVariant* result);
87 86
88 void DidFinishLoadingCallback(const webkit_glue::CppArgumentList& args, 87 static void DidFinishLoadingCallback(
89 webkit_glue::CppVariant* result); 88 const v8::FunctionCallbackInfo<v8::Value>& args);
90 89
91 void UpdateMessage(); 90 void UpdateMessage();
92 91
93 blink::WebFrame* frame_; 92 blink::WebFrame* frame_;
94 blink::WebPluginParams plugin_params_; 93 blink::WebPluginParams plugin_params_;
95 WebViewPlugin* plugin_; 94 WebViewPlugin* plugin_;
96 95
97 content::WebPluginInfo plugin_info_; 96 content::WebPluginInfo plugin_info_;
98 97
99 string16 message_; 98 string16 message_;
100 99
101 // True iff the plugin was blocked because the page was being prerendered. 100 // True iff the plugin was blocked because the page was being prerendered.
102 // Plugin will automatically be loaded when the page is displayed. 101 // Plugin will automatically be loaded when the page is displayed.
103 bool is_blocked_for_prerendering_; 102 bool is_blocked_for_prerendering_;
104 bool allow_loading_; 103 bool allow_loading_;
105 104
106 bool hidden_; 105 bool hidden_;
107 bool finished_loading_; 106 bool finished_loading_;
108 std::string identifier_; 107 std::string identifier_;
109 108
110 DISALLOW_COPY_AND_ASSIGN(PluginPlaceholder); 109 DISALLOW_COPY_AND_ASSIGN(PluginPlaceholder);
111 }; 110 };
112 111
113 } // namespace plugins 112 } // namespace plugins
114 113
115 #endif // COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_ 114 #endif // COMPONENTS_PLUGINS_RENDERER_PLUGIN_PLACEHOLDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698