| 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) OVERRIDE; |
| 125 | 135 |
| 126 gfx::PluginWindowHandle GetPluginWindowHandle(); | 136 gfx::PluginWindowHandle GetPluginWindowHandle(); |
| 127 | 137 |
| 128 protected: | 138 protected: |
| 129 friend class base::DeleteHelper<WebPluginDelegateProxy>; | 139 friend class base::DeleteHelper<WebPluginDelegateProxy>; |
| 130 virtual ~WebPluginDelegateProxy(); | 140 virtual ~WebPluginDelegateProxy(); |
| 131 | 141 |
| 132 private: | 142 private: |
| 133 struct SharedBitmap { | 143 struct SharedBitmap { |
| 134 SharedBitmap(); | 144 SharedBitmap(); |
| 135 ~SharedBitmap(); | 145 ~SharedBitmap(); |
| 136 | 146 |
| 137 scoped_ptr<TransportDIB> dib; | 147 scoped_ptr<TransportDIB> dib; |
| 138 scoped_ptr<SkCanvas> canvas; | 148 scoped_ptr<SkCanvas> canvas; |
| 139 }; | 149 }; |
| 140 | 150 |
| 141 // Message handlers for messages that proxy WebPlugin methods, which | 151 // Message handlers for messages that proxy WebPlugin methods, which |
| 142 // we translate into calls to the real WebPlugin. | 152 // we translate into calls to the real WebPlugin. |
| 143 void OnSetWindow(gfx::PluginWindowHandle window); | 153 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, | 154 void OnCompleteURL(const std::string& url_in, std::string* url_out, |
| 150 bool* result); | 155 bool* result); |
| 151 void OnHandleURLRequest(const PluginHostMsg_URLRequest_Params& params); | 156 void OnHandleURLRequest(const PluginHostMsg_URLRequest_Params& params); |
| 152 void OnCancelResource(int id); | 157 void OnCancelResource(int id); |
| 153 void OnInvalidateRect(const gfx::Rect& rect); | 158 void OnInvalidateRect(const gfx::Rect& rect); |
| 154 void OnGetWindowScriptNPObject(int route_id, bool* success); | 159 void OnGetWindowScriptNPObject(int route_id, bool* success); |
| 155 void OnResolveProxy(const GURL& url, bool* result, std::string* proxy_list); | 160 void OnResolveProxy(const GURL& url, bool* result, std::string* proxy_list); |
| 156 void OnGetPluginElement(int route_id, bool* success); | 161 void OnGetPluginElement(int route_id, bool* success); |
| 157 void OnSetCookie(const GURL& url, | 162 void OnSetCookie(const GURL& url, |
| 158 const GURL& first_party_for_cookies, | 163 const GURL& first_party_for_cookies, |
| 159 const std::string& cookie); | 164 const std::string& cookie); |
| 160 void OnGetCookies(const GURL& url, const GURL& first_party_for_cookies, | 165 void OnGetCookies(const GURL& url, const GURL& first_party_for_cookies, |
| 161 std::string* cookies); | 166 std::string* cookies); |
| 162 void OnCancelDocumentLoad(); | 167 void OnCancelDocumentLoad(); |
| 163 void OnInitiateHTTPRangeRequest(const std::string& url, | 168 void OnInitiateHTTPRangeRequest(const std::string& url, |
| 164 const std::string& range_info, | 169 const std::string& range_info, |
| 165 int range_request_id); | 170 int range_request_id); |
| 166 void OnDeferResourceLoading(unsigned long resource_id, bool defer); | 171 void OnDeferResourceLoading(unsigned long resource_id, bool defer); |
| 167 | 172 void OnURLRedirectResponse(bool allow, int resource_id); |
| 173 void OnCheckIfRunInsecureContent(const GURL& url, bool* result); |
| 168 #if defined(OS_MACOSX) | 174 #if defined(OS_MACOSX) |
| 169 void OnFocusChanged(bool focused); | 175 void OnFocusChanged(bool focused); |
| 170 void OnStartIme(); | 176 void OnStartIme(); |
| 171 // Accelerated (Core Animation) plugin implementation. | 177 // Accelerated (Core Animation) plugin implementation. |
| 172 void OnAcceleratedPluginEnabledRendering(); | 178 void OnAcceleratedPluginEnabledRendering(); |
| 173 void OnAcceleratedPluginAllocatedIOSurface(int32 width, | 179 void OnAcceleratedPluginAllocatedIOSurface(int32 width, |
| 174 int32 height, | 180 int32 height, |
| 175 uint32 surface_id); | 181 uint32 surface_id); |
| 176 void OnAcceleratedPluginSwappedIOSurface(); | 182 void OnAcceleratedPluginSwappedIOSurface(); |
| 177 #endif | 183 #endif |
| 178 | 184 #if defined(OS_WIN) |
| 179 void OnURLRedirectResponse(bool allow, int resource_id); | 185 void OnSetWindowlessData(HANDLE modal_loop_pump_messages_event, |
| 180 | 186 gfx::NativeViewId dummy_activation_window); |
| 187 void OnNotifyIMEStatus(const int input_mode, const gfx::Rect& caret_rect); |
| 188 #endif |
| 181 // Helper function that sends the UpdateGeometry message. | 189 // Helper function that sends the UpdateGeometry message. |
| 182 void SendUpdateGeometry(bool bitmaps_changed); | 190 void SendUpdateGeometry(bool bitmaps_changed); |
| 183 | 191 |
| 184 // Copies the given rectangle from the back-buffer transport_stores_ bitmap to | 192 // Copies the given rectangle from the back-buffer transport_stores_ bitmap to |
| 185 // the front-buffer transport_stores_ bitmap. | 193 // the front-buffer transport_stores_ bitmap. |
| 186 void CopyFromBackBufferToFrontBuffer(const gfx::Rect& rect); | 194 void CopyFromBackBufferToFrontBuffer(const gfx::Rect& rect); |
| 187 | 195 |
| 188 // Updates the front-buffer with the given rectangle from the back-buffer, | 196 // Updates the front-buffer with the given rectangle from the back-buffer, |
| 189 // either by copying the rectangle or flipping the buffers. | 197 // either by copying the rectangle or flipping the buffers. |
| 190 void UpdateFrontBuffer(const gfx::Rect& rect, bool allow_buffer_flipping); | 198 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 | 239 // plugin window gets destroyed, or when the plugin has crashed (at which |
| 232 // point the window has already been destroyed). | 240 // point the window has already been destroyed). |
| 233 void WillDestroyWindow(); | 241 void WillDestroyWindow(); |
| 234 | 242 |
| 235 #if defined(OS_WIN) | 243 #if defined(OS_WIN) |
| 236 // Returns true if we should update the plugin geometry synchronously. | 244 // Returns true if we should update the plugin geometry synchronously. |
| 237 bool UseSynchronousGeometryUpdates(); | 245 bool UseSynchronousGeometryUpdates(); |
| 238 #endif | 246 #endif |
| 239 | 247 |
| 240 base::WeakPtr<RenderViewImpl> render_view_; | 248 base::WeakPtr<RenderViewImpl> render_view_; |
| 241 WebPlugin* plugin_; | 249 WebPluginImpl* plugin_; |
| 242 bool uses_shared_bitmaps_; | 250 bool uses_shared_bitmaps_; |
| 243 #if defined(OS_MACOSX) | 251 #if defined(OS_MACOSX) |
| 244 bool uses_compositor_; | 252 bool uses_compositor_; |
| 245 #elif defined(OS_WIN) | 253 #elif defined(OS_WIN) |
| 246 // Used for windowless plugins so that keyboard activation works. | 254 // Used for windowless plugins so that keyboard activation works. |
| 247 gfx::NativeViewId dummy_activation_window_; | 255 gfx::NativeViewId dummy_activation_window_; |
| 248 #endif | 256 #endif |
| 249 gfx::PluginWindowHandle window_; | 257 gfx::PluginWindowHandle window_; |
| 250 scoped_refptr<PluginChannelHost> channel_host_; | 258 scoped_refptr<PluginChannelHost> channel_host_; |
| 251 std::string mime_type_; | 259 std::string mime_type_; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 | 295 |
| 288 // The url of the main frame hosting the plugin. | 296 // The url of the main frame hosting the plugin. |
| 289 GURL page_url_; | 297 GURL page_url_; |
| 290 | 298 |
| 291 DISALLOW_COPY_AND_ASSIGN(WebPluginDelegateProxy); | 299 DISALLOW_COPY_AND_ASSIGN(WebPluginDelegateProxy); |
| 292 }; | 300 }; |
| 293 | 301 |
| 294 } // namespace content | 302 } // namespace content |
| 295 | 303 |
| 296 #endif // CONTENT_RENDERER_NPAPI_WEBPLUGIN_DELEGATE_PROXY_H_ | 304 #endif // CONTENT_RENDERER_NPAPI_WEBPLUGIN_DELEGATE_PROXY_H_ |
| OLD | NEW |