| 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_RENDERER_WEBPLUGIN_DELEGATE_PROXY_H__ | 5 #ifndef CHROME_RENDERER_WEBPLUGIN_DELEGATE_PROXY_H__ |
| 6 #define CHROME_RENDERER_WEBPLUGIN_DELEGATE_PROXY_H__ | 6 #define CHROME_RENDERER_WEBPLUGIN_DELEGATE_PROXY_H__ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/gfx/rect.h" | 10 #include "base/gfx/rect.h" |
| 11 #include "base/gfx/native_widget_types.h" | 11 #include "base/gfx/native_widget_types.h" |
| 12 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
| 13 #include "chrome/common/ipc_message.h" | 13 #include "chrome/common/ipc_message.h" |
| 14 #include "chrome/renderer/plugin_channel_host.h" | 14 #include "chrome/renderer/plugin_channel_host.h" |
| 15 #include "skia/ext/platform_canvas.h" |
| 15 #include "webkit/glue/webplugin.h" | 16 #include "webkit/glue/webplugin.h" |
| 16 #include "webkit/glue/webplugin_delegate.h" | 17 #include "webkit/glue/webplugin_delegate.h" |
| 17 | 18 |
| 18 class GURL; | 19 class GURL; |
| 19 struct NPObject; | 20 struct NPObject; |
| 20 class NPObjectStub; | 21 class NPObjectStub; |
| 21 struct PluginHostMsg_URLRequest_Params; | 22 struct PluginHostMsg_URLRequest_Params; |
| 22 class RenderView; | 23 class RenderView; |
| 23 class SkBitmap; | 24 class SkBitmap; |
| 24 | 25 |
| 25 namespace base { | 26 namespace base { |
| 26 class SharedMemory; | 27 class SharedMemory; |
| 27 class WaitableEvent; | 28 class WaitableEvent; |
| 28 } | 29 } |
| 29 | 30 |
| 30 namespace skia { | |
| 31 class PlatformCanvasWin; | |
| 32 } | |
| 33 | |
| 34 // An implementation of WebPluginDelegate that proxies all calls to | 31 // An implementation of WebPluginDelegate that proxies all calls to |
| 35 // the plugin process. | 32 // the plugin process. |
| 36 class WebPluginDelegateProxy : public WebPluginDelegate, | 33 class WebPluginDelegateProxy : public WebPluginDelegate, |
| 37 public IPC::Channel::Listener, | 34 public IPC::Channel::Listener, |
| 38 public IPC::Message::Sender { | 35 public IPC::Message::Sender { |
| 39 public: | 36 public: |
| 40 static WebPluginDelegateProxy* Create(const GURL& url, | 37 static WebPluginDelegateProxy* Create(const GURL& url, |
| 41 const std::string& mime_type, | 38 const std::string& mime_type, |
| 42 const std::string& clsid, | 39 const std::string& clsid, |
| 43 RenderView* render_view); | 40 RenderView* render_view); |
| 44 | 41 |
| 45 // Called to drop our back-pointer to the containing RenderView. | 42 // Called to drop our back-pointer to the containing RenderView. |
| 46 void DropRenderView() { render_view_ = NULL; } | 43 void DropRenderView() { render_view_ = NULL; } |
| 47 | 44 |
| 48 // Called to drop our pointer to the window script object. | 45 // Called to drop our pointer to the window script object. |
| 49 void DropWindowScriptObject() { window_script_object_ = NULL; } | 46 void DropWindowScriptObject() { window_script_object_ = NULL; } |
| 50 | 47 |
| 51 // Called to flush any deferred geometry changes to the plugin process. | 48 // Called to flush any deferred geometry changes to the plugin process. |
| 52 virtual void FlushGeometryUpdates(); | 49 virtual void FlushGeometryUpdates(); |
| 53 | 50 |
| 54 // WebPluginDelegate implementation: | 51 // WebPluginDelegate implementation: |
| 55 virtual void PluginDestroyed(); | 52 virtual void PluginDestroyed(); |
| 56 virtual bool Initialize(const GURL& url, char** argn, char** argv, int argc, | 53 virtual bool Initialize(const GURL& url, char** argn, char** argv, int argc, |
| 57 WebPlugin* plugin, bool load_manually); | 54 WebPlugin* plugin, bool load_manually); |
| 58 virtual void UpdateGeometry(const gfx::Rect& window_rect, | 55 virtual void UpdateGeometry(const gfx::Rect& window_rect, |
| 59 const gfx::Rect& clip_rect); | 56 const gfx::Rect& clip_rect); |
| 60 virtual void Paint(HDC hdc, const gfx::Rect& rect); | 57 virtual void Paint(gfx::NativeDrawingContext context, const gfx::Rect& rect); |
| 61 virtual void Print(HDC hdc); | 58 virtual void Print(gfx::NativeDrawingContext context); |
| 62 virtual NPObject* GetPluginScriptableObject(); | 59 virtual NPObject* GetPluginScriptableObject(); |
| 63 virtual void DidFinishLoadWithReason(NPReason reason); | 60 virtual void DidFinishLoadWithReason(NPReason reason); |
| 64 virtual void SetFocus(); | 61 virtual void SetFocus(); |
| 65 virtual bool HandleEvent(NPEvent* event, WebCursor* cursor); | 62 virtual bool HandleEvent(NPEvent* event, WebCursor* cursor); |
| 66 virtual int GetProcessId(); | 63 virtual int GetProcessId(); |
| 67 | 64 |
| 68 // IPC::Channel::Listener implementation: | 65 // IPC::Channel::Listener implementation: |
| 69 virtual void OnMessageReceived(const IPC::Message& msg); | 66 virtual void OnMessageReceived(const IPC::Message& msg); |
| 70 void OnChannelError(); | 67 void OnChannelError(); |
| 71 | 68 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 void OnMissingPluginStatus(int status); | 128 void OnMissingPluginStatus(int status); |
| 132 void OnGetCPBrowsingContext(uint32* context); | 129 void OnGetCPBrowsingContext(uint32* context); |
| 133 void OnCancelDocumentLoad(); | 130 void OnCancelDocumentLoad(); |
| 134 void OnInitiateHTTPRangeRequest(const std::string& url, | 131 void OnInitiateHTTPRangeRequest(const std::string& url, |
| 135 const std::string& range_info, | 132 const std::string& range_info, |
| 136 intptr_t existing_stream, | 133 intptr_t existing_stream, |
| 137 bool notify_needed, | 134 bool notify_needed, |
| 138 intptr_t notify_data); | 135 intptr_t notify_data); |
| 139 | 136 |
| 140 // Draw a graphic indicating a crashed plugin. | 137 // Draw a graphic indicating a crashed plugin. |
| 141 void PaintSadPlugin(HDC hdc, const gfx::Rect& rect); | 138 void PaintSadPlugin(gfx::NativeDrawingContext context, const gfx::Rect& rect); |
| 142 | 139 |
| 140 #if defined(OS_WIN) |
| 143 // Returns true if the given rectangle is different in the hdc and the | 141 // Returns true if the given rectangle is different in the hdc and the |
| 144 // current background bitmap. | 142 // current background bitmap. |
| 145 bool BackgroundChanged(HDC hdc, const gfx::Rect& rect); | 143 bool BackgroundChanged(HDC hdc, const gfx::Rect& rect); |
| 144 #else |
| 145 // TODO(port): this should be portable; just avoiding windowless plugins for |
| 146 // now. |
| 147 #endif |
| 146 | 148 |
| 147 // Copies the given rectangle from the transport bitmap to the backing store. | 149 // Copies the given rectangle from the transport bitmap to the backing store. |
| 148 void CopyFromTransportToBacking(const gfx::Rect& rect); | 150 void CopyFromTransportToBacking(const gfx::Rect& rect); |
| 149 | 151 |
| 150 // Clears the shared memory section and canvases used for windowless plugins. | 152 // Clears the shared memory section and canvases used for windowless plugins. |
| 151 void ResetWindowlessBitmaps(); | 153 void ResetWindowlessBitmaps(); |
| 152 | 154 |
| 153 // Creates a shared memory section and canvas. | 155 // Creates a shared memory section and canvas. |
| 154 bool CreateBitmap(scoped_ptr<base::SharedMemory>* memory, | 156 bool CreateBitmap(scoped_ptr<base::SharedMemory>* memory, |
| 155 scoped_ptr<skia::PlatformCanvasWin>* canvas); | 157 scoped_ptr<skia::PlatformCanvas>* canvas); |
| 156 | 158 |
| 157 RenderView* render_view_; | 159 RenderView* render_view_; |
| 158 WebPlugin* plugin_; | 160 WebPlugin* plugin_; |
| 159 bool windowless_; | 161 bool windowless_; |
| 160 scoped_refptr<PluginChannelHost> channel_host_; | 162 scoped_refptr<PluginChannelHost> channel_host_; |
| 161 std::string mime_type_; | 163 std::string mime_type_; |
| 162 std::string clsid_; | 164 std::string clsid_; |
| 163 int instance_id_; | 165 int instance_id_; |
| 164 FilePath plugin_path_; | 166 FilePath plugin_path_; |
| 165 | 167 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 180 // True if we got an invalidate from the plugin and are waiting for a paint. | 182 // True if we got an invalidate from the plugin and are waiting for a paint. |
| 181 bool invalidate_pending_; | 183 bool invalidate_pending_; |
| 182 | 184 |
| 183 // Used to desynchronize windowless painting. When WebKit paints, we bitblt | 185 // Used to desynchronize windowless painting. When WebKit paints, we bitblt |
| 184 // from our backing store of what the plugin rectangle looks like. The | 186 // from our backing store of what the plugin rectangle looks like. The |
| 185 // plugin paints into the transport store, and we copy that to our backing | 187 // plugin paints into the transport store, and we copy that to our backing |
| 186 // store when we get an invalidate from it. The background bitmap is used | 188 // store when we get an invalidate from it. The background bitmap is used |
| 187 // for transparent plugins, as they need the backgroud data during painting. | 189 // for transparent plugins, as they need the backgroud data during painting. |
| 188 bool transparent_; | 190 bool transparent_; |
| 189 scoped_ptr<base::SharedMemory> backing_store_; | 191 scoped_ptr<base::SharedMemory> backing_store_; |
| 190 scoped_ptr<skia::PlatformCanvasWin> backing_store_canvas_; | 192 scoped_ptr<skia::PlatformCanvas> backing_store_canvas_; |
| 191 scoped_ptr<base::SharedMemory> transport_store_; | 193 scoped_ptr<base::SharedMemory> transport_store_; |
| 192 scoped_ptr<skia::PlatformCanvasWin> transport_store_canvas_; | 194 scoped_ptr<skia::PlatformCanvas> transport_store_canvas_; |
| 193 scoped_ptr<base::SharedMemory> background_store_; | 195 scoped_ptr<base::SharedMemory> background_store_; |
| 194 scoped_ptr<skia::PlatformCanvasWin> background_store_canvas_; | 196 scoped_ptr<skia::PlatformCanvas> background_store_canvas_; |
| 195 // This lets us know which portion of the backing store has been painted into. | 197 // This lets us know which portion of the backing store has been painted into. |
| 196 gfx::Rect backing_store_painted_; | 198 gfx::Rect backing_store_painted_; |
| 197 | 199 |
| 198 DISALLOW_EVIL_CONSTRUCTORS(WebPluginDelegateProxy); | 200 DISALLOW_EVIL_CONSTRUCTORS(WebPluginDelegateProxy); |
| 199 }; | 201 }; |
| 200 | 202 |
| 201 #endif // CHROME_RENDERER_WEBPLUGIN_DELEGATE_PROXY_H_ | 203 #endif // CHROME_RENDERER_WEBPLUGIN_DELEGATE_PROXY_H_ |
| OLD | NEW |