OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_PLUGIN_WEBPLUGIN_PROXY_H_ | 5 #ifndef CONTENT_PLUGIN_WEBPLUGIN_PROXY_H_ |
6 #define CONTENT_PLUGIN_WEBPLUGIN_PROXY_H_ | 6 #define CONTENT_PLUGIN_WEBPLUGIN_PROXY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #if defined(OS_MACOSX) | 12 #if defined(OS_MACOSX) |
13 #include "base/mac/scoped_cftyperef.h" | 13 #include "base/mac/scoped_cftyperef.h" |
14 #endif | 14 #endif |
15 #include "base/memory/scoped_handle.h" | 15 #include "base/memory/scoped_handle.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/shared_memory.h" | 17 #include "base/memory/shared_memory.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/timer/timer.h" | 19 #include "base/timer/timer.h" |
20 #include "content/child/npapi/webplugin.h" | 20 #include "content/child/npapi/webplugin.h" |
21 #include "ipc/ipc_message.h" | 21 #include "ipc/ipc_message.h" |
| 22 #include "ipc/ipc_sender.h" |
22 #include "skia/ext/refptr.h" | 23 #include "skia/ext/refptr.h" |
23 #include "third_party/skia/include/core/SkCanvas.h" | 24 #include "third_party/skia/include/core/SkCanvas.h" |
24 #include "url/gurl.h" | 25 #include "url/gurl.h" |
25 #if defined(USE_X11) | 26 #if defined(USE_X11) |
26 #include "ui/base/x/x11_util.h" | 27 #include "ui/base/x/x11_util.h" |
27 #endif | 28 #endif |
28 #include "ui/gl/gpu_preference.h" | 29 #include "ui/gl/gpu_preference.h" |
29 #include "ui/surface/transport_dib.h" | 30 #include "ui/surface/transport_dib.h" |
30 | 31 |
| 32 struct PluginMsg_FetchURL_Params; |
| 33 |
31 namespace content { | 34 namespace content { |
32 class PluginChannel; | 35 class PluginChannel; |
| 36 class PluginURLFetcher; |
33 class WebPluginDelegateImpl; | 37 class WebPluginDelegateImpl; |
34 | 38 |
35 #if defined(OS_MACOSX) | 39 #if defined(OS_MACOSX) |
36 class WebPluginAcceleratedSurfaceProxy; | 40 class WebPluginAcceleratedSurfaceProxy; |
37 #endif | 41 #endif |
38 | 42 |
39 // This is an implementation of WebPlugin that proxies all calls to the | 43 // This is an implementation of WebPlugin that proxies all calls to the |
40 // renderer. | 44 // renderer. |
41 class WebPluginProxy : public WebPlugin { | 45 class WebPluginProxy : public WebPlugin, |
| 46 public IPC::Sender { |
42 public: | 47 public: |
43 // Creates a new proxy for WebPlugin, using the given sender to send the | 48 // Creates a new proxy for WebPlugin, using the given sender to send the |
44 // marshalled WebPlugin calls. | 49 // marshalled WebPlugin calls. |
45 WebPluginProxy(PluginChannel* channel, | 50 WebPluginProxy(PluginChannel* channel, |
46 int route_id, | 51 int route_id, |
47 const GURL& page_url, | 52 const GURL& page_url, |
48 int host_render_view_routing_id); | 53 int host_render_view_routing_id); |
49 virtual ~WebPluginProxy(); | 54 virtual ~WebPluginProxy(); |
50 | 55 |
51 void set_delegate(WebPluginDelegateImpl* d) { delegate_ = d; } | 56 void set_delegate(WebPluginDelegateImpl* d) { delegate_ = d; } |
52 | 57 |
53 // WebPlugin overrides | 58 // WebPlugin overrides |
54 virtual void SetWindow(gfx::PluginWindowHandle window) OVERRIDE; | 59 virtual void SetWindow(gfx::PluginWindowHandle window) OVERRIDE; |
55 virtual void SetAcceptsInputEvents(bool accepts) OVERRIDE; | 60 virtual void SetAcceptsInputEvents(bool accepts) OVERRIDE; |
56 virtual void WillDestroyWindow(gfx::PluginWindowHandle window) OVERRIDE; | 61 virtual void WillDestroyWindow(gfx::PluginWindowHandle window) OVERRIDE; |
57 #if defined(OS_WIN) | |
58 void SetWindowlessData(HANDLE pump_messages_event, | |
59 gfx::NativeViewId dummy_activation_window); | |
60 #endif | |
61 virtual void CancelResource(unsigned long id) OVERRIDE; | 62 virtual void CancelResource(unsigned long id) OVERRIDE; |
62 virtual void Invalidate() OVERRIDE; | 63 virtual void Invalidate() OVERRIDE; |
63 virtual void InvalidateRect(const gfx::Rect& rect) OVERRIDE; | 64 virtual void InvalidateRect(const gfx::Rect& rect) OVERRIDE; |
64 virtual NPObject* GetWindowScriptNPObject() OVERRIDE; | 65 virtual NPObject* GetWindowScriptNPObject() OVERRIDE; |
65 virtual NPObject* GetPluginElement() OVERRIDE; | 66 virtual NPObject* GetPluginElement() OVERRIDE; |
66 virtual bool FindProxyForUrl(const GURL& url, | 67 virtual bool FindProxyForUrl(const GURL& url, |
67 std::string* proxy_list) OVERRIDE; | 68 std::string* proxy_list) OVERRIDE; |
68 virtual void SetCookie(const GURL& url, | 69 virtual void SetCookie(const GURL& url, |
69 const GURL& first_party_for_cookies, | 70 const GURL& first_party_for_cookies, |
70 const std::string& cookie) OVERRIDE; | 71 const std::string& cookie) OVERRIDE; |
(...skipping 13 matching lines...) Expand all Loading... |
84 const TransportDIB::Handle& windowless_buffer1, | 85 const TransportDIB::Handle& windowless_buffer1, |
85 int windowless_buffer_index); | 86 int windowless_buffer_index); |
86 virtual void CancelDocumentLoad() OVERRIDE; | 87 virtual void CancelDocumentLoad() OVERRIDE; |
87 virtual void InitiateHTTPRangeRequest( | 88 virtual void InitiateHTTPRangeRequest( |
88 const char* url, const char* range_info, int range_request_id) OVERRIDE; | 89 const char* url, const char* range_info, int range_request_id) OVERRIDE; |
89 virtual void SetDeferResourceLoading(unsigned long resource_id, | 90 virtual void SetDeferResourceLoading(unsigned long resource_id, |
90 bool defer) OVERRIDE; | 91 bool defer) OVERRIDE; |
91 virtual bool IsOffTheRecord() OVERRIDE; | 92 virtual bool IsOffTheRecord() OVERRIDE; |
92 virtual void ResourceClientDeleted( | 93 virtual void ResourceClientDeleted( |
93 WebPluginResourceClient* resource_client) OVERRIDE; | 94 WebPluginResourceClient* resource_client) OVERRIDE; |
94 | 95 virtual void URLRedirectResponse(bool allow, int resource_id) OVERRIDE; |
| 96 #if defined(OS_WIN) |
| 97 void SetWindowlessData(HANDLE pump_messages_event, |
| 98 gfx::NativeViewId dummy_activation_window); |
| 99 #endif |
95 #if defined(OS_MACOSX) | 100 #if defined(OS_MACOSX) |
96 virtual void FocusChanged(bool focused) OVERRIDE; | 101 virtual void FocusChanged(bool focused) OVERRIDE; |
97 virtual void StartIme() OVERRIDE; | 102 virtual void StartIme() OVERRIDE; |
98 virtual WebPluginAcceleratedSurface* | 103 virtual WebPluginAcceleratedSurface* |
99 GetAcceleratedSurface(gfx::GpuPreference gpu_preference) OVERRIDE; | 104 GetAcceleratedSurface(gfx::GpuPreference gpu_preference) OVERRIDE; |
100 virtual void AcceleratedPluginEnabledRendering() OVERRIDE; | 105 virtual void AcceleratedPluginEnabledRendering() OVERRIDE; |
101 virtual void AcceleratedPluginAllocatedIOSurface(int32 width, | 106 virtual void AcceleratedPluginAllocatedIOSurface(int32 width, |
102 int32 height, | 107 int32 height, |
103 uint32 surface_id) OVERRIDE; | 108 uint32 surface_id) OVERRIDE; |
104 virtual void AcceleratedPluginSwappedIOSurface() OVERRIDE; | 109 virtual void AcceleratedPluginSwappedIOSurface() OVERRIDE; |
105 #endif | 110 #endif |
106 virtual void URLRedirectResponse(bool allow, int resource_id) OVERRIDE; | 111 |
| 112 // IPC::Sender implementation. |
| 113 virtual bool Send(IPC::Message* msg) OVERRIDE; |
107 | 114 |
108 // class-specific methods | 115 // class-specific methods |
109 | 116 |
110 // Returns a WebPluginResourceClient object given its id, or NULL if no | 117 // Returns a WebPluginResourceClient object given its id, or NULL if no |
111 // object with that id exists. | 118 // object with that id exists. |
112 WebPluginResourceClient* GetResourceClient(int id); | 119 WebPluginResourceClient* GetResourceClient(int id); |
113 | 120 |
114 // Returns the id of the renderer that contains this plugin. | 121 // Returns the id of the renderer that contains this plugin. |
115 int GetRendererId(); | 122 int GetRendererId(); |
116 | 123 |
117 // Returns the id of the associated render view. | 124 // Returns the id of the associated render view. |
118 int host_render_view_routing_id() const { | 125 int host_render_view_routing_id() const { |
119 return host_render_view_routing_id_; | 126 return host_render_view_routing_id_; |
120 } | 127 } |
121 | 128 |
122 // For windowless plugins, paints the given rectangle into the local buffer. | 129 // For windowless plugins, paints the given rectangle into the local buffer. |
123 void Paint(const gfx::Rect& rect); | 130 void Paint(const gfx::Rect& rect); |
124 | 131 |
125 // Callback from the renderer to let us know that a paint occurred. | 132 // Callback from the renderer to let us know that a paint occurred. |
126 void DidPaint(); | 133 void DidPaint(); |
127 | 134 |
128 // Notification received on a plugin issued resource request creation. | 135 // Notification received on a plugin issued resource request creation. |
129 void OnResourceCreated(int resource_id, WebPluginResourceClient* client); | 136 void OnResourceCreated(int resource_id, WebPluginResourceClient* client); |
130 | 137 |
| 138 // Starts fetching a URL through the browser process. |
| 139 void FetchURL(const PluginMsg_FetchURL_Params& params); |
| 140 |
131 #if defined(OS_WIN) && !defined(USE_AURA) | 141 #if defined(OS_WIN) && !defined(USE_AURA) |
132 // Retrieves the IME status from a windowless plug-in and sends it to a | 142 // Retrieves the IME status from a windowless plug-in and sends it to a |
133 // renderer process. A renderer process will convert the coordinates from | 143 // renderer process. A renderer process will convert the coordinates from |
134 // local to the window coordinates and send the converted coordinates to a | 144 // local to the window coordinates and send the converted coordinates to a |
135 // browser process. | 145 // browser process. |
136 void UpdateIMEStatus(); | 146 void UpdateIMEStatus(); |
137 #endif | 147 #endif |
138 | 148 |
139 private: | 149 private: |
140 class SharedTransportDIB : public base::RefCounted<SharedTransportDIB> { | 150 class SharedTransportDIB : public base::RefCounted<SharedTransportDIB> { |
141 public: | 151 public: |
142 explicit SharedTransportDIB(TransportDIB* dib); | 152 explicit SharedTransportDIB(TransportDIB* dib); |
143 TransportDIB* dib() { return dib_.get(); } | 153 TransportDIB* dib() { return dib_.get(); } |
144 private: | 154 private: |
145 friend class base::RefCounted<SharedTransportDIB>; | 155 friend class base::RefCounted<SharedTransportDIB>; |
146 ~SharedTransportDIB(); | 156 ~SharedTransportDIB(); |
147 | 157 |
148 scoped_ptr<TransportDIB> dib_; | 158 scoped_ptr<TransportDIB> dib_; |
149 }; | 159 }; |
150 | 160 |
151 bool Send(IPC::Message* msg); | |
152 | |
153 // Handler for sending over the paint event to the plugin. | 161 // Handler for sending over the paint event to the plugin. |
154 void OnPaint(const gfx::Rect& damaged_rect); | 162 void OnPaint(const gfx::Rect& damaged_rect); |
155 | 163 |
156 #if defined(OS_WIN) | 164 #if defined(OS_WIN) |
157 void CreateCanvasFromHandle(const TransportDIB::Handle& dib_handle, | 165 void CreateCanvasFromHandle(const TransportDIB::Handle& dib_handle, |
158 const gfx::Rect& window_rect, | 166 const gfx::Rect& window_rect, |
159 skia::RefPtr<SkCanvas>* canvas); | 167 skia::RefPtr<SkCanvas>* canvas); |
160 #elif defined(OS_MACOSX) | 168 #elif defined(OS_MACOSX) |
161 static void CreateDIBAndCGContextFromHandle( | 169 static void CreateDIBAndCGContextFromHandle( |
162 const TransportDIB::Handle& dib_handle, | 170 const TransportDIB::Handle& dib_handle, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 XID windowless_shm_pixmap() const { | 202 XID windowless_shm_pixmap() const { |
195 return windowless_shm_pixmaps_[windowless_buffer_index_]; | 203 return windowless_shm_pixmaps_[windowless_buffer_index_]; |
196 } | 204 } |
197 #endif | 205 #endif |
198 | 206 |
199 #endif | 207 #endif |
200 | 208 |
201 typedef base::hash_map<int, WebPluginResourceClient*> ResourceClientMap; | 209 typedef base::hash_map<int, WebPluginResourceClient*> ResourceClientMap; |
202 ResourceClientMap resource_clients_; | 210 ResourceClientMap resource_clients_; |
203 | 211 |
| 212 typedef base::hash_map<int, PluginURLFetcher*> PluginURLFetcherMap; |
| 213 PluginURLFetcherMap plugin_url_fetchers_; |
| 214 |
204 scoped_refptr<PluginChannel> channel_; | 215 scoped_refptr<PluginChannel> channel_; |
205 int route_id_; | 216 int route_id_; |
206 NPObject* window_npobject_; | 217 NPObject* window_npobject_; |
207 NPObject* plugin_element_; | 218 NPObject* plugin_element_; |
208 WebPluginDelegateImpl* delegate_; | 219 WebPluginDelegateImpl* delegate_; |
209 gfx::Rect damaged_rect_; | 220 gfx::Rect damaged_rect_; |
210 bool waiting_for_paint_; | 221 bool waiting_for_paint_; |
211 // The url of the main frame hosting the plugin. | 222 // The url of the main frame hosting the plugin. |
212 GURL page_url_; | 223 GURL page_url_; |
213 | 224 |
(...skipping 22 matching lines...) Expand all Loading... |
236 | 247 |
237 // Contains the routing id of the host render view. | 248 // Contains the routing id of the host render view. |
238 int host_render_view_routing_id_; | 249 int host_render_view_routing_id_; |
239 | 250 |
240 base::WeakPtrFactory<WebPluginProxy> weak_factory_; | 251 base::WeakPtrFactory<WebPluginProxy> weak_factory_; |
241 }; | 252 }; |
242 | 253 |
243 } // namespace content | 254 } // namespace content |
244 | 255 |
245 #endif // CONTENT_PLUGIN_WEBPLUGIN_PROXY_H_ | 256 #endif // CONTENT_PLUGIN_WEBPLUGIN_PROXY_H_ |
OLD | NEW |