| 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_PLUGIN_PLUGIN_WEBPLUGIN_PROXY_H__ | 5 #ifndef CHROME_PLUGIN_PLUGIN_WEBPLUGIN_PROXY_H__ |
| 6 #define CHROME_PLUGIN_PLUGIN_WEBPLUGIN_PROXY_H__ | 6 #define CHROME_PLUGIN_PLUGIN_WEBPLUGIN_PROXY_H__ |
| 7 | 7 |
| 8 #include "base/hash_tables.h" | 8 #include "base/hash_tables.h" |
| 9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
| 10 #include "base/scoped_handle.h" | 10 #include "base/scoped_handle.h" |
| 11 #include "base/shared_memory.h" |
| 12 #include "base/timer.h" |
| 11 #include "chrome/common/ipc_message.h" | 13 #include "chrome/common/ipc_message.h" |
| 12 #include "chrome/common/chrome_plugin_api.h" | 14 #include "chrome/common/chrome_plugin_api.h" |
| 13 #include "webkit/glue/webplugin.h" | 15 #include "webkit/glue/webplugin.h" |
| 14 | 16 |
| 15 class PluginChannel; | 17 class PluginChannel; |
| 16 class WebPluginDelegate; | 18 class WebPluginDelegateImpl; |
| 17 | 19 |
| 18 // This is an implementation of WebPlugin that proxies all calls to the | 20 // This is an implementation of WebPlugin that proxies all calls to the |
| 19 // renderer. | 21 // renderer. |
| 20 class WebPluginProxy : public WebPlugin { | 22 class WebPluginProxy : public WebPlugin { |
| 21 public: | 23 public: |
| 22 // Creates a new proxy for WebPlugin, using the given sender to send the | 24 // Creates a new proxy for WebPlugin, using the given sender to send the |
| 23 // marshalled WebPlugin calls. | 25 // marshalled WebPlugin calls. |
| 24 WebPluginProxy(PluginChannel* channel, | 26 WebPluginProxy(PluginChannel* channel, |
| 25 int route_id, | 27 int route_id, |
| 26 WebPluginDelegate* delegate, | 28 WebPluginDelegateImpl* delegate, |
| 27 HANDLE modal_dialog_event); | 29 HANDLE modal_dialog_event); |
| 28 ~WebPluginProxy(); | 30 ~WebPluginProxy(); |
| 29 | 31 |
| 30 // WebPlugin overrides | 32 // WebPlugin overrides |
| 31 void SetWindow(HWND window, HANDLE pump_messages_event); | 33 void SetWindow(HWND window, HANDLE pump_messages_event); |
| 32 void CancelResource(int id); | 34 void CancelResource(int id); |
| 33 void Invalidate(); | 35 void Invalidate(); |
| 34 void InvalidateRect(const gfx::Rect& rect); | 36 void InvalidateRect(const gfx::Rect& rect); |
| 35 NPObject* GetWindowScriptNPObject(); | 37 NPObject* GetWindowScriptNPObject(); |
| 36 NPObject* GetPluginElement(); | 38 NPObject* GetPluginElement(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 53 CPBrowsingContext GetCPBrowsingContext(); | 55 CPBrowsingContext GetCPBrowsingContext(); |
| 54 | 56 |
| 55 // Retrieves the WebPluginProxy for the given context that was returned by | 57 // Retrieves the WebPluginProxy for the given context that was returned by |
| 56 // GetCPBrowsingContext, or NULL if not found. | 58 // GetCPBrowsingContext, or NULL if not found. |
| 57 static WebPluginProxy* FromCPBrowsingContext(CPBrowsingContext context); | 59 static WebPluginProxy* FromCPBrowsingContext(CPBrowsingContext context); |
| 58 | 60 |
| 59 // Returns a WebPluginResourceClient object given its id, or NULL if no | 61 // Returns a WebPluginResourceClient object given its id, or NULL if no |
| 60 // object with that id exists. | 62 // object with that id exists. |
| 61 WebPluginResourceClient* GetResourceClient(int id); | 63 WebPluginResourceClient* GetResourceClient(int id); |
| 62 | 64 |
| 63 void WillPaint(); | |
| 64 | |
| 65 // Notification received on a plugin issued resource request | 65 // Notification received on a plugin issued resource request |
| 66 // creation. | 66 // creation. |
| 67 void OnResourceCreated(int resource_id, HANDLE cookie); | 67 void OnResourceCreated(int resource_id, HANDLE cookie); |
| 68 | 68 |
| 69 void HandleURLRequest(const char *method, | 69 void HandleURLRequest(const char *method, |
| 70 bool is_javascript_url, | 70 bool is_javascript_url, |
| 71 const char* target, unsigned int len, | 71 const char* target, unsigned int len, |
| 72 const char* buf, bool is_file_data, | 72 const char* buf, bool is_file_data, |
| 73 bool notify, const char* url, | 73 bool notify, const char* url, |
| 74 void* notify_data, bool popups_allowed); | 74 void* notify_data, bool popups_allowed); |
| 75 | 75 |
| 76 void UpdateGeometry(const gfx::Rect& window_rect, |
| 77 const gfx::Rect& clip_rect, |
| 78 bool visible, |
| 79 const SharedMemoryHandle& windowless_buffer, |
| 80 const SharedMemoryLock& lock); |
| 81 |
| 76 private: | 82 private: |
| 77 bool Send(IPC::Message* msg); | 83 bool Send(IPC::Message* msg); |
| 78 | 84 |
| 85 // Called periodically so that we can paint windowless plugins. |
| 86 void OnPaintTimerFired(); |
| 87 |
| 88 // Updates the shared memory section where windowless plugins paint. |
| 89 void SetWindowlessBuffer(const SharedMemoryHandle& handle, |
| 90 const SharedMemoryLock& lock); |
| 91 |
| 92 // Called when a plugin's origin moves, so that we can update the world |
| 93 // transform of the local HDC. |
| 94 void UpdateTransform(); |
| 95 |
| 79 typedef base::hash_map<int, WebPluginResourceClient*> ResourceClientMap; | 96 typedef base::hash_map<int, WebPluginResourceClient*> ResourceClientMap; |
| 80 ResourceClientMap resource_clients_; | 97 ResourceClientMap resource_clients_; |
| 81 | 98 |
| 82 scoped_refptr<PluginChannel> channel_; | 99 scoped_refptr<PluginChannel> channel_; |
| 83 int route_id_; | 100 int route_id_; |
| 84 NPObject* window_npobject_; | 101 NPObject* window_npobject_; |
| 85 NPObject* plugin_element_; | 102 NPObject* plugin_element_; |
| 86 WebPluginDelegate* delegate_; | 103 WebPluginDelegateImpl* delegate_; |
| 87 gfx::Rect damaged_rect_; | |
| 88 bool waiting_for_paint_; | |
| 89 uint32 cp_browsing_context_; | 104 uint32 cp_browsing_context_; |
| 90 ScopedHandle modal_dialog_event_; | 105 ScopedHandle modal_dialog_event_; |
| 106 |
| 107 // Used to desynchronize windowless painting. We accumulate invalidates and |
| 108 // paint into a shared buffer when our repeating timer fires. After painting |
| 109 // we tell the renderer asynchronously and it paints from the buffer. This |
| 110 // allows the renderer to paint without a blocking call, which improves |
| 111 // performance, and lets us control the frame rate at which we paint. |
| 112 gfx::Rect damaged_rect_; |
| 113 base::RepeatingTimer<WebPluginProxy> paint_timer_; |
| 114 ScopedHandle windowless_shared_section_; |
| 115 ScopedBitmap windowless_bitmap_; |
| 116 ScopedHDC windowless_hdc_; |
| 117 ScopedHandle windowless_buffer_lock_; |
| 91 }; | 118 }; |
| 92 | 119 |
| 93 #endif // CHROME_PLUGIN_PLUGIN_WEBPLUGIN_PROXY_H__ | 120 #endif // CHROME_PLUGIN_PLUGIN_WEBPLUGIN_PROXY_H__ |
| OLD | NEW |