| 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_RENDERER_NPAPI_WEBPLUGIN_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_NPAPI_WEBPLUGIN_IMPL_H_ |
| 6 #define CONTENT_RENDERER_NPAPI_WEBPLUGIN_IMPL_H_ | 6 #define CONTENT_RENDERER_NPAPI_WEBPLUGIN_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 22 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 23 #include "third_party/WebKit/public/platform/WebVector.h" | 23 #include "third_party/WebKit/public/platform/WebVector.h" |
| 24 #include "third_party/WebKit/public/web/WebPlugin.h" | 24 #include "third_party/WebKit/public/web/WebPlugin.h" |
| 25 #include "ui/gfx/native_widget_types.h" | 25 #include "ui/gfx/native_widget_types.h" |
| 26 #include "url/gurl.h" | 26 #include "url/gurl.h" |
| 27 | 27 |
| 28 namespace cc { | 28 namespace cc { |
| 29 class IOSurfaceLayer; | 29 class IOSurfaceLayer; |
| 30 } | 30 } |
| 31 | 31 |
| 32 namespace WebKit { | 32 namespace blink { |
| 33 class WebFrame; | 33 class WebFrame; |
| 34 class WebLayer; | 34 class WebLayer; |
| 35 class WebPluginContainer; | 35 class WebPluginContainer; |
| 36 class WebURLResponse; | 36 class WebURLResponse; |
| 37 class WebURLLoader; | 37 class WebURLLoader; |
| 38 class WebURLRequest; | 38 class WebURLRequest; |
| 39 } | 39 } |
| 40 | 40 |
| 41 namespace webkit_glue { | 41 namespace webkit_glue { |
| 42 class MultipartResponseDelegate; | 42 class MultipartResponseDelegate; |
| 43 } // namespace webkit_glue | 43 } // namespace webkit_glue |
| 44 | 44 |
| 45 namespace content { | 45 namespace content { |
| 46 | 46 |
| 47 class RenderViewImpl; | 47 class RenderViewImpl; |
| 48 class WebPluginDelegate; | 48 class WebPluginDelegate; |
| 49 | 49 |
| 50 // This is the WebKit side of the plugin implementation that forwards calls, | 50 // This is the WebKit side of the plugin implementation that forwards calls, |
| 51 // after changing out of WebCore types, to a delegate. The delegate may | 51 // after changing out of WebCore types, to a delegate. The delegate may |
| 52 // be in a different process. | 52 // be in a different process. |
| 53 class WebPluginImpl : public WebPlugin, | 53 class WebPluginImpl : public WebPlugin, |
| 54 public WebKit::WebPlugin, | 54 public blink::WebPlugin, |
| 55 public WebKit::WebURLLoaderClient { | 55 public blink::WebURLLoaderClient { |
| 56 public: | 56 public: |
| 57 WebPluginImpl( | 57 WebPluginImpl( |
| 58 WebKit::WebFrame* frame, | 58 blink::WebFrame* frame, |
| 59 const WebKit::WebPluginParams& params, | 59 const blink::WebPluginParams& params, |
| 60 const base::FilePath& file_path, | 60 const base::FilePath& file_path, |
| 61 const base::WeakPtr<RenderViewImpl>& render_view); | 61 const base::WeakPtr<RenderViewImpl>& render_view); |
| 62 virtual ~WebPluginImpl(); | 62 virtual ~WebPluginImpl(); |
| 63 | 63 |
| 64 // Helper function for sorting post data. | 64 // Helper function for sorting post data. |
| 65 CONTENT_EXPORT static bool SetPostData(WebKit::WebURLRequest* request, | 65 CONTENT_EXPORT static bool SetPostData(blink::WebURLRequest* request, |
| 66 const char* buf, | 66 const char* buf, |
| 67 uint32 length); | 67 uint32 length); |
| 68 | 68 |
| 69 WebKit::WebFrame* webframe() { return webframe_; } | 69 blink::WebFrame* webframe() { return webframe_; } |
| 70 WebPluginDelegate* delegate() { return delegate_; } | 70 WebPluginDelegate* delegate() { return delegate_; } |
| 71 | 71 |
| 72 // WebKit::WebPlugin methods: | 72 // blink::WebPlugin methods: |
| 73 virtual bool initialize( | 73 virtual bool initialize( |
| 74 WebKit::WebPluginContainer* container); | 74 blink::WebPluginContainer* container); |
| 75 virtual void destroy(); | 75 virtual void destroy(); |
| 76 virtual NPObject* scriptableObject(); | 76 virtual NPObject* scriptableObject(); |
| 77 virtual struct _NPP* pluginNPP(); | 77 virtual struct _NPP* pluginNPP(); |
| 78 virtual bool getFormValue(WebKit::WebString& value); | 78 virtual bool getFormValue(blink::WebString& value); |
| 79 virtual void paint( | 79 virtual void paint( |
| 80 WebKit::WebCanvas* canvas, const WebKit::WebRect& paint_rect); | 80 blink::WebCanvas* canvas, const blink::WebRect& paint_rect); |
| 81 virtual void updateGeometry( | 81 virtual void updateGeometry( |
| 82 const WebKit::WebRect& frame_rect, const WebKit::WebRect& clip_rect, | 82 const blink::WebRect& frame_rect, const blink::WebRect& clip_rect, |
| 83 const WebKit::WebVector<WebKit::WebRect>& cut_outs, bool is_visible); | 83 const blink::WebVector<blink::WebRect>& cut_outs, bool is_visible); |
| 84 virtual void updateFocus(bool focused); | 84 virtual void updateFocus(bool focused); |
| 85 virtual void updateVisibility(bool visible); | 85 virtual void updateVisibility(bool visible); |
| 86 virtual bool acceptsInputEvents(); | 86 virtual bool acceptsInputEvents(); |
| 87 virtual bool handleInputEvent( | 87 virtual bool handleInputEvent( |
| 88 const WebKit::WebInputEvent& event, WebKit::WebCursorInfo& cursor_info); | 88 const blink::WebInputEvent& event, blink::WebCursorInfo& cursor_info); |
| 89 virtual void didReceiveResponse(const WebKit::WebURLResponse& response); | 89 virtual void didReceiveResponse(const blink::WebURLResponse& response); |
| 90 virtual void didReceiveData(const char* data, int data_length); | 90 virtual void didReceiveData(const char* data, int data_length); |
| 91 virtual void didFinishLoading(); | 91 virtual void didFinishLoading(); |
| 92 virtual void didFailLoading(const WebKit::WebURLError& error); | 92 virtual void didFailLoading(const blink::WebURLError& error); |
| 93 virtual void didFinishLoadingFrameRequest( | 93 virtual void didFinishLoadingFrameRequest( |
| 94 const WebKit::WebURL& url, void* notify_data); | 94 const blink::WebURL& url, void* notify_data); |
| 95 virtual void didFailLoadingFrameRequest( | 95 virtual void didFailLoadingFrameRequest( |
| 96 const WebKit::WebURL& url, void* notify_data, | 96 const blink::WebURL& url, void* notify_data, |
| 97 const WebKit::WebURLError& error); | 97 const blink::WebURLError& error); |
| 98 virtual bool isPlaceholder() OVERRIDE; | 98 virtual bool isPlaceholder() OVERRIDE; |
| 99 | 99 |
| 100 // WebPlugin implementation: | 100 // WebPlugin implementation: |
| 101 virtual void SetWindow(gfx::PluginWindowHandle window) OVERRIDE; | 101 virtual void SetWindow(gfx::PluginWindowHandle window) OVERRIDE; |
| 102 virtual void SetAcceptsInputEvents(bool accepts) OVERRIDE; | 102 virtual void SetAcceptsInputEvents(bool accepts) OVERRIDE; |
| 103 virtual void WillDestroyWindow(gfx::PluginWindowHandle window) OVERRIDE; | 103 virtual void WillDestroyWindow(gfx::PluginWindowHandle window) OVERRIDE; |
| 104 virtual void CancelResource(unsigned long id) OVERRIDE; | 104 virtual void CancelResource(unsigned long id) OVERRIDE; |
| 105 virtual void Invalidate() OVERRIDE; | 105 virtual void Invalidate() OVERRIDE; |
| 106 virtual void InvalidateRect(const gfx::Rect& rect) OVERRIDE; | 106 virtual void InvalidateRect(const gfx::Rect& rect) OVERRIDE; |
| 107 virtual NPObject* GetWindowScriptNPObject() OVERRIDE; | 107 virtual NPObject* GetWindowScriptNPObject() OVERRIDE; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 const char* buf, | 193 const char* buf, |
| 194 int len, | 194 int len, |
| 195 const char* range_info, | 195 const char* range_info, |
| 196 Referrer referrer_flag, | 196 Referrer referrer_flag, |
| 197 bool notify_redirects, | 197 bool notify_redirects, |
| 198 bool check_mixed_scripting); | 198 bool check_mixed_scripting); |
| 199 | 199 |
| 200 gfx::Rect GetWindowClipRect(const gfx::Rect& rect); | 200 gfx::Rect GetWindowClipRect(const gfx::Rect& rect); |
| 201 | 201 |
| 202 // Sets the actual Widget for the plugin. | 202 // Sets the actual Widget for the plugin. |
| 203 void SetContainer(WebKit::WebPluginContainer* container); | 203 void SetContainer(blink::WebPluginContainer* container); |
| 204 | 204 |
| 205 // Destroys the plugin instance. | 205 // Destroys the plugin instance. |
| 206 // The response_handle_to_ignore parameter if not NULL indicates the | 206 // The response_handle_to_ignore parameter if not NULL indicates the |
| 207 // resource handle to be left valid during plugin shutdown. | 207 // resource handle to be left valid during plugin shutdown. |
| 208 void TearDownPluginInstance(WebKit::WebURLLoader* loader_to_ignore); | 208 void TearDownPluginInstance(blink::WebURLLoader* loader_to_ignore); |
| 209 | 209 |
| 210 // WebURLLoaderClient implementation. We implement this interface in the | 210 // WebURLLoaderClient implementation. We implement this interface in the |
| 211 // renderer process, and then use the simple WebPluginResourceClient interface | 211 // renderer process, and then use the simple WebPluginResourceClient interface |
| 212 // to relay the callbacks to the plugin. | 212 // to relay the callbacks to the plugin. |
| 213 virtual void willSendRequest(WebKit::WebURLLoader* loader, | 213 virtual void willSendRequest(blink::WebURLLoader* loader, |
| 214 WebKit::WebURLRequest& request, | 214 blink::WebURLRequest& request, |
| 215 const WebKit::WebURLResponse& response); | 215 const blink::WebURLResponse& response); |
| 216 virtual void didSendData(WebKit::WebURLLoader* loader, | 216 virtual void didSendData(blink::WebURLLoader* loader, |
| 217 unsigned long long bytes_sent, | 217 unsigned long long bytes_sent, |
| 218 unsigned long long total_bytes_to_be_sent); | 218 unsigned long long total_bytes_to_be_sent); |
| 219 virtual void didReceiveResponse(WebKit::WebURLLoader* loader, | 219 virtual void didReceiveResponse(blink::WebURLLoader* loader, |
| 220 const WebKit::WebURLResponse& response); | 220 const blink::WebURLResponse& response); |
| 221 | 221 |
| 222 virtual void didReceiveData(WebKit::WebURLLoader* loader, const char *buffer, | 222 virtual void didReceiveData(blink::WebURLLoader* loader, const char *buffer, |
| 223 int data_length, int encoded_data_length); | 223 int data_length, int encoded_data_length); |
| 224 virtual void didFinishLoading(WebKit::WebURLLoader* loader, | 224 virtual void didFinishLoading(blink::WebURLLoader* loader, |
| 225 double finishTime); | 225 double finishTime); |
| 226 virtual void didFail(WebKit::WebURLLoader* loader, | 226 virtual void didFail(blink::WebURLLoader* loader, |
| 227 const WebKit::WebURLError& error); | 227 const blink::WebURLError& error); |
| 228 | 228 |
| 229 // Helper function to remove the stored information about a resource | 229 // Helper function to remove the stored information about a resource |
| 230 // request given its index in m_clients. | 230 // request given its index in m_clients. |
| 231 void RemoveClient(size_t i); | 231 void RemoveClient(size_t i); |
| 232 | 232 |
| 233 // Helper function to remove the stored information about a resource | 233 // Helper function to remove the stored information about a resource |
| 234 // request given a handle. | 234 // request given a handle. |
| 235 void RemoveClient(WebKit::WebURLLoader* loader); | 235 void RemoveClient(blink::WebURLLoader* loader); |
| 236 | 236 |
| 237 // Handles HTTP multipart responses, i.e. responses received with a HTTP | 237 // Handles HTTP multipart responses, i.e. responses received with a HTTP |
| 238 // status code of 206. | 238 // status code of 206. |
| 239 // Returns false if response is not multipart (may be if we requested | 239 // Returns false if response is not multipart (may be if we requested |
| 240 // single range). | 240 // single range). |
| 241 bool HandleHttpMultipartResponse(const WebKit::WebURLResponse& response, | 241 bool HandleHttpMultipartResponse(const blink::WebURLResponse& response, |
| 242 WebPluginResourceClient* client); | 242 WebPluginResourceClient* client); |
| 243 | 243 |
| 244 void HandleURLRequestInternal(const char* url, | 244 void HandleURLRequestInternal(const char* url, |
| 245 const char* method, | 245 const char* method, |
| 246 const char* target, | 246 const char* target, |
| 247 const char* buf, | 247 const char* buf, |
| 248 unsigned int len, | 248 unsigned int len, |
| 249 int notify_id, | 249 int notify_id, |
| 250 bool popups_allowed, | 250 bool popups_allowed, |
| 251 Referrer referrer_flag, | 251 Referrer referrer_flag, |
| 252 bool notify_redirects, | 252 bool notify_redirects, |
| 253 bool check_mixed_scripting); | 253 bool check_mixed_scripting); |
| 254 | 254 |
| 255 // Tears down the existing plugin instance and creates a new plugin instance | 255 // Tears down the existing plugin instance and creates a new plugin instance |
| 256 // to handle the response identified by the loader parameter. | 256 // to handle the response identified by the loader parameter. |
| 257 bool ReinitializePluginForResponse(WebKit::WebURLLoader* loader); | 257 bool ReinitializePluginForResponse(blink::WebURLLoader* loader); |
| 258 | 258 |
| 259 // Delayed task for downloading the plugin source URL. | 259 // Delayed task for downloading the plugin source URL. |
| 260 void OnDownloadPluginSrcUrl(); | 260 void OnDownloadPluginSrcUrl(); |
| 261 | 261 |
| 262 struct ClientInfo; | 262 struct ClientInfo; |
| 263 | 263 |
| 264 // Helper functions | 264 // Helper functions |
| 265 WebPluginResourceClient* GetClientFromLoader(WebKit::WebURLLoader* loader); | 265 WebPluginResourceClient* GetClientFromLoader(blink::WebURLLoader* loader); |
| 266 ClientInfo* GetClientInfoFromLoader(WebKit::WebURLLoader* loader); | 266 ClientInfo* GetClientInfoFromLoader(blink::WebURLLoader* loader); |
| 267 | 267 |
| 268 // Helper function to set the referrer on the request passed in. | 268 // Helper function to set the referrer on the request passed in. |
| 269 void SetReferrer(WebKit::WebURLRequest* request, Referrer referrer_flag); | 269 void SetReferrer(blink::WebURLRequest* request, Referrer referrer_flag); |
| 270 | 270 |
| 271 // Check for invalid chars like @, ;, \ before the first / (in path). | 271 // Check for invalid chars like @, ;, \ before the first / (in path). |
| 272 bool IsValidUrl(const GURL& url, Referrer referrer_flag); | 272 bool IsValidUrl(const GURL& url, Referrer referrer_flag); |
| 273 | 273 |
| 274 WebPluginDelegate* CreatePluginDelegate(); | 274 WebPluginDelegate* CreatePluginDelegate(); |
| 275 | 275 |
| 276 std::vector<ClientInfo> clients_; | 276 std::vector<ClientInfo> clients_; |
| 277 | 277 |
| 278 bool windowless_; | 278 bool windowless_; |
| 279 gfx::PluginWindowHandle window_; | 279 gfx::PluginWindowHandle window_; |
| 280 #if defined(OS_MACOSX) | 280 #if defined(OS_MACOSX) |
| 281 bool next_io_surface_allocated_; | 281 bool next_io_surface_allocated_; |
| 282 int32 next_io_surface_width_; | 282 int32 next_io_surface_width_; |
| 283 int32 next_io_surface_height_; | 283 int32 next_io_surface_height_; |
| 284 uint32 next_io_surface_id_; | 284 uint32 next_io_surface_id_; |
| 285 scoped_refptr<cc::IOSurfaceLayer> io_surface_layer_; | 285 scoped_refptr<cc::IOSurfaceLayer> io_surface_layer_; |
| 286 scoped_ptr<WebKit::WebLayer> web_layer_; | 286 scoped_ptr<blink::WebLayer> web_layer_; |
| 287 #endif | 287 #endif |
| 288 bool accepts_input_events_; | 288 bool accepts_input_events_; |
| 289 base::WeakPtr<RenderViewImpl> render_view_; | 289 base::WeakPtr<RenderViewImpl> render_view_; |
| 290 WebKit::WebFrame* webframe_; | 290 blink::WebFrame* webframe_; |
| 291 | 291 |
| 292 WebPluginDelegate* delegate_; | 292 WebPluginDelegate* delegate_; |
| 293 | 293 |
| 294 // This is just a weak reference. | 294 // This is just a weak reference. |
| 295 WebKit::WebPluginContainer* container_; | 295 blink::WebPluginContainer* container_; |
| 296 | 296 |
| 297 // Unique identifier for this plugin, used to track script objects. | 297 // Unique identifier for this plugin, used to track script objects. |
| 298 struct _NPP* npp_; | 298 struct _NPP* npp_; |
| 299 | 299 |
| 300 typedef std::map<WebPluginResourceClient*, | 300 typedef std::map<WebPluginResourceClient*, |
| 301 webkit_glue::MultipartResponseDelegate*> | 301 webkit_glue::MultipartResponseDelegate*> |
| 302 MultiPartResponseHandlerMap; | 302 MultiPartResponseHandlerMap; |
| 303 // Tracks HTTP multipart response handlers instantiated for | 303 // Tracks HTTP multipart response handlers instantiated for |
| 304 // a WebPluginResourceClient instance. | 304 // a WebPluginResourceClient instance. |
| 305 MultiPartResponseHandlerMap multi_part_response_map_; | 305 MultiPartResponseHandlerMap multi_part_response_map_; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 331 std::vector<std::string> arg_values_; | 331 std::vector<std::string> arg_values_; |
| 332 | 332 |
| 333 base::WeakPtrFactory<WebPluginImpl> weak_factory_; | 333 base::WeakPtrFactory<WebPluginImpl> weak_factory_; |
| 334 | 334 |
| 335 DISALLOW_COPY_AND_ASSIGN(WebPluginImpl); | 335 DISALLOW_COPY_AND_ASSIGN(WebPluginImpl); |
| 336 }; | 336 }; |
| 337 | 337 |
| 338 } // namespace content | 338 } // namespace content |
| 339 | 339 |
| 340 #endif // CONTENT_RENDERER_NPAPI_WEBPLUGIN_IMPL_H_ | 340 #endif // CONTENT_RENDERER_NPAPI_WEBPLUGIN_IMPL_H_ |
| OLD | NEW |