| 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_DELEGATE_PROXY_H_ | 5 #ifndef CONTENT_RENDERER_NPAPI_WEBPLUGIN_DELEGATE_PROXY_H_ |
| 6 #define CONTENT_RENDERER_NPAPI_WEBPLUGIN_DELEGATE_PROXY_H_ | 6 #define CONTENT_RENDERER_NPAPI_WEBPLUGIN_DELEGATE_PROXY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 class SkBitmap; | 32 class SkBitmap; |
| 33 | 33 |
| 34 namespace base { | 34 namespace base { |
| 35 class WaitableEvent; | 35 class WaitableEvent; |
| 36 } | 36 } |
| 37 | 37 |
| 38 namespace content { | 38 namespace content { |
| 39 class NPObjectStub; | 39 class NPObjectStub; |
| 40 class PluginChannelHost; | 40 class PluginChannelHost; |
| 41 class RenderViewImpl; | 41 class RenderViewImpl; |
| 42 class WebPluginImpl; |
| 42 | 43 |
| 43 // An implementation of WebPluginDelegate that proxies all calls to | 44 // An implementation of WebPluginDelegate that proxies all calls to |
| 44 // the plugin process. | 45 // the plugin process. |
| 45 class WebPluginDelegateProxy | 46 class WebPluginDelegateProxy |
| 46 : public WebPluginDelegate, | 47 : public WebPluginDelegate, |
| 47 public IPC::Listener, | 48 public IPC::Listener, |
| 48 public IPC::Sender, | 49 public IPC::Sender, |
| 49 public base::SupportsWeakPtr<WebPluginDelegateProxy> { | 50 public base::SupportsWeakPtr<WebPluginDelegateProxy> { |
| 50 public: | 51 public: |
| 51 WebPluginDelegateProxy(const std::string& mime_type, | 52 WebPluginDelegateProxy(WebPluginImpl* plugin, |
| 53 const std::string& mime_type, |
| 52 const base::WeakPtr<RenderViewImpl>& render_view); | 54 const base::WeakPtr<RenderViewImpl>& render_view); |
| 53 | 55 |
| 54 // WebPluginDelegate implementation: | 56 // WebPluginDelegate implementation: |
| 55 virtual void PluginDestroyed() OVERRIDE; | 57 virtual void PluginDestroyed() OVERRIDE; |
| 56 virtual bool Initialize(const GURL& url, | 58 virtual bool Initialize(const GURL& url, |
| 57 const std::vector<std::string>& arg_names, | 59 const std::vector<std::string>& arg_names, |
| 58 const std::vector<std::string>& arg_values, | 60 const std::vector<std::string>& arg_values, |
| 59 WebPlugin* plugin, | |
| 60 bool load_manually) OVERRIDE; | 61 bool load_manually) OVERRIDE; |
| 61 virtual void UpdateGeometry(const gfx::Rect& window_rect, | 62 virtual void UpdateGeometry(const gfx::Rect& window_rect, |
| 62 const gfx::Rect& clip_rect) OVERRIDE; | 63 const gfx::Rect& clip_rect) OVERRIDE; |
| 63 virtual void Paint(SkCanvas* canvas, const gfx::Rect& rect) OVERRIDE; | 64 virtual void Paint(SkCanvas* canvas, const gfx::Rect& rect) OVERRIDE; |
| 64 virtual NPObject* GetPluginScriptableObject() OVERRIDE; | 65 virtual NPObject* GetPluginScriptableObject() OVERRIDE; |
| 65 virtual struct _NPP* GetPluginNPP() OVERRIDE; | 66 virtual struct _NPP* GetPluginNPP() OVERRIDE; |
| 66 virtual bool GetFormValue(string16* value) OVERRIDE; | 67 virtual bool GetFormValue(string16* value) OVERRIDE; |
| 67 virtual void DidFinishLoadWithReason(const GURL& url, NPReason reason, | 68 virtual void DidFinishLoadWithReason(const GURL& url, NPReason reason, |
| 68 int notify_id) OVERRIDE; | 69 int notify_id) OVERRIDE; |
| 69 virtual void SetFocus(bool focused) OVERRIDE; | 70 virtual void SetFocus(bool focused) OVERRIDE; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 const std::string& headers, | 116 const std::string& headers, |
| 116 uint32 expected_length, | 117 uint32 expected_length, |
| 117 uint32 last_modified) OVERRIDE; | 118 uint32 last_modified) OVERRIDE; |
| 118 virtual void DidReceiveManualData(const char* buffer, int length) OVERRIDE; | 119 virtual void DidReceiveManualData(const char* buffer, int length) OVERRIDE; |
| 119 virtual void DidFinishManualLoading() OVERRIDE; | 120 virtual void DidFinishManualLoading() OVERRIDE; |
| 120 virtual void DidManualLoadFail() OVERRIDE; | 121 virtual void DidManualLoadFail() OVERRIDE; |
| 121 virtual WebPluginResourceClient* CreateResourceClient( | 122 virtual WebPluginResourceClient* CreateResourceClient( |
| 122 unsigned long resource_id, const GURL& url, int notify_id) OVERRIDE; | 123 unsigned long resource_id, const GURL& url, int notify_id) OVERRIDE; |
| 123 virtual WebPluginResourceClient* CreateSeekableResourceClient( | 124 virtual WebPluginResourceClient* CreateSeekableResourceClient( |
| 124 unsigned long resource_id, int range_request_id) OVERRIDE; | 125 unsigned long resource_id, int range_request_id) OVERRIDE; |
| 126 virtual void FetchURL(unsigned long resource_id, |
| 127 int notify_id, |
| 128 const GURL& url, |
| 129 const GURL& first_party_for_cookies, |
| 130 const std::string& method, |
| 131 const std::string& post_data, |
| 132 const GURL& referrer, |
| 133 bool notify_redirects, |
| 134 bool is_plugin_src_load, |
| 135 int origin_pid, |
| 136 int render_view_id) OVERRIDE; |
| 125 | 137 |
| 126 gfx::PluginWindowHandle GetPluginWindowHandle(); | 138 gfx::PluginWindowHandle GetPluginWindowHandle(); |
| 127 | 139 |
| 128 protected: | 140 protected: |
| 129 friend class base::DeleteHelper<WebPluginDelegateProxy>; | 141 friend class base::DeleteHelper<WebPluginDelegateProxy>; |
| 130 virtual ~WebPluginDelegateProxy(); | 142 virtual ~WebPluginDelegateProxy(); |
| 131 | 143 |
| 132 private: | 144 private: |
| 133 struct SharedBitmap { | 145 struct SharedBitmap { |
| 134 SharedBitmap(); | 146 SharedBitmap(); |
| 135 ~SharedBitmap(); | 147 ~SharedBitmap(); |
| 136 | 148 |
| 137 scoped_ptr<TransportDIB> dib; | 149 scoped_ptr<TransportDIB> dib; |
| 138 scoped_ptr<SkCanvas> canvas; | 150 scoped_ptr<SkCanvas> canvas; |
| 139 }; | 151 }; |
| 140 | 152 |
| 141 // Message handlers for messages that proxy WebPlugin methods, which | 153 // Message handlers for messages that proxy WebPlugin methods, which |
| 142 // we translate into calls to the real WebPlugin. | 154 // we translate into calls to the real WebPlugin. |
| 143 void OnSetWindow(gfx::PluginWindowHandle window); | 155 void OnSetWindow(gfx::PluginWindowHandle window); |
| 144 #if defined(OS_WIN) | |
| 145 void OnSetWindowlessData(HANDLE modal_loop_pump_messages_event, | |
| 146 gfx::NativeViewId dummy_activation_window); | |
| 147 void OnNotifyIMEStatus(const int input_mode, const gfx::Rect& caret_rect); | |
| 148 #endif | |
| 149 void OnCompleteURL(const std::string& url_in, std::string* url_out, | 156 void OnCompleteURL(const std::string& url_in, std::string* url_out, |
| 150 bool* result); | 157 bool* result); |
| 151 void OnHandleURLRequest(const PluginHostMsg_URLRequest_Params& params); | 158 void OnHandleURLRequest(const PluginHostMsg_URLRequest_Params& params); |
| 152 void OnCancelResource(int id); | 159 void OnCancelResource(int id); |
| 153 void OnInvalidateRect(const gfx::Rect& rect); | 160 void OnInvalidateRect(const gfx::Rect& rect); |
| 154 void OnGetWindowScriptNPObject(int route_id, bool* success); | 161 void OnGetWindowScriptNPObject(int route_id, bool* success); |
| 155 void OnResolveProxy(const GURL& url, bool* result, std::string* proxy_list); | 162 void OnResolveProxy(const GURL& url, bool* result, std::string* proxy_list); |
| 156 void OnGetPluginElement(int route_id, bool* success); | 163 void OnGetPluginElement(int route_id, bool* success); |
| 157 void OnSetCookie(const GURL& url, | 164 void OnSetCookie(const GURL& url, |
| 158 const GURL& first_party_for_cookies, | 165 const GURL& first_party_for_cookies, |
| 159 const std::string& cookie); | 166 const std::string& cookie); |
| 160 void OnGetCookies(const GURL& url, const GURL& first_party_for_cookies, | 167 void OnGetCookies(const GURL& url, const GURL& first_party_for_cookies, |
| 161 std::string* cookies); | 168 std::string* cookies); |
| 162 void OnCancelDocumentLoad(); | 169 void OnCancelDocumentLoad(); |
| 163 void OnInitiateHTTPRangeRequest(const std::string& url, | 170 void OnInitiateHTTPRangeRequest(const std::string& url, |
| 164 const std::string& range_info, | 171 const std::string& range_info, |
| 165 int range_request_id); | 172 int range_request_id); |
| 166 void OnDeferResourceLoading(unsigned long resource_id, bool defer); | 173 void OnDeferResourceLoading(unsigned long resource_id, bool defer); |
| 167 | 174 void OnURLRedirectResponse(bool allow, int resource_id); |
| 175 void OnCheckIfRunInsecureContent(const GURL& url, bool* result); |
| 168 #if defined(OS_MACOSX) | 176 #if defined(OS_MACOSX) |
| 169 void OnFocusChanged(bool focused); | 177 void OnFocusChanged(bool focused); |
| 170 void OnStartIme(); | 178 void OnStartIme(); |
| 171 // Accelerated (Core Animation) plugin implementation. | 179 // Accelerated (Core Animation) plugin implementation. |
| 172 void OnAcceleratedPluginEnabledRendering(); | 180 void OnAcceleratedPluginEnabledRendering(); |
| 173 void OnAcceleratedPluginAllocatedIOSurface(int32 width, | 181 void OnAcceleratedPluginAllocatedIOSurface(int32 width, |
| 174 int32 height, | 182 int32 height, |
| 175 uint32 surface_id); | 183 uint32 surface_id); |
| 176 void OnAcceleratedPluginSwappedIOSurface(); | 184 void OnAcceleratedPluginSwappedIOSurface(); |
| 177 #endif | 185 #endif |
| 178 | 186 #if defined(OS_WIN) |
| 179 void OnURLRedirectResponse(bool allow, int resource_id); | 187 void OnSetWindowlessData(HANDLE modal_loop_pump_messages_event, |
| 180 | 188 gfx::NativeViewId dummy_activation_window); |
| 189 void OnNotifyIMEStatus(const int input_mode, const gfx::Rect& caret_rect); |
| 190 #endif |
| 181 // Helper function that sends the UpdateGeometry message. | 191 // Helper function that sends the UpdateGeometry message. |
| 182 void SendUpdateGeometry(bool bitmaps_changed); | 192 void SendUpdateGeometry(bool bitmaps_changed); |
| 183 | 193 |
| 184 // Copies the given rectangle from the back-buffer transport_stores_ bitmap to | 194 // Copies the given rectangle from the back-buffer transport_stores_ bitmap to |
| 185 // the front-buffer transport_stores_ bitmap. | 195 // the front-buffer transport_stores_ bitmap. |
| 186 void CopyFromBackBufferToFrontBuffer(const gfx::Rect& rect); | 196 void CopyFromBackBufferToFrontBuffer(const gfx::Rect& rect); |
| 187 | 197 |
| 188 // Updates the front-buffer with the given rectangle from the back-buffer, | 198 // Updates the front-buffer with the given rectangle from the back-buffer, |
| 189 // either by copying the rectangle or flipping the buffers. | 199 // either by copying the rectangle or flipping the buffers. |
| 190 void UpdateFrontBuffer(const gfx::Rect& rect, bool allow_buffer_flipping); | 200 void UpdateFrontBuffer(const gfx::Rect& rect, bool allow_buffer_flipping); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 // plugin window gets destroyed, or when the plugin has crashed (at which | 241 // plugin window gets destroyed, or when the plugin has crashed (at which |
| 232 // point the window has already been destroyed). | 242 // point the window has already been destroyed). |
| 233 void WillDestroyWindow(); | 243 void WillDestroyWindow(); |
| 234 | 244 |
| 235 #if defined(OS_WIN) | 245 #if defined(OS_WIN) |
| 236 // Returns true if we should update the plugin geometry synchronously. | 246 // Returns true if we should update the plugin geometry synchronously. |
| 237 bool UseSynchronousGeometryUpdates(); | 247 bool UseSynchronousGeometryUpdates(); |
| 238 #endif | 248 #endif |
| 239 | 249 |
| 240 base::WeakPtr<RenderViewImpl> render_view_; | 250 base::WeakPtr<RenderViewImpl> render_view_; |
| 241 WebPlugin* plugin_; | 251 WebPluginImpl* plugin_; |
| 242 bool uses_shared_bitmaps_; | 252 bool uses_shared_bitmaps_; |
| 243 #if defined(OS_MACOSX) | 253 #if defined(OS_MACOSX) |
| 244 bool uses_compositor_; | 254 bool uses_compositor_; |
| 245 #elif defined(OS_WIN) | 255 #elif defined(OS_WIN) |
| 246 // Used for windowless plugins so that keyboard activation works. | 256 // Used for windowless plugins so that keyboard activation works. |
| 247 gfx::NativeViewId dummy_activation_window_; | 257 gfx::NativeViewId dummy_activation_window_; |
| 248 #endif | 258 #endif |
| 249 gfx::PluginWindowHandle window_; | 259 gfx::PluginWindowHandle window_; |
| 250 scoped_refptr<PluginChannelHost> channel_host_; | 260 scoped_refptr<PluginChannelHost> channel_host_; |
| 251 std::string mime_type_; | 261 std::string mime_type_; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 | 297 |
| 288 // The url of the main frame hosting the plugin. | 298 // The url of the main frame hosting the plugin. |
| 289 GURL page_url_; | 299 GURL page_url_; |
| 290 | 300 |
| 291 DISALLOW_COPY_AND_ASSIGN(WebPluginDelegateProxy); | 301 DISALLOW_COPY_AND_ASSIGN(WebPluginDelegateProxy); |
| 292 }; | 302 }; |
| 293 | 303 |
| 294 } // namespace content | 304 } // namespace content |
| 295 | 305 |
| 296 #endif // CONTENT_RENDERER_NPAPI_WEBPLUGIN_DELEGATE_PROXY_H_ | 306 #endif // CONTENT_RENDERER_NPAPI_WEBPLUGIN_DELEGATE_PROXY_H_ |
| OLD | NEW |