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

Side by Side Diff: chrome/plugin/webplugin_proxy.h

Issue 6672048: Move plugin code to content. (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
« no previous file with comments | « chrome/plugin/webplugin_delegate_stub.cc ('k') | chrome/plugin/webplugin_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_PLUGIN_WEBPLUGIN_PROXY_H_
6 #define CHROME_PLUGIN_WEBPLUGIN_PROXY_H_
7 #pragma once
8
9 #include <string>
10
11 #if defined(USE_X11)
12 #include "ui/base/x/x11_util.h"
13 #endif
14 #include "app/surface/transport_dib.h"
15 #include "base/hash_tables.h"
16 #include "base/ref_counted.h"
17 #if defined(OS_MACOSX)
18 #include "base/mac/scoped_cftyperef.h"
19 #endif
20 #include "base/scoped_handle.h"
21 #include "base/scoped_ptr.h"
22 #include "base/shared_memory.h"
23 #include "base/timer.h"
24 #include "googleurl/src/gurl.h"
25 #include "ipc/ipc_message.h"
26 #include "webkit/plugins/npapi/webplugin.h"
27
28 class PluginChannel;
29
30 namespace webkit {
31 namespace npapi {
32 class WebPluginDelegateImpl;
33 }
34 }
35
36 #if defined(OS_MACOSX)
37 class WebPluginAcceleratedSurfaceProxy;
38 #endif
39
40 // This is an implementation of WebPlugin that proxies all calls to the
41 // renderer.
42 class WebPluginProxy : public webkit::npapi::WebPlugin {
43 public:
44 // Creates a new proxy for WebPlugin, using the given sender to send the
45 // marshalled WebPlugin calls.
46 WebPluginProxy(PluginChannel* channel,
47 int route_id,
48 const GURL& page_url,
49 gfx::NativeViewId containing_window,
50 int host_render_view_routing_id);
51 ~WebPluginProxy();
52
53 void set_delegate(webkit::npapi::WebPluginDelegateImpl* d) { delegate_ = d; }
54
55 // WebPlugin overrides
56 virtual void SetWindow(gfx::PluginWindowHandle window);
57
58 // Whether input events should be sent to the delegate.
59 virtual void SetAcceptsInputEvents(bool accepts);
60
61 virtual void WillDestroyWindow(gfx::PluginWindowHandle window);
62 #if defined(OS_WIN)
63 void SetWindowlessPumpEvent(HANDLE pump_messages_event);
64 #endif
65
66 virtual void CancelResource(unsigned long id);
67 virtual void Invalidate();
68 virtual void InvalidateRect(const gfx::Rect& rect);
69 virtual NPObject* GetWindowScriptNPObject();
70 virtual NPObject* GetPluginElement();
71 virtual void SetCookie(const GURL& url,
72 const GURL& first_party_for_cookies,
73 const std::string& cookie);
74 virtual std::string GetCookies(const GURL& url,
75 const GURL& first_party_for_cookies);
76
77 virtual void OnMissingPluginStatus(int status);
78 // class-specific methods
79
80 // Returns a WebPluginResourceClient object given its id, or NULL if no
81 // object with that id exists.
82 webkit::npapi::WebPluginResourceClient* GetResourceClient(int id);
83
84 // Returns the id of the renderer that contains this plugin.
85 int GetRendererId();
86
87 // Returns the id of the associated render view.
88 int host_render_view_routing_id() const {
89 return host_render_view_routing_id_;
90 }
91
92 // For windowless plugins, paints the given rectangle into the local buffer.
93 void Paint(const gfx::Rect& rect);
94
95 // Callback from the renderer to let us know that a paint occurred.
96 void DidPaint();
97
98 // Notification received on a plugin issued resource request creation.
99 void OnResourceCreated(int resource_id,
100 webkit::npapi::WebPluginResourceClient* client);
101
102 virtual void HandleURLRequest(const char* url,
103 const char* method,
104 const char* target,
105 const char* buf,
106 unsigned int len,
107 int notify_id,
108 bool popups_allowed,
109 bool notify_redirects);
110 void UpdateGeometry(const gfx::Rect& window_rect,
111 const gfx::Rect& clip_rect,
112 const TransportDIB::Handle& windowless_buffer,
113 const TransportDIB::Handle& background_buffer,
114 bool transparent
115 #if defined(OS_MACOSX)
116 ,
117 int ack_key
118 #endif
119 );
120 virtual void CancelDocumentLoad();
121 virtual void InitiateHTTPRangeRequest(
122 const char* url, const char* range_info, int range_request_id);
123 virtual void SetDeferResourceLoading(unsigned long resource_id, bool defer);
124 virtual bool IsOffTheRecord();
125 virtual void ResourceClientDeleted(
126 webkit::npapi::WebPluginResourceClient* resource_client);
127 gfx::NativeViewId containing_window() { return containing_window_; }
128
129 #if defined(OS_MACOSX)
130 virtual void FocusChanged(bool focused);
131
132 virtual void StartIme();
133
134 virtual void BindFakePluginWindowHandle(bool opaque);
135
136 virtual webkit::npapi::WebPluginAcceleratedSurface* GetAcceleratedSurface();
137
138 // Tell the browser (via the renderer) to invalidate because the
139 // accelerated buffers have changed.
140 virtual void AcceleratedFrameBuffersDidSwap(
141 gfx::PluginWindowHandle window, uint64 surface_id);
142
143 // Tell the renderer and browser to associate the given plugin handle with
144 // |accelerated_surface_identifier|. The geometry is used to resize any
145 // native "window" (which on the Mac is a just a view).
146 // This method is used when IOSurface support is available.
147 virtual void SetAcceleratedSurface(gfx::PluginWindowHandle window,
148 const gfx::Size& size,
149 uint64 accelerated_surface_identifier);
150
151 // Tell the renderer and browser to associate the given plugin handle with
152 // |dib_handle|. The geometry is used to resize any native "window" (which
153 // on the Mac is just a view).
154 // This method is used when IOSurface support is not available.
155 virtual void SetAcceleratedDIB(
156 gfx::PluginWindowHandle window,
157 const gfx::Size& size,
158 const TransportDIB::Handle& dib_handle);
159
160 // Create/destroy TranportDIBs via messages to the browser process.
161 // These are only used when IOSurface support is not available.
162 virtual void AllocSurfaceDIB(const size_t size,
163 TransportDIB::Handle* dib_handle);
164 virtual void FreeSurfaceDIB(TransportDIB::Id dib_id);
165 #endif
166
167 virtual void URLRedirectResponse(bool allow, int resource_id);
168
169 private:
170 bool Send(IPC::Message* msg);
171
172 // Handler for sending over the paint event to the plugin.
173 void OnPaint(const gfx::Rect& damaged_rect);
174
175 // Updates the shared memory section where windowless plugins paint.
176 void SetWindowlessBuffer(const TransportDIB::Handle& windowless_buffer,
177 const TransportDIB::Handle& background_buffer,
178 const gfx::Rect& window_rect);
179
180 typedef base::hash_map<int, webkit::npapi::WebPluginResourceClient*>
181 ResourceClientMap;
182 ResourceClientMap resource_clients_;
183
184 scoped_refptr<PluginChannel> channel_;
185 int route_id_;
186 NPObject* window_npobject_;
187 NPObject* plugin_element_;
188 webkit::npapi::WebPluginDelegateImpl* delegate_;
189 gfx::Rect damaged_rect_;
190 bool waiting_for_paint_;
191 gfx::NativeViewId containing_window_;
192 // The url of the main frame hosting the plugin.
193 GURL page_url_;
194
195 // Variables used for desynchronized windowless plugin painting. See note in
196 // webplugin_delegate_proxy.h for how this works.
197 bool transparent_;
198 #if defined(OS_MACOSX)
199 scoped_ptr<TransportDIB> windowless_dib_;
200 scoped_ptr<TransportDIB> background_dib_;
201 base::mac::ScopedCFTypeRef<CGContextRef> windowless_context_;
202 base::mac::ScopedCFTypeRef<CGContextRef> background_context_;
203 scoped_ptr<WebPluginAcceleratedSurfaceProxy> accelerated_surface_;
204 #else
205 scoped_ptr<skia::PlatformCanvas> windowless_canvas_;
206 scoped_ptr<skia::PlatformCanvas> background_canvas_;
207
208 #if defined(USE_X11)
209 scoped_ptr<TransportDIB> windowless_dib_;
210 scoped_ptr<TransportDIB> background_dib_;
211 // If we can use SHM pixmaps for windowless plugin painting or not.
212 bool use_shm_pixmap_;
213 // The SHM pixmap for windowless plugin painting.
214 XID windowless_shm_pixmap_;
215 #endif
216
217 #endif
218
219 // Contains the routing id of the host render view.
220 int host_render_view_routing_id_;
221
222 ScopedRunnableMethodFactory<WebPluginProxy> runnable_method_factory_;
223 };
224
225 #endif // CHROME_PLUGIN_WEBPLUGIN_PROXY_H_
OLDNEW
« no previous file with comments | « chrome/plugin/webplugin_delegate_stub.cc ('k') | chrome/plugin/webplugin_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698