Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: chrome/renderer/webplugin_delegate_proxy.h

Issue 6713005: Move a bunch of gpu/worker/plugin renderer code to content. I temporarily disabled the sad plugi... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_RENDERER_WEBPLUGIN_DELEGATE_PROXY_H_
6 #define CHROME_RENDERER_WEBPLUGIN_DELEGATE_PROXY_H_
7 #pragma once
8
9 #include <string>
10 #include <vector>
11
12 #include "app/surface/transport_dib.h"
13 #include "base/ref_counted.h"
14 #include "base/scoped_ptr.h"
15 #include "base/weak_ptr.h"
16 #include "googleurl/src/gurl.h"
17 #include "ipc/ipc_channel.h"
18 #include "ipc/ipc_message.h"
19 #include "ui/gfx/native_widget_types.h"
20 #include "ui/gfx/rect.h"
21 #include "webkit/plugins/npapi/webplugininfo.h"
22 #include "webkit/plugins/npapi/webplugin_delegate.h"
23
24 #if defined(OS_MACOSX)
25 #include "base/hash_tables.h"
26 #include "base/linked_ptr.h"
27 #endif
28
29 struct NPObject;
30 class NPObjectStub;
31 struct NPVariant_Param;
32 class PluginChannelHost;
33 struct PluginHostMsg_URLRequest_Params;
34 class RenderView;
35 class SkBitmap;
36
37 namespace base {
38 class SharedMemory;
39 class WaitableEvent;
40 }
41
42 namespace skia {
43 class PlatformCanvas;
44 }
45
46 namespace webkit {
47 namespace npapi {
48 class WebPlugin;
49 }
50 }
51
52 // An implementation of WebPluginDelegate that proxies all calls to
53 // the plugin process.
54 class WebPluginDelegateProxy
55 : public webkit::npapi::WebPluginDelegate,
56 public IPC::Channel::Listener,
57 public IPC::Message::Sender,
58 public base::SupportsWeakPtr<WebPluginDelegateProxy> {
59 public:
60 WebPluginDelegateProxy(const std::string& mime_type,
61 const base::WeakPtr<RenderView>& render_view);
62
63 // WebPluginDelegate implementation:
64 virtual void PluginDestroyed();
65 virtual bool Initialize(const GURL& url,
66 const std::vector<std::string>& arg_names,
67 const std::vector<std::string>& arg_values,
68 webkit::npapi::WebPlugin* plugin,
69 bool load_manually);
70 virtual void UpdateGeometry(const gfx::Rect& window_rect,
71 const gfx::Rect& clip_rect);
72 virtual void Paint(WebKit::WebCanvas* canvas, const gfx::Rect& rect);
73 virtual void Print(gfx::NativeDrawingContext context);
74 virtual NPObject* GetPluginScriptableObject();
75 virtual void DidFinishLoadWithReason(const GURL& url, NPReason reason,
76 int notify_id);
77 virtual void SetFocus(bool focused);
78 virtual bool HandleInputEvent(const WebKit::WebInputEvent& event,
79 WebKit::WebCursorInfo* cursor);
80 virtual int GetProcessId();
81
82 // Informs the plugin that its containing content view has gained or lost
83 // first responder status.
84 virtual void SetContentAreaFocus(bool has_focus);
85 #if defined(OS_MACOSX)
86 // Informs the plugin that its enclosing window has gained or lost focus.
87 virtual void SetWindowFocus(bool window_has_focus);
88 // Informs the plugin that its container (window/tab) has changed visibility.
89 virtual void SetContainerVisibility(bool is_visible);
90 // Informs the plugin that its enclosing window's frame has changed.
91 virtual void WindowFrameChanged(gfx::Rect window_frame, gfx::Rect view_frame);
92 // Informs the plugin that plugin IME has completed.
93 // If |text| is empty, composition was cancelled.
94 virtual void ImeCompositionCompleted(const string16& text, int plugin_id);
95 #endif
96
97 // IPC::Channel::Listener implementation:
98 virtual bool OnMessageReceived(const IPC::Message& msg);
99 virtual void OnChannelError();
100
101 // IPC::Message::Sender implementation:
102 virtual bool Send(IPC::Message* msg);
103
104 virtual void SendJavaScriptStream(const GURL& url,
105 const std::string& result,
106 bool success,
107 int notify_id);
108
109 virtual void DidReceiveManualResponse(const GURL& url,
110 const std::string& mime_type,
111 const std::string& headers,
112 uint32 expected_length,
113 uint32 last_modified);
114 virtual void DidReceiveManualData(const char* buffer, int length);
115 virtual void DidFinishManualLoading();
116 virtual void DidManualLoadFail();
117 virtual void InstallMissingPlugin();
118 virtual webkit::npapi::WebPluginResourceClient* CreateResourceClient(
119 unsigned long resource_id, const GURL& url, int notify_id);
120 virtual webkit::npapi::WebPluginResourceClient* CreateSeekableResourceClient(
121 unsigned long resource_id, int range_request_id);
122
123 gfx::PluginWindowHandle GetPluginWindowHandle();
124
125 protected:
126 template<class WebPluginDelegateProxy> friend class DeleteTask;
127 ~WebPluginDelegateProxy();
128
129 private:
130 // Message handlers for messages that proxy WebPlugin methods, which
131 // we translate into calls to the real WebPlugin.
132 void OnSetWindow(gfx::PluginWindowHandle window);
133 #if defined(OS_WIN)
134 void OnSetWindowlessPumpEvent(HANDLE modal_loop_pump_messages_event);
135 #endif
136 void OnCompleteURL(const std::string& url_in, std::string* url_out,
137 bool* result);
138 void OnHandleURLRequest(const PluginHostMsg_URLRequest_Params& params);
139 void OnCancelResource(int id);
140 void OnInvalidateRect(const gfx::Rect& rect);
141 void OnGetWindowScriptNPObject(int route_id, bool* success);
142 void OnGetPluginElement(int route_id, bool* success);
143 void OnSetCookie(const GURL& url,
144 const GURL& first_party_for_cookies,
145 const std::string& cookie);
146 void OnGetCookies(const GURL& url, const GURL& first_party_for_cookies,
147 std::string* cookies);
148 void OnMissingPluginStatus(int status);
149 void OnCancelDocumentLoad();
150 void OnInitiateHTTPRangeRequest(const std::string& url,
151 const std::string& range_info,
152 int range_request_id);
153 void OnDeferResourceLoading(unsigned long resource_id, bool defer);
154
155 #if defined(OS_MACOSX)
156 void OnFocusChanged(bool focused);
157 void OnStartIme();
158 void OnBindFakePluginWindowHandle(bool opaque);
159 void OnUpdateGeometry_ACK(int ack_key);
160 void OnAcceleratedSurfaceSetIOSurface(gfx::PluginWindowHandle window,
161 int32 width,
162 int32 height,
163 uint64 io_surface_identifier);
164 void OnAcceleratedSurfaceSetTransportDIB(gfx::PluginWindowHandle window,
165 int32 width,
166 int32 height,
167 TransportDIB::Handle transport_dib);
168 void OnAcceleratedSurfaceAllocTransportDIB(size_t size,
169 TransportDIB::Handle* dib_handle);
170 void OnAcceleratedSurfaceFreeTransportDIB(TransportDIB::Id dib_id);
171 void OnAcceleratedSurfaceBuffersSwapped(gfx::PluginWindowHandle window,
172 uint64 surface_id);
173 #endif
174
175 void OnURLRedirectResponse(bool allow, int resource_id);
176
177 // Draw a graphic indicating a crashed plugin.
178 void PaintSadPlugin(WebKit::WebCanvas* canvas, const gfx::Rect& rect);
179
180 // Returns true if the given rectangle is different in the native drawing
181 // context and the current background bitmap.
182 bool BackgroundChanged(gfx::NativeDrawingContext context,
183 const gfx::Rect& rect);
184
185 // Copies the given rectangle from the transport bitmap to the backing store.
186 void CopyFromTransportToBacking(const gfx::Rect& rect);
187
188 // Clears the shared memory section and canvases used for windowless plugins.
189 void ResetWindowlessBitmaps();
190
191 #if !defined(OS_WIN)
192 // Creates a process-local memory section and canvas. PlatformCanvas on
193 // Windows only works with a DIB, not arbitrary memory.
194 bool CreateLocalBitmap(std::vector<uint8>* memory,
195 scoped_ptr<skia::PlatformCanvas>* canvas);
196 #endif
197
198 // Creates a shared memory section and canvas.
199 bool CreateSharedBitmap(scoped_ptr<TransportDIB>* memory,
200 scoped_ptr<skia::PlatformCanvas>* canvas);
201
202 // Called for cleanup during plugin destruction. Normally right before the
203 // plugin window gets destroyed, or when the plugin has crashed (at which
204 // point the window has already been destroyed).
205 void WillDestroyWindow();
206
207 #if defined(OS_MACOSX)
208 // Synthesize a fake window handle for the plug-in to identify the instance
209 // to the browser, allowing mapping to a surface for hardware acceleration
210 // of plug-in content. The browser generates the handle which is then set on
211 // the plug-in. Returns true if it successfully sets the window handle on the
212 // plug-in.
213 bool BindFakePluginWindowHandle(bool opaque);
214
215 typedef base::hash_map<int, linked_ptr<TransportDIB> > OldTransportDIBMap;
216
217 OldTransportDIBMap old_transport_dibs_;
218 #endif // OS_MACOSX
219
220 #if defined(OS_WIN)
221 // Returns true if we should update the plugin geometry synchronously.
222 bool UseSynchronousGeometryUpdates();
223 #endif
224
225 base::WeakPtr<RenderView> render_view_;
226 webkit::npapi::WebPlugin* plugin_;
227 bool uses_shared_bitmaps_;
228 gfx::PluginWindowHandle window_;
229 scoped_refptr<PluginChannelHost> channel_host_;
230 std::string mime_type_;
231 int instance_id_;
232 webkit::npapi::WebPluginInfo info_;
233
234 gfx::Rect plugin_rect_;
235 gfx::Rect clip_rect_;
236
237 NPObject* npobject_;
238 base::WeakPtr<NPObjectStub> window_script_object_;
239
240 // Event passed in by the plugin process and is used to decide if
241 // messages need to be pumped in the NPP_HandleEvent sync call.
242 scoped_ptr<base::WaitableEvent> modal_loop_pump_messages_event_;
243
244 // Bitmap for crashed plugin
245 SkBitmap* sad_plugin_;
246
247 // True if we got an invalidate from the plugin and are waiting for a paint.
248 bool invalidate_pending_;
249
250 // Used to desynchronize windowless painting. When WebKit paints, we bitblt
251 // from our backing store of what the plugin rectangle looks like. The
252 // plugin paints into the transport store, and we copy that to our backing
253 // store when we get an invalidate from it. The background bitmap is used
254 // for transparent plugins, as they need the backgroud data during painting.
255 bool transparent_;
256 #if defined(OS_WIN)
257 scoped_ptr<TransportDIB> backing_store_;
258 #else
259 std::vector<uint8> backing_store_;
260 #endif
261 scoped_ptr<skia::PlatformCanvas> backing_store_canvas_;
262 scoped_ptr<TransportDIB> transport_store_;
263 scoped_ptr<skia::PlatformCanvas> transport_store_canvas_;
264 scoped_ptr<TransportDIB> background_store_;
265 scoped_ptr<skia::PlatformCanvas> background_store_canvas_;
266 // This lets us know which portion of the backing store has been painted into.
267 gfx::Rect backing_store_painted_;
268
269 // The url of the main frame hosting the plugin.
270 GURL page_url_;
271
272 DISALLOW_COPY_AND_ASSIGN(WebPluginDelegateProxy);
273 };
274
275 #endif // CHROME_RENDERER_WEBPLUGIN_DELEGATE_PROXY_H_
OLDNEW
« no previous file with comments | « chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc ('k') | chrome/renderer/webplugin_delegate_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698