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

Side by Side Diff: content/renderer/pepper/pepper_plugin_delegate_impl.h

Issue 20987009: Rename PepperPluginDelegateImpl to PepperHelperImpl after getting rid of the PluginDelegate interfa… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 4 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) 2012 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 CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_DELEGATE_IMPL_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_DELEGATE_IMPL_H_
7
8 #include <map>
9 #include <set>
10 #include <string>
11 #include <vector>
12
13 #include "base/basictypes.h"
14 #include "base/id_map.h"
15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/weak_ptr.h"
18 #include "base/observer_list.h"
19 #include "content/public/renderer/render_view_observer.h"
20 #include "content/renderer/pepper/pepper_browser_connection.h"
21 #include "content/renderer/render_view_pepper_helper.h"
22 #include "ipc/ipc_platform_file.h"
23 #include "ppapi/c/pp_file_info.h"
24 #include "ppapi/c/ppb_tcp_socket.h"
25 #include "ppapi/c/private/ppb_tcp_socket_private.h"
26 #include "ppapi/shared_impl/private/ppb_tcp_server_socket_shared.h"
27 #include "ppapi/shared_impl/private/tcp_socket_private_impl.h"
28 #include "ui/base/ime/text_input_type.h"
29
30 namespace base {
31 class FilePath;
32 }
33
34 namespace ppapi {
35 class PepperFilePath;
36 class PpapiPermissions;
37 class PPB_X509Certificate_Fields;
38 namespace host {
39 class ResourceHost;
40 }
41 }
42
43 namespace WebKit {
44 class WebGamepads;
45 class WebURLResponse;
46 struct WebCompositionUnderline;
47 struct WebCursorInfo;
48 }
49
50 namespace content {
51 class ContextProviderCommandBuffer;
52 class GamepadSharedMemoryReader;
53 class PepperBroker;
54 class PluginModule;
55 class PPB_Broker_Impl;
56 class PPB_TCPSocket_Private_Impl;
57 class RenderViewImpl;
58 struct WebPluginInfo;
59
60 class PepperPluginDelegateImpl
61 : public RenderViewPepperHelper,
62 public base::SupportsWeakPtr<PepperPluginDelegateImpl>,
63 public RenderViewObserver {
64 public:
65 explicit PepperPluginDelegateImpl(RenderViewImpl* render_view);
66 virtual ~PepperPluginDelegateImpl();
67
68 RenderViewImpl* render_view() { return render_view_; }
69
70 PepperBrowserConnection* pepper_browser_connection() {
71 return &pepper_browser_connection_;
72 }
73
74 // A pointer is returned immediately, but it is not ready to be used until
75 // BrokerConnected has been called.
76 // The caller is responsible for calling Disconnect() on the returned pointer
77 // to clean up the corresponding resources allocated during this call.
78 PepperBroker* ConnectToBroker(PPB_Broker_Impl* client);
79
80 // Removes broker from pending_connect_broker_ if present. Returns true if so.
81 bool StopWaitingForBrokerConnection(PepperBroker* broker);
82
83 void RegisterTCPSocket(PPB_TCPSocket_Private_Impl* socket, uint32 socket_id);
84 void UnregisterTCPSocket(uint32 socket_id);
85 void TCPServerSocketStopListening(uint32 socket_id);
86
87 // Notifies that |instance| has changed the cursor.
88 // This will update the cursor appearance if it is currently over the plugin
89 // instance.
90 void DidChangeCursor(PepperPluginInstanceImpl* instance,
91 const WebKit::WebCursorInfo& cursor);
92
93 // Notifies that |instance| has received a mouse event.
94 void DidReceiveMouseEvent(PepperPluginInstanceImpl* instance);
95
96 // Notification that the given plugin is focused or unfocused.
97 void PluginFocusChanged(PepperPluginInstanceImpl* instance, bool focused);
98
99 // Notification that the text input status of the given plugin is changed.
100 void PluginTextInputTypeChanged(PepperPluginInstanceImpl* instance);
101
102 // Notification that the caret position in the given plugin is changed.
103 void PluginCaretPositionChanged(PepperPluginInstanceImpl* instance);
104
105 // Notification that the plugin requested to cancel the current composition.
106 void PluginRequestedCancelComposition(PepperPluginInstanceImpl* instance);
107
108 // Notification that the text selection in the given plugin is changed.
109 void PluginSelectionChanged(PepperPluginInstanceImpl* instance);
110
111 // Indicates that the given instance has been created.
112 void InstanceCreated(PepperPluginInstanceImpl* instance);
113
114 // Indicates that the given instance is being destroyed. This is called from
115 // the destructor, so it's important that the instance is not dereferenced
116 // from this call.
117 void InstanceDeleted(PepperPluginInstanceImpl* instance);
118
119 // Sends an async IPC to open a local file.
120 typedef base::Callback<void (base::PlatformFileError, base::PassPlatformFile)>
121 AsyncOpenFileCallback;
122 bool AsyncOpenFile(const base::FilePath& path,
123 int flags,
124 const AsyncOpenFileCallback& callback);
125
126 // Retrieve current gamepad data.
127 void SampleGamepads(WebKit::WebGamepads* data);
128
129 // Notifies the plugin of the document load. This should initiate the call to
130 // PPP_Instance.HandleDocumentLoad.
131 //
132 // The loader object should set itself on the PluginInstance as the document
133 // loader using set_document_loader.
134 void HandleDocumentLoad(PepperPluginInstanceImpl* instance,
135 const WebKit::WebURLResponse& response);
136
137 // Sets up the renderer host and out-of-process proxy for an external plugin
138 // module. Returns the renderer host, or NULL if it couldn't be created.
139 RendererPpapiHost* CreateExternalPluginModule(
140 scoped_refptr<PluginModule> module,
141 const base::FilePath& path,
142 ::ppapi::PpapiPermissions permissions,
143 const IPC::ChannelHandle& channel_handle,
144 base::ProcessId plugin_pid,
145 int plugin_child_id);
146
147 private:
148 // RenderViewPepperHelper implementation.
149 virtual WebKit::WebPlugin* CreatePepperWebPlugin(
150 const WebPluginInfo& webplugin_info,
151 const WebKit::WebPluginParams& params) OVERRIDE;
152 virtual void ViewWillInitiatePaint() OVERRIDE;
153 virtual void ViewInitiatedPaint() OVERRIDE;
154 virtual void ViewFlushedPaint() OVERRIDE;
155 virtual PepperPluginInstanceImpl* GetBitmapForOptimizedPluginPaint(
156 const gfx::Rect& paint_bounds,
157 TransportDIB** dib,
158 gfx::Rect* location,
159 gfx::Rect* clip,
160 float* scale_factor) OVERRIDE;
161 virtual void OnSetFocus(bool has_focus) OVERRIDE;
162 virtual void PageVisibilityChanged(bool is_visible) OVERRIDE;
163 virtual bool IsPluginFocused() const OVERRIDE;
164 virtual gfx::Rect GetCaretBounds() const OVERRIDE;
165 virtual ui::TextInputType GetTextInputType() const OVERRIDE;
166 virtual bool IsPluginAcceptingCompositionEvents() const OVERRIDE;
167 virtual bool CanComposeInline() const OVERRIDE;
168 virtual void GetSurroundingText(string16* text,
169 ui::Range* range) const OVERRIDE;
170 virtual void OnImeSetComposition(
171 const string16& text,
172 const std::vector<WebKit::WebCompositionUnderline>& underlines,
173 int selection_start,
174 int selection_end) OVERRIDE;
175 virtual void OnImeConfirmComposition(const string16& text) OVERRIDE;
176 virtual void WillHandleMouseEvent() OVERRIDE;
177
178 // RenderViewObserver implementation.
179 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
180 virtual void OnDestruct() OVERRIDE;
181
182 void OnTCPSocketConnectACK(uint32 plugin_dispatcher_id,
183 uint32 socket_id,
184 int32_t result,
185 const PP_NetAddress_Private& local_addr,
186 const PP_NetAddress_Private& remote_addr);
187 void OnTCPSocketSSLHandshakeACK(
188 uint32 plugin_dispatcher_id,
189 uint32 socket_id,
190 bool succeeded,
191 const ppapi::PPB_X509Certificate_Fields& certificate_fields);
192 void OnTCPSocketReadACK(uint32 plugin_dispatcher_id,
193 uint32 socket_id,
194 int32_t result,
195 const std::string& data);
196 void OnTCPSocketWriteACK(uint32 plugin_dispatcher_id,
197 uint32 socket_id,
198 int32_t result);
199 void OnTCPSocketSetOptionACK(uint32 plugin_dispatcher_id,
200 uint32 socket_id,
201 int32_t result);
202 void OnTCPServerSocketListenACK(uint32 plugin_dispatcher_id,
203 PP_Resource socket_resource,
204 uint32 socket_id,
205 const PP_NetAddress_Private& local_addr,
206 int32_t status);
207 void OnTCPServerSocketAcceptACK(uint32 plugin_dispatcher_id,
208 uint32 socket_id,
209 uint32 accepted_socket_id,
210 const PP_NetAddress_Private& local_addr,
211 const PP_NetAddress_Private& remote_addr);
212 void OnPpapiBrokerChannelCreated(int request_id,
213 base::ProcessId broker_pid,
214 const IPC::ChannelHandle& handle);
215 void OnAsyncFileOpened(base::PlatformFileError error_code,
216 IPC::PlatformFileForTransit file_for_transit,
217 int message_id);
218 void OnPpapiBrokerPermissionResult(int request_id, bool result);
219
220 // Attempts to create a PPAPI plugin for the given filepath. On success, it
221 // will return the newly-created module.
222 //
223 // There are two reasons for failure. The first is that the plugin isn't
224 // a PPAPI plugin. In this case, |*pepper_plugin_was_registered| will be set
225 // to false and the caller may want to fall back on creating an NPAPI plugin.
226 // the second is that the plugin failed to initialize. In this case,
227 // |*pepper_plugin_was_registered| will be set to true and the caller should
228 // not fall back on any other plugin types.
229 scoped_refptr<PluginModule> CreatePepperPluginModule(
230 const WebPluginInfo& webplugin_info,
231 bool* pepper_plugin_was_registered);
232
233 // Asynchronously attempts to create a PPAPI broker for the given plugin.
234 scoped_refptr<PepperBroker> CreateBroker(PluginModule* plugin_module);
235
236 // Create a new HostDispatcher for proxying, hook it to the PluginModule,
237 // and perform other common initialization.
238 RendererPpapiHost* CreateOutOfProcessModule(
239 PluginModule* module,
240 const base::FilePath& path,
241 ppapi::PpapiPermissions permissions,
242 const IPC::ChannelHandle& channel_handle,
243 base::ProcessId plugin_pid,
244 int plugin_child_id,
245 bool is_external);
246
247 // Pointer to the RenderView that owns us.
248 RenderViewImpl* render_view_;
249
250 // Connection for sending and receiving pepper host-related messages to/from
251 // the browser.
252 PepperBrowserConnection pepper_browser_connection_;
253
254 std::set<PepperPluginInstanceImpl*> active_instances_;
255
256 IDMap<AsyncOpenFileCallback> pending_async_open_files_;
257
258 IDMap<PPB_TCPSocket_Private_Impl> tcp_sockets_;
259
260 IDMap<ppapi::PPB_TCPServerSocket_Shared> tcp_server_sockets_;
261
262 typedef IDMap<scoped_refptr<PepperBroker>, IDMapOwnPointer> BrokerMap;
263 BrokerMap pending_connect_broker_;
264
265 typedef IDMap<base::WeakPtr<PPB_Broker_Impl> > PermissionRequestMap;
266 PermissionRequestMap pending_permission_requests_;
267
268 // Whether or not the focus is on a PPAPI plugin
269 PepperPluginInstanceImpl* focused_plugin_;
270
271 // Current text input composition text. Empty if no composition is in
272 // progress.
273 string16 composition_text_;
274
275 // The plugin instance that received the last mouse event. It is set to NULL
276 // if the last mouse event went to elements other than Pepper plugins.
277 // |last_mouse_event_target_| is not owned by this class. We can know about
278 // when it is destroyed via InstanceDeleted().
279 PepperPluginInstanceImpl* last_mouse_event_target_;
280
281 scoped_ptr<GamepadSharedMemoryReader> gamepad_shared_memory_reader_;
282
283 scoped_refptr<ContextProviderCommandBuffer> offscreen_context3d_;
284
285 DISALLOW_COPY_AND_ASSIGN(PepperPluginDelegateImpl);
286 };
287
288 } // namespace content
289
290 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_DELEGATE_IMPL_H_
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_platform_video_capture.cc ('k') | content/renderer/pepper/pepper_plugin_delegate_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698