| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
| 11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
| 12 #if defined(OS_MACOSX) | 12 #if defined(OS_MACOSX) |
| 13 #include "base/scoped_cftyperef.h" | 13 #include "base/scoped_cftyperef.h" |
| 14 #endif | 14 #endif |
| 15 #include "base/scoped_handle.h" | 15 #include "base/scoped_handle.h" |
| 16 #include "base/scoped_ptr.h" | 16 #include "base/scoped_ptr.h" |
| 17 #include "base/shared_memory.h" | 17 #include "base/shared_memory.h" |
| 18 #include "base/timer.h" | 18 #include "base/timer.h" |
| 19 #include "chrome/common/chrome_plugin_api.h" | 19 #include "chrome/common/chrome_plugin_api.h" |
| 20 #include "chrome/common/transport_dib.h" | 20 #include "chrome/common/transport_dib.h" |
| 21 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
| 22 #include "ipc/ipc_message.h" | 22 #include "ipc/ipc_message.h" |
| 23 #include "webkit/glue/webplugin.h" | 23 #include "webkit/glue/webplugin.h" |
| 24 | 24 |
| 25 class PluginChannel; |
| 26 |
| 25 namespace base { | 27 namespace base { |
| 26 class WaitableEvent; | 28 class WaitableEvent; |
| 27 } | 29 } |
| 28 | 30 |
| 29 class PluginChannel; | 31 namespace webkit_glue { |
| 30 class WebPluginDelegate; | 32 class WebPluginDelegate; |
| 33 } |
| 31 | 34 |
| 32 // This is an implementation of WebPlugin that proxies all calls to the | 35 // This is an implementation of WebPlugin that proxies all calls to the |
| 33 // renderer. | 36 // renderer. |
| 34 class WebPluginProxy : public WebPlugin { | 37 class WebPluginProxy : public webkit_glue::WebPlugin { |
| 35 public: | 38 public: |
| 36 // Creates a new proxy for WebPlugin, using the given sender to send the | 39 // Creates a new proxy for WebPlugin, using the given sender to send the |
| 37 // marshalled WebPlugin calls. | 40 // marshalled WebPlugin calls. |
| 38 WebPluginProxy(PluginChannel* channel, | 41 WebPluginProxy(PluginChannel* channel, |
| 39 int route_id, | 42 int route_id, |
| 40 WebPluginDelegate* delegate, | |
| 41 const GURL& page_url); | 43 const GURL& page_url); |
| 42 ~WebPluginProxy(); | 44 ~WebPluginProxy(); |
| 43 | 45 |
| 46 void set_delegate(webkit_glue::WebPluginDelegate* d) { delegate_ = d; } |
| 47 |
| 44 // WebPlugin overrides | 48 // WebPlugin overrides |
| 45 void SetWindow(gfx::PluginWindowHandle window); | 49 void SetWindow(gfx::PluginWindowHandle window); |
| 46 void WillDestroyWindow(gfx::PluginWindowHandle window); | 50 void WillDestroyWindow(gfx::PluginWindowHandle window); |
| 47 #if defined(OS_WIN) | 51 #if defined(OS_WIN) |
| 48 void SetWindowlessPumpEvent(HANDLE pump_messages_event); | 52 void SetWindowlessPumpEvent(HANDLE pump_messages_event); |
| 49 // Returns true on success. | 53 // Returns true on success. |
| 50 bool SetModalDialogEvent(HANDLE modal_dialog_event); | 54 bool SetModalDialogEvent(HANDLE modal_dialog_event); |
| 51 #endif | 55 #endif |
| 52 void CancelResource(int id); | 56 void CancelResource(int id); |
| 53 void Invalidate(); | 57 void Invalidate(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 76 // Retrieves the browsing context associated with the renderer this plugin | 80 // Retrieves the browsing context associated with the renderer this plugin |
| 77 // is in. Calling multiple times will return the same value. | 81 // is in. Calling multiple times will return the same value. |
| 78 CPBrowsingContext GetCPBrowsingContext(); | 82 CPBrowsingContext GetCPBrowsingContext(); |
| 79 | 83 |
| 80 // Retrieves the WebPluginProxy for the given context that was returned by | 84 // Retrieves the WebPluginProxy for the given context that was returned by |
| 81 // GetCPBrowsingContext, or NULL if not found. | 85 // GetCPBrowsingContext, or NULL if not found. |
| 82 static WebPluginProxy* FromCPBrowsingContext(CPBrowsingContext context); | 86 static WebPluginProxy* FromCPBrowsingContext(CPBrowsingContext context); |
| 83 | 87 |
| 84 // Returns a WebPluginResourceClient object given its id, or NULL if no | 88 // Returns a WebPluginResourceClient object given its id, or NULL if no |
| 85 // object with that id exists. | 89 // object with that id exists. |
| 86 WebPluginResourceClient* GetResourceClient(int id); | 90 webkit_glue::WebPluginResourceClient* GetResourceClient(int id); |
| 87 | 91 |
| 88 // Returns the process id of the renderer that contains this plugin. | 92 // Returns the process id of the renderer that contains this plugin. |
| 89 int GetRendererProcessId(); | 93 int GetRendererProcessId(); |
| 90 | 94 |
| 91 // For windowless plugins, paints the given rectangle into the local buffer. | 95 // For windowless plugins, paints the given rectangle into the local buffer. |
| 92 void Paint(const gfx::Rect& rect); | 96 void Paint(const gfx::Rect& rect); |
| 93 | 97 |
| 94 // Callback from the renderer to let us know that a paint occurred. | 98 // Callback from the renderer to let us know that a paint occurred. |
| 95 void DidPaint(); | 99 void DidPaint(); |
| 96 | 100 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 115 void InitiateHTTPRangeRequest(const char* url, | 119 void InitiateHTTPRangeRequest(const char* url, |
| 116 const char* range_info, | 120 const char* range_info, |
| 117 intptr_t existing_stream, | 121 intptr_t existing_stream, |
| 118 bool notify_needed, | 122 bool notify_needed, |
| 119 intptr_t notify_data); | 123 intptr_t notify_data); |
| 120 | 124 |
| 121 void SetDeferResourceLoading(int resource_id, bool defer); | 125 void SetDeferResourceLoading(int resource_id, bool defer); |
| 122 | 126 |
| 123 bool IsOffTheRecord(); | 127 bool IsOffTheRecord(); |
| 124 | 128 |
| 125 void ResourceClientDeleted(WebPluginResourceClient* resource_client); | 129 void ResourceClientDeleted( |
| 130 webkit_glue::WebPluginResourceClient* resource_client); |
| 126 | 131 |
| 127 base::WaitableEvent* modal_dialog_event() { | 132 base::WaitableEvent* modal_dialog_event() { |
| 128 return modal_dialog_event_.get(); | 133 return modal_dialog_event_.get(); |
| 129 } | 134 } |
| 130 | 135 |
| 131 private: | 136 private: |
| 132 bool Send(IPC::Message* msg); | 137 bool Send(IPC::Message* msg); |
| 133 | 138 |
| 134 // Handler for sending over the paint event to the plugin. | 139 // Handler for sending over the paint event to the plugin. |
| 135 void OnPaint(const gfx::Rect& damaged_rect); | 140 void OnPaint(const gfx::Rect& damaged_rect); |
| 136 | 141 |
| 137 // Updates the shared memory section where windowless plugins paint. | 142 // Updates the shared memory section where windowless plugins paint. |
| 138 void SetWindowlessBuffer(const TransportDIB::Handle& windowless_buffer, | 143 void SetWindowlessBuffer(const TransportDIB::Handle& windowless_buffer, |
| 139 const TransportDIB::Handle& background_buffer); | 144 const TransportDIB::Handle& background_buffer); |
| 140 | 145 |
| 141 #if defined(OS_WIN) | 146 #if defined(OS_WIN) |
| 142 // Converts a shared memory section handle from the renderer process into a | 147 // Converts a shared memory section handle from the renderer process into a |
| 143 // bitmap and hdc that are mapped to this process. | 148 // bitmap and hdc that are mapped to this process. |
| 144 void ConvertBuffer(const base::SharedMemoryHandle& buffer, | 149 void ConvertBuffer(const base::SharedMemoryHandle& buffer, |
| 145 ScopedHandle* shared_section, | 150 ScopedHandle* shared_section, |
| 146 ScopedBitmap* bitmap, | 151 ScopedBitmap* bitmap, |
| 147 ScopedHDC* hdc); | 152 ScopedHDC* hdc); |
| 148 #endif | 153 #endif |
| 149 | 154 |
| 150 // Called when a plugin's origin moves, so that we can update the world | 155 // Called when a plugin's origin moves, so that we can update the world |
| 151 // transform of the local HDC. | 156 // transform of the local HDC. |
| 152 void UpdateTransform(); | 157 void UpdateTransform(); |
| 153 | 158 |
| 154 typedef base::hash_map<int, WebPluginResourceClient*> ResourceClientMap; | 159 typedef base::hash_map<int, webkit_glue::WebPluginResourceClient*> |
| 160 ResourceClientMap; |
| 155 ResourceClientMap resource_clients_; | 161 ResourceClientMap resource_clients_; |
| 156 | 162 |
| 157 scoped_refptr<PluginChannel> channel_; | 163 scoped_refptr<PluginChannel> channel_; |
| 158 int route_id_; | 164 int route_id_; |
| 159 uint32 cp_browsing_context_; | 165 uint32 cp_browsing_context_; |
| 160 NPObject* window_npobject_; | 166 NPObject* window_npobject_; |
| 161 NPObject* plugin_element_; | 167 NPObject* plugin_element_; |
| 162 WebPluginDelegate* delegate_; | 168 webkit_glue::WebPluginDelegate* delegate_; |
| 163 gfx::Rect damaged_rect_; | 169 gfx::Rect damaged_rect_; |
| 164 bool waiting_for_paint_; | 170 bool waiting_for_paint_; |
| 165 scoped_ptr<base::WaitableEvent> modal_dialog_event_; | 171 scoped_ptr<base::WaitableEvent> modal_dialog_event_; |
| 166 // The url of the main frame hosting the plugin. | 172 // The url of the main frame hosting the plugin. |
| 167 GURL page_url_; | 173 GURL page_url_; |
| 168 | 174 |
| 169 #if defined(OS_WIN) | 175 #if defined(OS_WIN) |
| 170 // Variables used for desynchronized windowless plugin painting. See note in | 176 // Variables used for desynchronized windowless plugin painting. See note in |
| 171 // webplugin_delegate_proxy.h for how this works. | 177 // webplugin_delegate_proxy.h for how this works. |
| 172 | 178 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 188 scoped_ptr<TransportDIB> windowless_dib_; | 194 scoped_ptr<TransportDIB> windowless_dib_; |
| 189 scoped_ptr<TransportDIB> background_dib_; | 195 scoped_ptr<TransportDIB> background_dib_; |
| 190 scoped_ptr<skia::PlatformCanvas> windowless_canvas_; | 196 scoped_ptr<skia::PlatformCanvas> windowless_canvas_; |
| 191 scoped_ptr<skia::PlatformCanvas> background_canvas_; | 197 scoped_ptr<skia::PlatformCanvas> background_canvas_; |
| 192 #endif | 198 #endif |
| 193 | 199 |
| 194 ScopedRunnableMethodFactory<WebPluginProxy> runnable_method_factory_; | 200 ScopedRunnableMethodFactory<WebPluginProxy> runnable_method_factory_; |
| 195 }; | 201 }; |
| 196 | 202 |
| 197 #endif // CHROME_PLUGIN_PLUGIN_WEBPLUGIN_PROXY_H__ | 203 #endif // CHROME_PLUGIN_PLUGIN_WEBPLUGIN_PROXY_H__ |
| OLD | NEW |