OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_WEBPLUGIN_DELEGATE_PROXY_H__ | 5 #ifndef CHROME_RENDERER_WEBPLUGIN_DELEGATE_PROXY_H__ |
6 #define CHROME_RENDERER_WEBPLUGIN_DELEGATE_PROXY_H__ | 6 #define CHROME_RENDERER_WEBPLUGIN_DELEGATE_PROXY_H__ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/gfx/rect.h" | 12 #include "base/gfx/rect.h" |
13 #include "base/gfx/native_widget_types.h" | 13 #include "base/gfx/native_widget_types.h" |
14 #include "base/ref_counted.h" | 14 #include "base/ref_counted.h" |
| 15 #include "base/weak_ptr.h" |
15 #include "chrome/common/transport_dib.h" | 16 #include "chrome/common/transport_dib.h" |
16 #include "chrome/renderer/plugin_channel_host.h" | 17 #include "chrome/renderer/plugin_channel_host.h" |
17 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
18 #include "ipc/ipc_message.h" | 19 #include "ipc/ipc_message.h" |
19 #include "skia/ext/platform_canvas.h" | 20 #include "skia/ext/platform_canvas.h" |
20 #include "webkit/glue/webplugin.h" | 21 #include "webkit/glue/webplugin.h" |
21 #include "webkit/glue/webplugin_delegate.h" | 22 #include "webkit/glue/webplugin_delegate.h" |
22 | 23 |
23 struct NPObject; | 24 struct NPObject; |
24 class NPObjectStub; | 25 class NPObjectStub; |
25 struct NPVariant_Param; | 26 struct NPVariant_Param; |
26 struct PluginHostMsg_URLRequest_Params; | 27 struct PluginHostMsg_URLRequest_Params; |
27 class RenderView; | 28 class RenderView; |
28 class SkBitmap; | 29 class SkBitmap; |
29 | 30 |
30 namespace base { | 31 namespace base { |
31 class SharedMemory; | 32 class SharedMemory; |
32 class WaitableEvent; | 33 class WaitableEvent; |
33 } | 34 } |
34 | 35 |
35 // An implementation of WebPluginDelegate that proxies all calls to | 36 // An implementation of WebPluginDelegate that proxies all calls to |
36 // the plugin process. | 37 // the plugin process. |
37 class WebPluginDelegateProxy : public WebPluginDelegate, | 38 class WebPluginDelegateProxy : |
38 public IPC::Channel::Listener, | 39 public webkit_glue::WebPluginDelegate, |
39 public IPC::Message::Sender { | 40 public IPC::Channel::Listener, |
| 41 public IPC::Message::Sender, |
| 42 public base::SupportsWeakPtr<WebPluginDelegateProxy> { |
40 public: | 43 public: |
41 static WebPluginDelegateProxy* Create(const GURL& url, | 44 static WebPluginDelegateProxy* Create( |
42 const std::string& mime_type, | 45 const GURL& url, |
43 const std::string& clsid, | 46 const std::string& mime_type, |
44 RenderView* render_view); | 47 const std::string& clsid, |
45 | 48 const base::WeakPtr<RenderView>& render_view); |
46 // Called to drop our back-pointer to the containing RenderView. | |
47 void DropRenderView() { render_view_ = NULL; } | |
48 | 49 |
49 // Called to drop our pointer to the window script object. | 50 // Called to drop our pointer to the window script object. |
50 void DropWindowScriptObject() { window_script_object_ = NULL; } | 51 void DropWindowScriptObject() { window_script_object_ = NULL; } |
51 | 52 |
52 // WebPluginDelegate implementation: | 53 // WebPluginDelegate implementation: |
53 virtual void PluginDestroyed(); | 54 virtual void PluginDestroyed(); |
54 virtual bool Initialize(const GURL& url, char** argn, char** argv, int argc, | 55 virtual bool Initialize(const GURL& url, char** argn, char** argv, int argc, |
55 WebPlugin* plugin, bool load_manually); | 56 webkit_glue::WebPlugin* plugin, bool load_manually); |
56 virtual void UpdateGeometry(const gfx::Rect& window_rect, | 57 virtual void UpdateGeometry(const gfx::Rect& window_rect, |
57 const gfx::Rect& clip_rect); | 58 const gfx::Rect& clip_rect); |
58 virtual void Paint(gfx::NativeDrawingContext context, const gfx::Rect& rect); | 59 virtual void Paint(gfx::NativeDrawingContext context, const gfx::Rect& rect); |
59 virtual void Print(gfx::NativeDrawingContext context); | 60 virtual void Print(gfx::NativeDrawingContext context); |
60 virtual NPObject* GetPluginScriptableObject(); | 61 virtual NPObject* GetPluginScriptableObject(); |
61 virtual void DidFinishLoadWithReason(const GURL& url, NPReason reason, | 62 virtual void DidFinishLoadWithReason(const GURL& url, NPReason reason, |
62 intptr_t notify_data); | 63 intptr_t notify_data); |
63 virtual void SetFocus(); | 64 virtual void SetFocus(); |
64 virtual bool HandleInputEvent(const WebKit::WebInputEvent& event, | 65 virtual bool HandleInputEvent(const WebKit::WebInputEvent& event, |
65 WebKit::WebCursorInfo* cursor); | 66 WebKit::WebCursorInfo* cursor); |
(...skipping 14 matching lines...) Expand all Loading... |
80 virtual void DidReceiveManualResponse(const GURL& url, | 81 virtual void DidReceiveManualResponse(const GURL& url, |
81 const std::string& mime_type, | 82 const std::string& mime_type, |
82 const std::string& headers, | 83 const std::string& headers, |
83 uint32 expected_length, | 84 uint32 expected_length, |
84 uint32 last_modified); | 85 uint32 last_modified); |
85 virtual void DidReceiveManualData(const char* buffer, int length); | 86 virtual void DidReceiveManualData(const char* buffer, int length); |
86 virtual void DidFinishManualLoading(); | 87 virtual void DidFinishManualLoading(); |
87 virtual void DidManualLoadFail(); | 88 virtual void DidManualLoadFail(); |
88 virtual FilePath GetPluginPath(); | 89 virtual FilePath GetPluginPath(); |
89 virtual void InstallMissingPlugin(); | 90 virtual void InstallMissingPlugin(); |
90 virtual WebPluginResourceClient* CreateResourceClient(int resource_id, | 91 virtual webkit_glue::WebPluginResourceClient* CreateResourceClient( |
91 const GURL& url, | 92 int resource_id, |
92 bool notify_needed, | 93 const GURL& url, |
93 intptr_t notify_data, | 94 bool notify_needed, |
94 intptr_t existing_stream
); | 95 intptr_t notify_data, |
| 96 intptr_t existing_stream); |
| 97 virtual bool IsWindowless() const; |
| 98 virtual gfx::Rect GetRect() const; |
| 99 virtual gfx::Rect GetClipRect() const; |
| 100 virtual int GetQuirks() const; |
95 | 101 |
96 protected: | 102 protected: |
97 template<class WebPluginDelegateProxy> friend class DeleteTask; | 103 template<class WebPluginDelegateProxy> friend class DeleteTask; |
98 ~WebPluginDelegateProxy(); | 104 ~WebPluginDelegateProxy(); |
99 | 105 |
100 private: | 106 private: |
101 WebPluginDelegateProxy(const std::string& mime_type, | 107 WebPluginDelegateProxy(const std::string& mime_type, |
102 const std::string& clsid, | 108 const std::string& clsid, |
103 RenderView* render_view); | 109 const base::WeakPtr<RenderView>& render_view); |
104 | 110 |
105 // Message handlers for messages that proxy WebPlugin methods, which | 111 // Message handlers for messages that proxy WebPlugin methods, which |
106 // we translate into calls to the real WebPlugin. | 112 // we translate into calls to the real WebPlugin. |
107 void OnSetWindow(gfx::PluginWindowHandle window); | 113 void OnSetWindow(gfx::PluginWindowHandle window); |
108 #if defined(OS_WIN) | 114 #if defined(OS_WIN) |
109 void OnSetWindowlessPumpEvent(HANDLE modal_loop_pump_messages_event); | 115 void OnSetWindowlessPumpEvent(HANDLE modal_loop_pump_messages_event); |
110 #endif | 116 #endif |
111 void OnCompleteURL(const std::string& url_in, std::string* url_out, | 117 void OnCompleteURL(const std::string& url_in, std::string* url_out, |
112 bool* result); | 118 bool* result); |
113 void OnHandleURLRequest(const PluginHostMsg_URLRequest_Params& params); | 119 void OnHandleURLRequest(const PluginHostMsg_URLRequest_Params& params); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 160 |
155 // Creates a shared memory section and canvas. | 161 // Creates a shared memory section and canvas. |
156 bool CreateBitmap(scoped_ptr<TransportDIB>* memory, | 162 bool CreateBitmap(scoped_ptr<TransportDIB>* memory, |
157 scoped_ptr<skia::PlatformCanvas>* canvas); | 163 scoped_ptr<skia::PlatformCanvas>* canvas); |
158 | 164 |
159 // Called for cleanup during plugin destruction. Normally right before the | 165 // Called for cleanup during plugin destruction. Normally right before the |
160 // plugin window gets destroyed, or when the plugin has crashed (at which | 166 // plugin window gets destroyed, or when the plugin has crashed (at which |
161 // point the window has already been destroyed). | 167 // point the window has already been destroyed). |
162 void WillDestroyWindow(); | 168 void WillDestroyWindow(); |
163 | 169 |
164 RenderView* render_view_; | 170 base::WeakPtr<RenderView> render_view_; |
165 WebPlugin* plugin_; | 171 webkit_glue::WebPlugin* plugin_; |
166 bool windowless_; | 172 bool windowless_; |
167 gfx::PluginWindowHandle window_; | 173 gfx::PluginWindowHandle window_; |
168 scoped_refptr<PluginChannelHost> channel_host_; | 174 scoped_refptr<PluginChannelHost> channel_host_; |
169 std::string mime_type_; | 175 std::string mime_type_; |
170 std::string clsid_; | 176 std::string clsid_; |
171 int instance_id_; | 177 int instance_id_; |
172 FilePath plugin_path_; | 178 FilePath plugin_path_; |
173 | 179 |
174 gfx::Rect plugin_rect_; | 180 gfx::Rect plugin_rect_; |
175 | 181 |
(...skipping 25 matching lines...) Expand all Loading... |
201 // This lets us know which portion of the backing store has been painted into. | 207 // This lets us know which portion of the backing store has been painted into. |
202 gfx::Rect backing_store_painted_; | 208 gfx::Rect backing_store_painted_; |
203 | 209 |
204 // The url of the main frame hosting the plugin. | 210 // The url of the main frame hosting the plugin. |
205 GURL page_url_; | 211 GURL page_url_; |
206 | 212 |
207 DISALLOW_EVIL_CONSTRUCTORS(WebPluginDelegateProxy); | 213 DISALLOW_EVIL_CONSTRUCTORS(WebPluginDelegateProxy); |
208 }; | 214 }; |
209 | 215 |
210 #endif // CHROME_RENDERER_WEBPLUGIN_DELEGATE_PROXY_H_ | 216 #endif // CHROME_RENDERER_WEBPLUGIN_DELEGATE_PROXY_H_ |
OLD | NEW |