| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 WEBKIT_GLUE_PLUGINS_WEBPLUGIN_DELEGATE_IMPL_H_ | 5 #ifndef WEBKIT_PLUGINS_NPAPI_WEBPLUGIN_DELEGATE_IMPL_H_ |
| 6 #define WEBKIT_GLUE_PLUGINS_WEBPLUGIN_DELEGATE_IMPL_H_ | 6 #define WEBKIT_PLUGINS_NPAPI_WEBPLUGIN_DELEGATE_IMPL_H_ |
| 7 | |
| 8 #include "build/build_config.h" | |
| 9 | 7 |
| 10 #include <string> | 8 #include <string> |
| 11 #include <list> | 9 #include <list> |
| 12 | 10 |
| 13 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
| 14 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 15 #include "base/task.h" | 13 #include "base/task.h" |
| 16 #include "base/time.h" | 14 #include "base/time.h" |
| 17 #include "base/timer.h" | 15 #include "base/timer.h" |
| 16 #include "build/build_config.h" |
| 18 #include "gfx/native_widget_types.h" | 17 #include "gfx/native_widget_types.h" |
| 19 #include "gfx/rect.h" | 18 #include "gfx/rect.h" |
| 20 #include "third_party/npapi/bindings/npapi.h" | 19 #include "third_party/npapi/bindings/npapi.h" |
| 21 #include "webkit/glue/plugins/webplugin_delegate.h" | 20 #include "webkit/plugins/npapi/webplugin_delegate.h" |
| 22 #include "webkit/glue/webcursor.h" | 21 #include "webkit/glue/webcursor.h" |
| 23 | 22 |
| 24 #if defined(USE_X11) | 23 #if defined(USE_X11) |
| 25 #include "app/x11_util.h" | 24 #include "app/x11_util.h" |
| 26 | 25 |
| 27 typedef struct _GdkDrawable GdkPixmap; | 26 typedef struct _GdkDrawable GdkPixmap; |
| 28 #endif | 27 #endif |
| 29 | 28 |
| 30 class FilePath; | 29 class FilePath; |
| 31 | 30 |
| 32 namespace NPAPI { | |
| 33 class PluginInstance; | |
| 34 } | |
| 35 | |
| 36 namespace WebKit { | 31 namespace WebKit { |
| 37 class WebMouseEvent; | 32 class WebMouseEvent; |
| 38 } | 33 } |
| 39 | 34 |
| 40 #if defined(OS_MACOSX) | 35 #if defined(OS_MACOSX) |
| 41 class ExternalDragTracker; | 36 class ExternalDragTracker; |
| 42 #ifndef NP_NO_QUICKDRAW | 37 #ifndef NP_NO_QUICKDRAW |
| 43 class QuickDrawDrawingManager; | 38 class QuickDrawDrawingManager; |
| 44 #endif | 39 #endif |
| 45 #ifdef __OBJC__ | 40 #ifdef __OBJC__ |
| 46 @class CALayer; | 41 @class CALayer; |
| 47 @class CARenderer; | 42 @class CARenderer; |
| 48 #else | 43 #else |
| 49 class CALayer; | 44 class CALayer; |
| 50 class CARenderer; | 45 class CARenderer; |
| 51 #endif | 46 #endif |
| 52 namespace webkit_glue { | 47 #endif |
| 48 |
| 49 namespace webkit { |
| 50 namespace npapi { |
| 51 |
| 52 class PluginInstance; |
| 53 |
| 54 #if defined(OS_MACOSX) |
| 53 class WebPluginAcceleratedSurface; | 55 class WebPluginAcceleratedSurface; |
| 54 } | |
| 55 #endif | 56 #endif |
| 56 | 57 |
| 57 // An implementation of WebPluginDelegate that runs in the plugin process, | 58 // An implementation of WebPluginDelegate that runs in the plugin process, |
| 58 // proxied from the renderer by WebPluginDelegateProxy. | 59 // proxied from the renderer by WebPluginDelegateProxy. |
| 59 class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate { | 60 class WebPluginDelegateImpl : public WebPluginDelegate { |
| 60 public: | 61 public: |
| 61 enum PluginQuirks { | 62 enum PluginQuirks { |
| 62 PLUGIN_QUIRK_SETWINDOW_TWICE = 1, // Win32 | 63 PLUGIN_QUIRK_SETWINDOW_TWICE = 1, // Win32 |
| 63 PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE = 2, // Win32 | 64 PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE = 2, // Win32 |
| 64 PLUGIN_QUIRK_DONT_CALL_WND_PROC_RECURSIVELY = 4, // Win32 | 65 PLUGIN_QUIRK_DONT_CALL_WND_PROC_RECURSIVELY = 4, // Win32 |
| 65 PLUGIN_QUIRK_DONT_SET_NULL_WINDOW_HANDLE_ON_DESTROY = 8, // Win32 | 66 PLUGIN_QUIRK_DONT_SET_NULL_WINDOW_HANDLE_ON_DESTROY = 8, // Win32 |
| 66 PLUGIN_QUIRK_DONT_ALLOW_MULTIPLE_INSTANCES = 16, // Win32 | 67 PLUGIN_QUIRK_DONT_ALLOW_MULTIPLE_INSTANCES = 16, // Win32 |
| 67 PLUGIN_QUIRK_DIE_AFTER_UNLOAD = 32, // Win32 | 68 PLUGIN_QUIRK_DIE_AFTER_UNLOAD = 32, // Win32 |
| 68 PLUGIN_QUIRK_PATCH_SETCURSOR = 64, // Win32 | 69 PLUGIN_QUIRK_PATCH_SETCURSOR = 64, // Win32 |
| 69 PLUGIN_QUIRK_BLOCK_NONSTANDARD_GETURL_REQUESTS = 128, // Win32 | 70 PLUGIN_QUIRK_BLOCK_NONSTANDARD_GETURL_REQUESTS = 128, // Win32 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 87 std::wstring *plugin_name); | 88 std::wstring *plugin_name); |
| 88 | 89 |
| 89 // Returns true if the window handle passed in is that of the dummy | 90 // Returns true if the window handle passed in is that of the dummy |
| 90 // activation window for windowless plugins. | 91 // activation window for windowless plugins. |
| 91 static bool IsDummyActivationWindow(gfx::NativeWindow window); | 92 static bool IsDummyActivationWindow(gfx::NativeWindow window); |
| 92 | 93 |
| 93 // WebPluginDelegate implementation | 94 // WebPluginDelegate implementation |
| 94 virtual bool Initialize(const GURL& url, | 95 virtual bool Initialize(const GURL& url, |
| 95 const std::vector<std::string>& arg_names, | 96 const std::vector<std::string>& arg_names, |
| 96 const std::vector<std::string>& arg_values, | 97 const std::vector<std::string>& arg_values, |
| 97 webkit_glue::WebPlugin* plugin, | 98 WebPlugin* plugin, |
| 98 bool load_manually); | 99 bool load_manually); |
| 99 virtual void PluginDestroyed(); | 100 virtual void PluginDestroyed(); |
| 100 virtual void UpdateGeometry(const gfx::Rect& window_rect, | 101 virtual void UpdateGeometry(const gfx::Rect& window_rect, |
| 101 const gfx::Rect& clip_rect); | 102 const gfx::Rect& clip_rect); |
| 102 virtual void Paint(WebKit::WebCanvas* canvas, const gfx::Rect& rect); | 103 virtual void Paint(WebKit::WebCanvas* canvas, const gfx::Rect& rect); |
| 103 virtual void Print(gfx::NativeDrawingContext context); | 104 virtual void Print(gfx::NativeDrawingContext context); |
| 104 virtual void SetFocus(bool focused); | 105 virtual void SetFocus(bool focused); |
| 105 virtual bool HandleInputEvent(const WebKit::WebInputEvent& event, | 106 virtual bool HandleInputEvent(const WebKit::WebInputEvent& event, |
| 106 WebKit::WebCursorInfo* cursor_info); | 107 WebKit::WebCursorInfo* cursor_info); |
| 107 virtual NPObject* GetPluginScriptableObject(); | 108 virtual NPObject* GetPluginScriptableObject(); |
| 108 virtual void DidFinishLoadWithReason( | 109 virtual void DidFinishLoadWithReason( |
| 109 const GURL& url, NPReason reason, int notify_id); | 110 const GURL& url, NPReason reason, int notify_id); |
| 110 virtual int GetProcessId(); | 111 virtual int GetProcessId(); |
| 111 virtual void SendJavaScriptStream(const GURL& url, | 112 virtual void SendJavaScriptStream(const GURL& url, |
| 112 const std::string& result, | 113 const std::string& result, |
| 113 bool success, | 114 bool success, |
| 114 int notify_id); | 115 int notify_id); |
| 115 virtual void DidReceiveManualResponse(const GURL& url, | 116 virtual void DidReceiveManualResponse(const GURL& url, |
| 116 const std::string& mime_type, | 117 const std::string& mime_type, |
| 117 const std::string& headers, | 118 const std::string& headers, |
| 118 uint32 expected_length, | 119 uint32 expected_length, |
| 119 uint32 last_modified); | 120 uint32 last_modified); |
| 120 virtual void DidReceiveManualData(const char* buffer, int length); | 121 virtual void DidReceiveManualData(const char* buffer, int length); |
| 121 virtual void DidFinishManualLoading(); | 122 virtual void DidFinishManualLoading(); |
| 122 virtual void DidManualLoadFail(); | 123 virtual void DidManualLoadFail(); |
| 123 virtual void InstallMissingPlugin(); | 124 virtual void InstallMissingPlugin(); |
| 124 virtual webkit_glue::WebPluginResourceClient* CreateResourceClient( | 125 virtual WebPluginResourceClient* CreateResourceClient( |
| 125 unsigned long resource_id, const GURL& url, int notify_id); | 126 unsigned long resource_id, const GURL& url, int notify_id); |
| 126 virtual webkit_glue::WebPluginResourceClient* CreateSeekableResourceClient( | 127 virtual WebPluginResourceClient* CreateSeekableResourceClient( |
| 127 unsigned long resource_id, int range_request_id); | 128 unsigned long resource_id, int range_request_id); |
| 128 // End of WebPluginDelegate implementation. | 129 // End of WebPluginDelegate implementation. |
| 129 | 130 |
| 130 bool IsWindowless() const { return windowless_ ; } | 131 bool IsWindowless() const { return windowless_ ; } |
| 131 gfx::Rect GetRect() const { return window_rect_; } | 132 gfx::Rect GetRect() const { return window_rect_; } |
| 132 gfx::Rect GetClipRect() const { return clip_rect_; } | 133 gfx::Rect GetClipRect() const { return clip_rect_; } |
| 133 | 134 |
| 134 // Returns the path for the library implementing this plugin. | 135 // Returns the path for the library implementing this plugin. |
| 135 FilePath GetPluginPath(); | 136 FilePath GetPluginPath(); |
| 136 | 137 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 #endif | 188 #endif |
| 188 | 189 |
| 189 #if defined(USE_X11) | 190 #if defined(USE_X11) |
| 190 void SetWindowlessShmPixmap(XID shm_pixmap) { | 191 void SetWindowlessShmPixmap(XID shm_pixmap) { |
| 191 windowless_shm_pixmap_ = shm_pixmap; | 192 windowless_shm_pixmap_ = shm_pixmap; |
| 192 } | 193 } |
| 193 #endif | 194 #endif |
| 194 | 195 |
| 195 private: | 196 private: |
| 196 friend class DeleteTask<WebPluginDelegateImpl>; | 197 friend class DeleteTask<WebPluginDelegateImpl>; |
| 197 friend class webkit_glue::WebPluginDelegate; | 198 friend class WebPluginDelegate; |
| 198 | 199 |
| 199 WebPluginDelegateImpl(gfx::PluginWindowHandle containing_view, | 200 WebPluginDelegateImpl(gfx::PluginWindowHandle containing_view, |
| 200 NPAPI::PluginInstance *instance); | 201 PluginInstance *instance); |
| 201 ~WebPluginDelegateImpl(); | 202 ~WebPluginDelegateImpl(); |
| 202 | 203 |
| 203 // Called by Initialize() for platform-specific initialization. | 204 // Called by Initialize() for platform-specific initialization. |
| 204 // If this returns false, the plugin shouldn't be started--see Initialize(). | 205 // If this returns false, the plugin shouldn't be started--see Initialize(). |
| 205 bool PlatformInitialize(); | 206 bool PlatformInitialize(); |
| 206 | 207 |
| 207 // Called by DestroyInstance(), used for platform-specific destruction. | 208 // Called by DestroyInstance(), used for platform-specific destruction. |
| 208 void PlatformDestroyInstance(); | 209 void PlatformDestroyInstance(); |
| 209 | 210 |
| 210 //-------------------------- | 211 //-------------------------- |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 bool PlatformSetPluginHasFocus(bool focused); | 267 bool PlatformSetPluginHasFocus(bool focused); |
| 267 | 268 |
| 268 //----------------------------------------- | 269 //----------------------------------------- |
| 269 // used for windowed and windowless plugins | 270 // used for windowed and windowless plugins |
| 270 | 271 |
| 271 // Does platform-specific event handling. Arguments and return are identical | 272 // Does platform-specific event handling. Arguments and return are identical |
| 272 // to HandleInputEvent. | 273 // to HandleInputEvent. |
| 273 bool PlatformHandleInputEvent(const WebKit::WebInputEvent& event, | 274 bool PlatformHandleInputEvent(const WebKit::WebInputEvent& event, |
| 274 WebKit::WebCursorInfo* cursor_info); | 275 WebKit::WebCursorInfo* cursor_info); |
| 275 | 276 |
| 276 NPAPI::PluginInstance* instance() { return instance_.get(); } | 277 PluginInstance* instance() { return instance_.get(); } |
| 277 | 278 |
| 278 // Closes down and destroys our plugin instance. | 279 // Closes down and destroys our plugin instance. |
| 279 void DestroyInstance(); | 280 void DestroyInstance(); |
| 280 | 281 |
| 281 | 282 |
| 282 // used for windowed plugins | 283 // used for windowed plugins |
| 283 // Note: on Mac OS X, the only time the windowed handle is non-zero | 284 // Note: on Mac OS X, the only time the windowed handle is non-zero |
| 284 // is the case of accelerated rendering, which uses a fake window handle to | 285 // is the case of accelerated rendering, which uses a fake window handle to |
| 285 // identify itself back to the browser. It still performs all of its | 286 // identify itself back to the browser. It still performs all of its |
| 286 // work offscreen. | 287 // work offscreen. |
| 287 gfx::PluginWindowHandle windowed_handle_; | 288 gfx::PluginWindowHandle windowed_handle_; |
| 288 gfx::Rect windowed_last_pos_; | 289 gfx::Rect windowed_last_pos_; |
| 289 | 290 |
| 290 bool windowed_did_set_window_; | 291 bool windowed_did_set_window_; |
| 291 | 292 |
| 292 // used by windowed and windowless plugins | 293 // used by windowed and windowless plugins |
| 293 bool windowless_; | 294 bool windowless_; |
| 294 | 295 |
| 295 webkit_glue::WebPlugin* plugin_; | 296 WebPlugin* plugin_; |
| 296 scoped_refptr<NPAPI::PluginInstance> instance_; | 297 scoped_refptr<PluginInstance> instance_; |
| 297 | 298 |
| 298 #if defined(OS_WIN) | 299 #if defined(OS_WIN) |
| 299 // Original wndproc before we subclassed. | 300 // Original wndproc before we subclassed. |
| 300 WNDPROC plugin_wnd_proc_; | 301 WNDPROC plugin_wnd_proc_; |
| 301 | 302 |
| 302 // Used to throttle WM_USER+1 messages in Flash. | 303 // Used to throttle WM_USER+1 messages in Flash. |
| 303 uint32 last_message_; | 304 uint32 last_message_; |
| 304 bool is_calling_wndproc; | 305 bool is_calling_wndproc; |
| 305 | 306 |
| 306 // The current keyboard layout of this process and the main thread ID of the | 307 // The current keyboard layout of this process and the main thread ID of the |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 #ifndef NP_NO_CARBON | 423 #ifndef NP_NO_CARBON |
| 423 NP_CGContext np_cg_context_; | 424 NP_CGContext np_cg_context_; |
| 424 #endif | 425 #endif |
| 425 #ifndef NP_NO_QUICKDRAW | 426 #ifndef NP_NO_QUICKDRAW |
| 426 NP_Port qd_port_; | 427 NP_Port qd_port_; |
| 427 scoped_ptr<QuickDrawDrawingManager> qd_manager_; | 428 scoped_ptr<QuickDrawDrawingManager> qd_manager_; |
| 428 base::TimeTicks fast_path_enable_tick_; | 429 base::TimeTicks fast_path_enable_tick_; |
| 429 #endif | 430 #endif |
| 430 | 431 |
| 431 CALayer* layer_; // Used for CA drawing mode. Weak, retained by plug-in. | 432 CALayer* layer_; // Used for CA drawing mode. Weak, retained by plug-in. |
| 432 webkit_glue::WebPluginAcceleratedSurface* surface_; // Weak ref. | 433 WebPluginAcceleratedSurface* surface_; // Weak ref. |
| 433 CARenderer* renderer_; // Renders layer_ to surface_. | 434 CARenderer* renderer_; // Renders layer_ to surface_. |
| 434 scoped_ptr<base::RepeatingTimer<WebPluginDelegateImpl> > redraw_timer_; | 435 scoped_ptr<base::RepeatingTimer<WebPluginDelegateImpl> > redraw_timer_; |
| 435 | 436 |
| 436 // The upper-left corner of the web content area in screen coordinates, | 437 // The upper-left corner of the web content area in screen coordinates, |
| 437 // relative to an upper-left (0,0). | 438 // relative to an upper-left (0,0). |
| 438 gfx::Point content_area_origin_; | 439 gfx::Point content_area_origin_; |
| 439 | 440 |
| 440 bool containing_window_has_focus_; | 441 bool containing_window_has_focus_; |
| 441 bool initial_window_focus_; | 442 bool initial_window_focus_; |
| 442 bool container_is_visible_; | 443 bool container_is_visible_; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 // where SetContentAreaHasFocus is never called. See | 502 // where SetContentAreaHasFocus is never called. See |
| 502 // https://bugs.webkit.org/show_bug.cgi?id=46013 for details. | 503 // https://bugs.webkit.org/show_bug.cgi?id=46013 for details. |
| 503 bool containing_view_has_focus_; | 504 bool containing_view_has_focus_; |
| 504 | 505 |
| 505 // True if NPP_New did not return an error. | 506 // True if NPP_New did not return an error. |
| 506 bool creation_succeeded_; | 507 bool creation_succeeded_; |
| 507 | 508 |
| 508 DISALLOW_COPY_AND_ASSIGN(WebPluginDelegateImpl); | 509 DISALLOW_COPY_AND_ASSIGN(WebPluginDelegateImpl); |
| 509 }; | 510 }; |
| 510 | 511 |
| 511 #endif // WEBKIT_GLUE_PLUGINS_WEBPLUGIN_DELEGATE_IMPL_H_ | 512 } // namespace npapi |
| 513 } // namespace webkit |
| 514 |
| 515 #endif // WEBKIT_PLUGINS_NPAPI_WEBPLUGIN_DELEGATE_IMPL_H_ |
| OLD | NEW |