| 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_PEPPER_PEPPER_PLUGIN_DELEGATE_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_DELEGATE_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_DELEGATE_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <map> | |
| 9 #include <set> | 8 #include <set> |
| 10 #include <string> | 9 #include <string> |
| 11 #include <vector> | |
| 12 | 10 |
| 13 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 14 #include "base/id_map.h" | 12 #include "base/id_map.h" |
| 15 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 18 #include "base/observer_list.h" | |
| 19 #include "content/public/renderer/render_view_observer.h" | 16 #include "content/public/renderer/render_view_observer.h" |
| 20 #include "content/renderer/pepper/pepper_browser_connection.h" | |
| 21 #include "content/renderer/pepper_helper.h" | 17 #include "content/renderer/pepper_helper.h" |
| 22 #include "ipc/ipc_platform_file.h" | |
| 23 #include "ppapi/c/pp_file_info.h" | 18 #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" | 19 #include "ui/base/ime/text_input_type.h" |
| 29 | 20 |
| 30 namespace base { | 21 namespace base { |
| 31 class FilePath; | 22 class FilePath; |
| 32 } | 23 } |
| 33 | 24 |
| 34 namespace ppapi { | 25 namespace ppapi { |
| 35 class PepperFilePath; | |
| 36 class PpapiPermissions; | 26 class PpapiPermissions; |
| 37 class PPB_X509Certificate_Fields; | |
| 38 namespace host { | |
| 39 class ResourceHost; | |
| 40 } | |
| 41 } | 27 } |
| 42 | 28 |
| 43 namespace WebKit { | 29 namespace WebKit { |
| 44 class WebGamepads; | 30 class WebGamepads; |
| 45 class WebURLResponse; | 31 class WebURLResponse; |
| 46 struct WebCompositionUnderline; | 32 struct WebCompositionUnderline; |
| 47 struct WebCursorInfo; | 33 struct WebCursorInfo; |
| 48 } | 34 } |
| 49 | 35 |
| 50 namespace content { | 36 namespace content { |
| 51 class ContextProviderCommandBuffer; | 37 class ContextProviderCommandBuffer; |
| 52 class GamepadSharedMemoryReader; | 38 class GamepadSharedMemoryReader; |
| 53 class PepperBroker; | 39 class PepperBroker; |
| 54 class PluginModule; | 40 class PluginModule; |
| 55 class PPB_Broker_Impl; | 41 class PPB_Broker_Impl; |
| 56 class PPB_TCPSocket_Private_Impl; | |
| 57 class RenderViewImpl; | 42 class RenderViewImpl; |
| 58 struct WebPluginInfo; | 43 struct WebPluginInfo; |
| 59 | 44 |
| 60 class PepperHelperImpl : public PepperHelper, | 45 class PepperHelperImpl : public PepperHelper, |
| 61 public base::SupportsWeakPtr<PepperHelperImpl>, | 46 public base::SupportsWeakPtr<PepperHelperImpl>, |
| 62 public RenderViewObserver { | 47 public RenderViewObserver { |
| 63 public: | 48 public: |
| 64 explicit PepperHelperImpl(RenderViewImpl* render_view); | 49 explicit PepperHelperImpl(RenderViewImpl* render_view); |
| 65 virtual ~PepperHelperImpl(); | 50 virtual ~PepperHelperImpl(); |
| 66 | 51 |
| 67 RenderViewImpl* render_view() { return render_view_; } | 52 RenderViewImpl* render_view() { return render_view_; } |
| 68 | 53 |
| 69 PepperBrowserConnection* pepper_browser_connection() { | |
| 70 return &pepper_browser_connection_; | |
| 71 } | |
| 72 | |
| 73 // A pointer is returned immediately, but it is not ready to be used until | 54 // A pointer is returned immediately, but it is not ready to be used until |
| 74 // BrokerConnected has been called. | 55 // BrokerConnected has been called. |
| 75 // The caller is responsible for calling Disconnect() on the returned pointer | 56 // The caller is responsible for calling Disconnect() on the returned pointer |
| 76 // to clean up the corresponding resources allocated during this call. | 57 // to clean up the corresponding resources allocated during this call. |
| 77 PepperBroker* ConnectToBroker(PPB_Broker_Impl* client); | 58 PepperBroker* ConnectToBroker(PPB_Broker_Impl* client); |
| 78 | 59 |
| 79 // Removes broker from pending_connect_broker_ if present. Returns true if so. | 60 // Removes broker from pending_connect_broker_ if present. Returns true if so. |
| 80 bool StopWaitingForBrokerConnection(PepperBroker* broker); | 61 bool StopWaitingForBrokerConnection(PepperBroker* broker); |
| 81 | 62 |
| 82 void RegisterTCPSocket(PPB_TCPSocket_Private_Impl* socket, uint32 socket_id); | |
| 83 void UnregisterTCPSocket(uint32 socket_id); | |
| 84 void TCPServerSocketStopListening(uint32 socket_id); | |
| 85 | |
| 86 // Notifies that |instance| has changed the cursor. | 63 // Notifies that |instance| has changed the cursor. |
| 87 // This will update the cursor appearance if it is currently over the plugin | 64 // This will update the cursor appearance if it is currently over the plugin |
| 88 // instance. | 65 // instance. |
| 89 void DidChangeCursor(PepperPluginInstanceImpl* instance, | 66 void DidChangeCursor(PepperPluginInstanceImpl* instance, |
| 90 const WebKit::WebCursorInfo& cursor); | 67 const WebKit::WebCursorInfo& cursor); |
| 91 | 68 |
| 92 // Notifies that |instance| has received a mouse event. | 69 // Notifies that |instance| has received a mouse event. |
| 93 void DidReceiveMouseEvent(PepperPluginInstanceImpl* instance); | 70 void DidReceiveMouseEvent(PepperPluginInstanceImpl* instance); |
| 94 | 71 |
| 95 // Notification that the given plugin is focused or unfocused. | 72 // Notification that the given plugin is focused or unfocused. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 108 void PluginSelectionChanged(PepperPluginInstanceImpl* instance); | 85 void PluginSelectionChanged(PepperPluginInstanceImpl* instance); |
| 109 | 86 |
| 110 // Indicates that the given instance has been created. | 87 // Indicates that the given instance has been created. |
| 111 void InstanceCreated(PepperPluginInstanceImpl* instance); | 88 void InstanceCreated(PepperPluginInstanceImpl* instance); |
| 112 | 89 |
| 113 // Indicates that the given instance is being destroyed. This is called from | 90 // Indicates that the given instance is being destroyed. This is called from |
| 114 // the destructor, so it's important that the instance is not dereferenced | 91 // the destructor, so it's important that the instance is not dereferenced |
| 115 // from this call. | 92 // from this call. |
| 116 void InstanceDeleted(PepperPluginInstanceImpl* instance); | 93 void InstanceDeleted(PepperPluginInstanceImpl* instance); |
| 117 | 94 |
| 118 // Sends an async IPC to open a local file. | |
| 119 typedef base::Callback<void (base::PlatformFileError, base::PassPlatformFile)> | |
| 120 AsyncOpenFileCallback; | |
| 121 bool AsyncOpenFile(const base::FilePath& path, | |
| 122 int flags, | |
| 123 const AsyncOpenFileCallback& callback); | |
| 124 | |
| 125 // Retrieve current gamepad data. | 95 // Retrieve current gamepad data. |
| 126 void SampleGamepads(WebKit::WebGamepads* data); | 96 void SampleGamepads(WebKit::WebGamepads* data); |
| 127 | 97 |
| 128 // Notifies the plugin of the document load. This should initiate the call to | 98 // Notifies the plugin of the document load. This should initiate the call to |
| 129 // PPP_Instance.HandleDocumentLoad. | 99 // PPP_Instance.HandleDocumentLoad. |
| 130 // | 100 // |
| 131 // The loader object should set itself on the PluginInstance as the document | 101 // The loader object should set itself on the PluginInstance as the document |
| 132 // loader using set_document_loader. | 102 // loader using set_document_loader. |
| 133 void HandleDocumentLoad(PepperPluginInstanceImpl* instance, | 103 void HandleDocumentLoad(PepperPluginInstanceImpl* instance, |
| 134 const WebKit::WebURLResponse& response); | 104 const WebKit::WebURLResponse& response); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 const std::vector<WebKit::WebCompositionUnderline>& underlines, | 141 const std::vector<WebKit::WebCompositionUnderline>& underlines, |
| 172 int selection_start, | 142 int selection_start, |
| 173 int selection_end) OVERRIDE; | 143 int selection_end) OVERRIDE; |
| 174 virtual void OnImeConfirmComposition(const string16& text) OVERRIDE; | 144 virtual void OnImeConfirmComposition(const string16& text) OVERRIDE; |
| 175 virtual void WillHandleMouseEvent() OVERRIDE; | 145 virtual void WillHandleMouseEvent() OVERRIDE; |
| 176 | 146 |
| 177 // RenderViewObserver implementation. | 147 // RenderViewObserver implementation. |
| 178 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 148 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 179 virtual void OnDestruct() OVERRIDE; | 149 virtual void OnDestruct() OVERRIDE; |
| 180 | 150 |
| 181 void OnTCPSocketConnectACK(uint32 plugin_dispatcher_id, | |
| 182 uint32 socket_id, | |
| 183 int32_t result, | |
| 184 const PP_NetAddress_Private& local_addr, | |
| 185 const PP_NetAddress_Private& remote_addr); | |
| 186 void OnTCPSocketSSLHandshakeACK( | |
| 187 uint32 plugin_dispatcher_id, | |
| 188 uint32 socket_id, | |
| 189 bool succeeded, | |
| 190 const ppapi::PPB_X509Certificate_Fields& certificate_fields); | |
| 191 void OnTCPSocketReadACK(uint32 plugin_dispatcher_id, | |
| 192 uint32 socket_id, | |
| 193 int32_t result, | |
| 194 const std::string& data); | |
| 195 void OnTCPSocketWriteACK(uint32 plugin_dispatcher_id, | |
| 196 uint32 socket_id, | |
| 197 int32_t result); | |
| 198 void OnTCPSocketSetOptionACK(uint32 plugin_dispatcher_id, | |
| 199 uint32 socket_id, | |
| 200 int32_t result); | |
| 201 void OnTCPServerSocketListenACK(uint32 plugin_dispatcher_id, | |
| 202 PP_Resource socket_resource, | |
| 203 uint32 socket_id, | |
| 204 const PP_NetAddress_Private& local_addr, | |
| 205 int32_t status); | |
| 206 void OnTCPServerSocketAcceptACK(uint32 plugin_dispatcher_id, | |
| 207 uint32 socket_id, | |
| 208 uint32 accepted_socket_id, | |
| 209 const PP_NetAddress_Private& local_addr, | |
| 210 const PP_NetAddress_Private& remote_addr); | |
| 211 void OnPpapiBrokerChannelCreated(int request_id, | 151 void OnPpapiBrokerChannelCreated(int request_id, |
| 212 base::ProcessId broker_pid, | 152 base::ProcessId broker_pid, |
| 213 const IPC::ChannelHandle& handle); | 153 const IPC::ChannelHandle& handle); |
| 214 void OnAsyncFileOpened(base::PlatformFileError error_code, | |
| 215 IPC::PlatformFileForTransit file_for_transit, | |
| 216 int message_id); | |
| 217 void OnPpapiBrokerPermissionResult(int request_id, bool result); | 154 void OnPpapiBrokerPermissionResult(int request_id, bool result); |
| 218 | 155 |
| 219 // Attempts to create a PPAPI plugin for the given filepath. On success, it | 156 // Attempts to create a PPAPI plugin for the given filepath. On success, it |
| 220 // will return the newly-created module. | 157 // will return the newly-created module. |
| 221 // | 158 // |
| 222 // There are two reasons for failure. The first is that the plugin isn't | 159 // There are two reasons for failure. The first is that the plugin isn't |
| 223 // a PPAPI plugin. In this case, |*pepper_plugin_was_registered| will be set | 160 // a PPAPI plugin. In this case, |*pepper_plugin_was_registered| will be set |
| 224 // to false and the caller may want to fall back on creating an NPAPI plugin. | 161 // to false and the caller may want to fall back on creating an NPAPI plugin. |
| 225 // the second is that the plugin failed to initialize. In this case, | 162 // the second is that the plugin failed to initialize. In this case, |
| 226 // |*pepper_plugin_was_registered| will be set to true and the caller should | 163 // |*pepper_plugin_was_registered| will be set to true and the caller should |
| (...skipping 12 matching lines...) Expand all Loading... |
| 239 const base::FilePath& path, | 176 const base::FilePath& path, |
| 240 ppapi::PpapiPermissions permissions, | 177 ppapi::PpapiPermissions permissions, |
| 241 const IPC::ChannelHandle& channel_handle, | 178 const IPC::ChannelHandle& channel_handle, |
| 242 base::ProcessId plugin_pid, | 179 base::ProcessId plugin_pid, |
| 243 int plugin_child_id, | 180 int plugin_child_id, |
| 244 bool is_external); | 181 bool is_external); |
| 245 | 182 |
| 246 // Pointer to the RenderView that owns us. | 183 // Pointer to the RenderView that owns us. |
| 247 RenderViewImpl* render_view_; | 184 RenderViewImpl* render_view_; |
| 248 | 185 |
| 249 // Connection for sending and receiving pepper host-related messages to/from | |
| 250 // the browser. | |
| 251 PepperBrowserConnection pepper_browser_connection_; | |
| 252 | |
| 253 std::set<PepperPluginInstanceImpl*> active_instances_; | 186 std::set<PepperPluginInstanceImpl*> active_instances_; |
| 254 | 187 |
| 255 IDMap<AsyncOpenFileCallback> pending_async_open_files_; | |
| 256 | |
| 257 IDMap<PPB_TCPSocket_Private_Impl> tcp_sockets_; | |
| 258 | |
| 259 IDMap<ppapi::PPB_TCPServerSocket_Shared> tcp_server_sockets_; | |
| 260 | |
| 261 typedef IDMap<scoped_refptr<PepperBroker>, IDMapOwnPointer> BrokerMap; | 188 typedef IDMap<scoped_refptr<PepperBroker>, IDMapOwnPointer> BrokerMap; |
| 262 BrokerMap pending_connect_broker_; | 189 BrokerMap pending_connect_broker_; |
| 263 | 190 |
| 264 typedef IDMap<base::WeakPtr<PPB_Broker_Impl> > PermissionRequestMap; | 191 typedef IDMap<base::WeakPtr<PPB_Broker_Impl> > PermissionRequestMap; |
| 265 PermissionRequestMap pending_permission_requests_; | 192 PermissionRequestMap pending_permission_requests_; |
| 266 | 193 |
| 267 // Whether or not the focus is on a PPAPI plugin | 194 // Whether or not the focus is on a PPAPI plugin |
| 268 PepperPluginInstanceImpl* focused_plugin_; | 195 PepperPluginInstanceImpl* focused_plugin_; |
| 269 | 196 |
| 270 // Current text input composition text. Empty if no composition is in | 197 // Current text input composition text. Empty if no composition is in |
| 271 // progress. | 198 // progress. |
| 272 string16 composition_text_; | 199 string16 composition_text_; |
| 273 | 200 |
| 274 // The plugin instance that received the last mouse event. It is set to NULL | 201 // The plugin instance that received the last mouse event. It is set to NULL |
| 275 // if the last mouse event went to elements other than Pepper plugins. | 202 // if the last mouse event went to elements other than Pepper plugins. |
| 276 // |last_mouse_event_target_| is not owned by this class. We can know about | 203 // |last_mouse_event_target_| is not owned by this class. We can know about |
| 277 // when it is destroyed via InstanceDeleted(). | 204 // when it is destroyed via InstanceDeleted(). |
| 278 PepperPluginInstanceImpl* last_mouse_event_target_; | 205 PepperPluginInstanceImpl* last_mouse_event_target_; |
| 279 | 206 |
| 280 scoped_ptr<GamepadSharedMemoryReader> gamepad_shared_memory_reader_; | 207 scoped_ptr<GamepadSharedMemoryReader> gamepad_shared_memory_reader_; |
| 281 | 208 |
| 282 scoped_refptr<ContextProviderCommandBuffer> offscreen_context3d_; | 209 scoped_refptr<ContextProviderCommandBuffer> offscreen_context3d_; |
| 283 | 210 |
| 284 DISALLOW_COPY_AND_ASSIGN(PepperHelperImpl); | 211 DISALLOW_COPY_AND_ASSIGN(PepperHelperImpl); |
| 285 }; | 212 }; |
| 286 | 213 |
| 287 } // namespace content | 214 } // namespace content |
| 288 | 215 |
| 289 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_DELEGATE_H_ | 216 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_DELEGATE_H_ |
| OLD | NEW |