| 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/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/shared_memory.h" | 18 #include "base/shared_memory.h" |
| 19 #include "base/timer/timer.h" | 19 #include "base/timer/timer.h" |
| 20 #include "content/child/npapi/webplugin.h" |
| 20 #include "ipc/ipc_message.h" | 21 #include "ipc/ipc_message.h" |
| 21 #include "skia/ext/refptr.h" | 22 #include "skia/ext/refptr.h" |
| 22 #include "third_party/skia/include/core/SkCanvas.h" | 23 #include "third_party/skia/include/core/SkCanvas.h" |
| 23 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 24 #if defined(USE_X11) | 25 #if defined(USE_X11) |
| 25 #include "ui/base/x/x11_util.h" | 26 #include "ui/base/x/x11_util.h" |
| 26 #endif | 27 #endif |
| 27 #include "ui/gl/gpu_preference.h" | 28 #include "ui/gl/gpu_preference.h" |
| 28 #include "ui/surface/transport_dib.h" | 29 #include "ui/surface/transport_dib.h" |
| 29 #include "webkit/plugins/npapi/webplugin.h" | |
| 30 | |
| 31 namespace webkit { | |
| 32 namespace npapi { | |
| 33 class WebPluginDelegateImpl; | |
| 34 } | |
| 35 } | |
| 36 | 30 |
| 37 namespace content { | 31 namespace content { |
| 38 class PluginChannel; | 32 class PluginChannel; |
| 33 class WebPluginDelegateImpl; |
| 39 | 34 |
| 40 #if defined(OS_MACOSX) | 35 #if defined(OS_MACOSX) |
| 41 class WebPluginAcceleratedSurfaceProxy; | 36 class WebPluginAcceleratedSurfaceProxy; |
| 42 #endif | 37 #endif |
| 43 | 38 |
| 44 // This is an implementation of WebPlugin that proxies all calls to the | 39 // This is an implementation of WebPlugin that proxies all calls to the |
| 45 // renderer. | 40 // renderer. |
| 46 class WebPluginProxy : public webkit::npapi::WebPlugin { | 41 class WebPluginProxy : public WebPlugin { |
| 47 public: | 42 public: |
| 48 // Creates a new proxy for WebPlugin, using the given sender to send the | 43 // Creates a new proxy for WebPlugin, using the given sender to send the |
| 49 // marshalled WebPlugin calls. | 44 // marshalled WebPlugin calls. |
| 50 WebPluginProxy(PluginChannel* channel, | 45 WebPluginProxy(PluginChannel* channel, |
| 51 int route_id, | 46 int route_id, |
| 52 const GURL& page_url, | 47 const GURL& page_url, |
| 53 int host_render_view_routing_id); | 48 int host_render_view_routing_id); |
| 54 virtual ~WebPluginProxy(); | 49 virtual ~WebPluginProxy(); |
| 55 | 50 |
| 56 void set_delegate(webkit::npapi::WebPluginDelegateImpl* d) { delegate_ = d; } | 51 void set_delegate(WebPluginDelegateImpl* d) { delegate_ = d; } |
| 57 | 52 |
| 58 // WebPlugin overrides | 53 // WebPlugin overrides |
| 59 virtual void SetWindow(gfx::PluginWindowHandle window) OVERRIDE; | 54 virtual void SetWindow(gfx::PluginWindowHandle window) OVERRIDE; |
| 60 | 55 |
| 61 // Whether input events should be sent to the delegate. | 56 // Whether input events should be sent to the delegate. |
| 62 virtual void SetAcceptsInputEvents(bool accepts) OVERRIDE; | 57 virtual void SetAcceptsInputEvents(bool accepts) OVERRIDE; |
| 63 | 58 |
| 64 virtual void WillDestroyWindow(gfx::PluginWindowHandle window) OVERRIDE; | 59 virtual void WillDestroyWindow(gfx::PluginWindowHandle window) OVERRIDE; |
| 65 #if defined(OS_WIN) | 60 #if defined(OS_WIN) |
| 66 void SetWindowlessData(HANDLE pump_messages_event, | 61 void SetWindowlessData(HANDLE pump_messages_event, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 77 virtual void SetCookie(const GURL& url, | 72 virtual void SetCookie(const GURL& url, |
| 78 const GURL& first_party_for_cookies, | 73 const GURL& first_party_for_cookies, |
| 79 const std::string& cookie) OVERRIDE; | 74 const std::string& cookie) OVERRIDE; |
| 80 virtual std::string GetCookies(const GURL& url, | 75 virtual std::string GetCookies(const GURL& url, |
| 81 const GURL& first_party_for_cookies) OVERRIDE; | 76 const GURL& first_party_for_cookies) OVERRIDE; |
| 82 | 77 |
| 83 // class-specific methods | 78 // class-specific methods |
| 84 | 79 |
| 85 // Returns a WebPluginResourceClient object given its id, or NULL if no | 80 // Returns a WebPluginResourceClient object given its id, or NULL if no |
| 86 // object with that id exists. | 81 // object with that id exists. |
| 87 webkit::npapi::WebPluginResourceClient* GetResourceClient(int id); | 82 WebPluginResourceClient* GetResourceClient(int id); |
| 88 | 83 |
| 89 // Returns the id of the renderer that contains this plugin. | 84 // Returns the id of the renderer that contains this plugin. |
| 90 int GetRendererId(); | 85 int GetRendererId(); |
| 91 | 86 |
| 92 // Returns the id of the associated render view. | 87 // Returns the id of the associated render view. |
| 93 int host_render_view_routing_id() const { | 88 int host_render_view_routing_id() const { |
| 94 return host_render_view_routing_id_; | 89 return host_render_view_routing_id_; |
| 95 } | 90 } |
| 96 | 91 |
| 97 // For windowless plugins, paints the given rectangle into the local buffer. | 92 // For windowless plugins, paints the given rectangle into the local buffer. |
| 98 void Paint(const gfx::Rect& rect); | 93 void Paint(const gfx::Rect& rect); |
| 99 | 94 |
| 100 // Callback from the renderer to let us know that a paint occurred. | 95 // Callback from the renderer to let us know that a paint occurred. |
| 101 void DidPaint(); | 96 void DidPaint(); |
| 102 | 97 |
| 103 // Notification received on a plugin issued resource request creation. | 98 // Notification received on a plugin issued resource request creation. |
| 104 void OnResourceCreated(int resource_id, | 99 void OnResourceCreated(int resource_id, WebPluginResourceClient* client); |
| 105 webkit::npapi::WebPluginResourceClient* client); | |
| 106 | 100 |
| 107 virtual void HandleURLRequest(const char* url, | 101 virtual void HandleURLRequest(const char* url, |
| 108 const char* method, | 102 const char* method, |
| 109 const char* target, | 103 const char* target, |
| 110 const char* buf, | 104 const char* buf, |
| 111 unsigned int len, | 105 unsigned int len, |
| 112 int notify_id, | 106 int notify_id, |
| 113 bool popups_allowed, | 107 bool popups_allowed, |
| 114 bool notify_redirects) OVERRIDE; | 108 bool notify_redirects) OVERRIDE; |
| 115 void UpdateGeometry(const gfx::Rect& window_rect, | 109 void UpdateGeometry(const gfx::Rect& window_rect, |
| 116 const gfx::Rect& clip_rect, | 110 const gfx::Rect& clip_rect, |
| 117 const TransportDIB::Handle& windowless_buffer0, | 111 const TransportDIB::Handle& windowless_buffer0, |
| 118 const TransportDIB::Handle& windowless_buffer1, | 112 const TransportDIB::Handle& windowless_buffer1, |
| 119 int windowless_buffer_index); | 113 int windowless_buffer_index); |
| 120 virtual void CancelDocumentLoad() OVERRIDE; | 114 virtual void CancelDocumentLoad() OVERRIDE; |
| 121 virtual void InitiateHTTPRangeRequest( | 115 virtual void InitiateHTTPRangeRequest( |
| 122 const char* url, const char* range_info, int range_request_id) OVERRIDE; | 116 const char* url, const char* range_info, int range_request_id) OVERRIDE; |
| 123 virtual void SetDeferResourceLoading(unsigned long resource_id, | 117 virtual void SetDeferResourceLoading(unsigned long resource_id, |
| 124 bool defer) OVERRIDE; | 118 bool defer) OVERRIDE; |
| 125 virtual bool IsOffTheRecord() OVERRIDE; | 119 virtual bool IsOffTheRecord() OVERRIDE; |
| 126 virtual void ResourceClientDeleted( | 120 virtual void ResourceClientDeleted( |
| 127 webkit::npapi::WebPluginResourceClient* resource_client) OVERRIDE; | 121 WebPluginResourceClient* resource_client) OVERRIDE; |
| 128 | 122 |
| 129 #if defined(OS_MACOSX) | 123 #if defined(OS_MACOSX) |
| 130 virtual void FocusChanged(bool focused) OVERRIDE; | 124 virtual void FocusChanged(bool focused) OVERRIDE; |
| 131 | |
| 132 virtual void StartIme() OVERRIDE; | 125 virtual void StartIme() OVERRIDE; |
| 133 | 126 virtual WebPluginAcceleratedSurface* |
| 134 virtual webkit::npapi::WebPluginAcceleratedSurface* | |
| 135 GetAcceleratedSurface(gfx::GpuPreference gpu_preference) OVERRIDE; | 127 GetAcceleratedSurface(gfx::GpuPreference gpu_preference) OVERRIDE; |
| 136 | 128 |
| 137 //---------------------------------------------------------------------- | 129 //---------------------------------------------------------------------- |
| 138 // Accelerated plugin implementation which renders via the compositor. | 130 // Accelerated plugin implementation which renders via the compositor. |
| 139 | 131 |
| 140 // Tells the renderer, and from there the GPU process, that the plugin | 132 // Tells the renderer, and from there the GPU process, that the plugin |
| 141 // is using accelerated rather than software rendering. | 133 // is using accelerated rather than software rendering. |
| 142 virtual void AcceleratedPluginEnabledRendering() OVERRIDE; | 134 virtual void AcceleratedPluginEnabledRendering() OVERRIDE; |
| 143 | 135 |
| 144 // Tells the renderer, and from there the GPU process, that the plugin | 136 // Tells the renderer, and from there the GPU process, that the plugin |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 } | 206 } |
| 215 | 207 |
| 216 #if defined(USE_X11) | 208 #if defined(USE_X11) |
| 217 XID windowless_shm_pixmap() const { | 209 XID windowless_shm_pixmap() const { |
| 218 return windowless_shm_pixmaps_[windowless_buffer_index_]; | 210 return windowless_shm_pixmaps_[windowless_buffer_index_]; |
| 219 } | 211 } |
| 220 #endif | 212 #endif |
| 221 | 213 |
| 222 #endif | 214 #endif |
| 223 | 215 |
| 224 typedef base::hash_map<int, webkit::npapi::WebPluginResourceClient*> | 216 typedef base::hash_map<int, WebPluginResourceClient*> ResourceClientMap; |
| 225 ResourceClientMap; | |
| 226 ResourceClientMap resource_clients_; | 217 ResourceClientMap resource_clients_; |
| 227 | 218 |
| 228 scoped_refptr<PluginChannel> channel_; | 219 scoped_refptr<PluginChannel> channel_; |
| 229 int route_id_; | 220 int route_id_; |
| 230 NPObject* window_npobject_; | 221 NPObject* window_npobject_; |
| 231 NPObject* plugin_element_; | 222 NPObject* plugin_element_; |
| 232 webkit::npapi::WebPluginDelegateImpl* delegate_; | 223 WebPluginDelegateImpl* delegate_; |
| 233 gfx::Rect damaged_rect_; | 224 gfx::Rect damaged_rect_; |
| 234 bool waiting_for_paint_; | 225 bool waiting_for_paint_; |
| 235 // The url of the main frame hosting the plugin. | 226 // The url of the main frame hosting the plugin. |
| 236 GURL page_url_; | 227 GURL page_url_; |
| 237 | 228 |
| 238 // Variables used for desynchronized windowless plugin painting. See note in | 229 // Variables used for desynchronized windowless plugin painting. See note in |
| 239 // webplugin_delegate_proxy.h for how this works. The two sets of windowless_* | 230 // webplugin_delegate_proxy.h for how this works. The two sets of windowless_* |
| 240 // fields are for the front-buffer and back-buffer of a buffer flipping system | 231 // fields are for the front-buffer and back-buffer of a buffer flipping system |
| 241 // and windowless_buffer_index_ identifies which set we are using as the | 232 // and windowless_buffer_index_ identifies which set we are using as the |
| 242 // back-buffer at any given time. | 233 // back-buffer at any given time. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 260 | 251 |
| 261 // Contains the routing id of the host render view. | 252 // Contains the routing id of the host render view. |
| 262 int host_render_view_routing_id_; | 253 int host_render_view_routing_id_; |
| 263 | 254 |
| 264 base::WeakPtrFactory<WebPluginProxy> weak_factory_; | 255 base::WeakPtrFactory<WebPluginProxy> weak_factory_; |
| 265 }; | 256 }; |
| 266 | 257 |
| 267 } // namespace content | 258 } // namespace content |
| 268 | 259 |
| 269 #endif // CONTENT_PLUGIN_WEBPLUGIN_PROXY_H_ | 260 #endif // CONTENT_PLUGIN_WEBPLUGIN_PROXY_H_ |
| OLD | NEW |