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

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

Issue 8804006: Reland 8688002: PPB_TCPSocket_Private/PPB_UDPSocket_Private are exposed to Browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reorder memebers Created 9 years 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_PLUGIN_DELEGATE_IMPL_H_ 5 #ifndef CONTENT_RENDERER_PEPPER_PLUGIN_DELEGATE_IMPL_H_
6 #define CONTENT_RENDERER_PEPPER_PLUGIN_DELEGATE_IMPL_H_ 6 #define CONTENT_RENDERER_PEPPER_PLUGIN_DELEGATE_IMPL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map>
9 #include <set> 10 #include <set>
10 #include <map>
11 #include <string> 11 #include <string>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/id_map.h" 14 #include "base/id_map.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
18 #include "content/public/renderer/render_view_observer.h"
18 #include "content/renderer/pepper_parent_context_provider.h" 19 #include "content/renderer/pepper_parent_context_provider.h"
19 #include "ppapi/proxy/broker_dispatcher.h" 20 #include "ppapi/proxy/broker_dispatcher.h"
20 #include "ppapi/proxy/proxy_channel.h" 21 #include "ppapi/proxy/proxy_channel.h"
22 #include "ppapi/shared_impl/private/tcp_socket_private_impl.h"
23 #include "ppapi/shared_impl/private/udp_socket_private_impl.h"
21 #include "ui/base/ime/text_input_type.h" 24 #include "ui/base/ime/text_input_type.h"
22 #include "webkit/plugins/ppapi/plugin_delegate.h" 25 #include "webkit/plugins/ppapi/plugin_delegate.h"
23 #include "webkit/plugins/ppapi/ppb_broker_impl.h" 26 #include "webkit/plugins/ppapi/ppb_broker_impl.h"
24 #include "webkit/plugins/ppapi/ppb_flash_menu_impl.h" 27 #include "webkit/plugins/ppapi/ppb_flash_menu_impl.h"
25 28
26 class FilePath; 29 class FilePath;
27 class PepperPluginDelegateImpl; 30 class PepperPluginDelegateImpl;
28 class RenderViewImpl; 31 class RenderViewImpl;
29 32
30 namespace gfx { 33 namespace gfx {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 webkit::ppapi::PluginModule* plugin_module_; 117 webkit::ppapi::PluginModule* plugin_module_;
115 118
116 base::WeakPtr<PepperPluginDelegateImpl> delegate_; 119 base::WeakPtr<PepperPluginDelegateImpl> delegate_;
117 120
118 DISALLOW_COPY_AND_ASSIGN(PpapiBrokerImpl); 121 DISALLOW_COPY_AND_ASSIGN(PpapiBrokerImpl);
119 }; 122 };
120 123
121 class PepperPluginDelegateImpl 124 class PepperPluginDelegateImpl
122 : public webkit::ppapi::PluginDelegate, 125 : public webkit::ppapi::PluginDelegate,
123 public base::SupportsWeakPtr<PepperPluginDelegateImpl>, 126 public base::SupportsWeakPtr<PepperPluginDelegateImpl>,
124 public PepperParentContextProvider { 127 public PepperParentContextProvider,
128 public content::RenderViewObserver {
125 public: 129 public:
126 explicit PepperPluginDelegateImpl(RenderViewImpl* render_view); 130 explicit PepperPluginDelegateImpl(RenderViewImpl* render_view);
127 virtual ~PepperPluginDelegateImpl(); 131 virtual ~PepperPluginDelegateImpl();
128 132
129 // Attempts to create a PPAPI plugin for the given filepath. On success, it 133 // Attempts to create a PPAPI plugin for the given filepath. On success, it
130 // will return the newly-created module. 134 // will return the newly-created module.
131 // 135 //
132 // There are two reasons for failure. The first is that the plugin isn't 136 // There are two reasons for failure. The first is that the plugin isn't
133 // a PPAPI plugin. In this case, |*pepper_plugin_was_registered| will be set 137 // a PPAPI plugin. In this case, |*pepper_plugin_was_registered| will be set
134 // to false and the caller may want to fall back on creating an NPAPI plugin. 138 // to false and the caller may want to fall back on creating an NPAPI plugin.
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 uint16_t port) OVERRIDE; 307 uint16_t port) OVERRIDE;
304 virtual int32_t ConnectTcpAddress( 308 virtual int32_t ConnectTcpAddress(
305 webkit::ppapi::PPB_Flash_NetConnector_Impl* connector, 309 webkit::ppapi::PPB_Flash_NetConnector_Impl* connector,
306 const struct PP_NetAddress_Private* addr) OVERRIDE; 310 const struct PP_NetAddress_Private* addr) OVERRIDE;
307 // This is the completion for both |ConnectTcp()| and |ConnectTcpAddress()|. 311 // This is the completion for both |ConnectTcp()| and |ConnectTcpAddress()|.
308 void OnConnectTcpACK( 312 void OnConnectTcpACK(
309 int request_id, 313 int request_id,
310 base::PlatformFile socket, 314 base::PlatformFile socket,
311 const PP_NetAddress_Private& local_addr, 315 const PP_NetAddress_Private& local_addr,
312 const PP_NetAddress_Private& remote_addr); 316 const PP_NetAddress_Private& remote_addr);
317
318 virtual uint32 TCPSocketCreate() OVERRIDE;
319 virtual void TCPSocketConnect(
320 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket,
321 uint32 socket_id,
322 const std::string& host,
323 uint16_t port) OVERRIDE;
324 virtual void TCPSocketConnectWithNetAddress(
325 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket,
326 uint32 socket_id,
327 const PP_NetAddress_Private& addr) OVERRIDE;
328 virtual void TCPSocketSSLHandshake(uint32 socket_id,
329 const std::string& server_name,
330 uint16_t server_port) OVERRIDE;
331 virtual void TCPSocketRead(uint32 socket_id, int32_t bytes_to_read) OVERRIDE;
332 virtual void TCPSocketWrite(uint32 socket_id,
333 const std::string& buffer) OVERRIDE;
334 virtual void TCPSocketDisconnect(uint32 socket_id) OVERRIDE;
335
336 virtual uint32 UDPSocketCreate() OVERRIDE;
337 virtual void UDPSocketBind(
338 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket,
339 uint32 socket_id,
340 const PP_NetAddress_Private& addr) OVERRIDE;
341 virtual void UDPSocketRecvFrom(uint32 socket_id,
342 int32_t num_bytes) OVERRIDE;
343 virtual void UDPSocketSendTo(uint32 socket_id,
344 const std::string& buffer,
345 const PP_NetAddress_Private& addr) OVERRIDE;
346 virtual void UDPSocketClose(uint32 socket_id) OVERRIDE;
347
313 virtual int32_t ShowContextMenu( 348 virtual int32_t ShowContextMenu(
314 webkit::ppapi::PluginInstance* instance, 349 webkit::ppapi::PluginInstance* instance,
315 webkit::ppapi::PPB_Flash_Menu_Impl* menu, 350 webkit::ppapi::PPB_Flash_Menu_Impl* menu,
316 const gfx::Point& position) OVERRIDE; 351 const gfx::Point& position) OVERRIDE;
317 void OnContextMenuClosed( 352 void OnContextMenuClosed(
318 const webkit_glue::CustomContextMenuContext& custom_context); 353 const webkit_glue::CustomContextMenuContext& custom_context);
319 void OnCustomContextMenuAction( 354 void OnCustomContextMenuAction(
320 const webkit_glue::CustomContextMenuContext& custom_context, 355 const webkit_glue::CustomContextMenuContext& custom_context,
321 unsigned action); 356 unsigned action);
322 void CompleteShowContextMenu(int request_id, 357 void CompleteShowContextMenu(int request_id,
(...skipping 18 matching lines...) Expand all
341 OVERRIDE; 376 OVERRIDE;
342 virtual ::ppapi::Preferences GetPreferences() OVERRIDE; 377 virtual ::ppapi::Preferences GetPreferences() OVERRIDE;
343 virtual void LockMouse(webkit::ppapi::PluginInstance* instance) OVERRIDE; 378 virtual void LockMouse(webkit::ppapi::PluginInstance* instance) OVERRIDE;
344 virtual void UnlockMouse(webkit::ppapi::PluginInstance* instance) OVERRIDE; 379 virtual void UnlockMouse(webkit::ppapi::PluginInstance* instance) OVERRIDE;
345 virtual void DidChangeCursor(webkit::ppapi::PluginInstance* instance, 380 virtual void DidChangeCursor(webkit::ppapi::PluginInstance* instance,
346 const WebKit::WebCursorInfo& cursor) OVERRIDE; 381 const WebKit::WebCursorInfo& cursor) OVERRIDE;
347 virtual void DidReceiveMouseEvent( 382 virtual void DidReceiveMouseEvent(
348 webkit::ppapi::PluginInstance* instance) OVERRIDE; 383 webkit::ppapi::PluginInstance* instance) OVERRIDE;
349 virtual bool IsInFullscreenMode() OVERRIDE; 384 virtual bool IsInFullscreenMode() OVERRIDE;
350 385
386 // RenderViewObserver implementation.
387 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
388
389 void OnTCPSocketConnectACK(uint32 plugin_dispatcher_id,
390 uint32 socket_id,
391 bool succeeded,
392 const PP_NetAddress_Private& local_addr,
393 const PP_NetAddress_Private& remote_addr);
394 void OnTCPSocketSSLHandshakeACK(uint32 plugin_dispatcher_id,
395 uint32 socket_id,
396 bool succeeded);
397 void OnTCPSocketReadACK(uint32 plugin_dispatcher_id,
398 uint32 socket_id,
399 bool succeeded,
400 const std::string& data);
401 void OnTCPSocketWriteACK(uint32 plugin_dispatcher_id,
402 uint32 socket_id,
403 bool succeeded,
404 int32_t bytes_written);
405 void OnUDPSocketBindACK(uint32 plugin_dispatcher_id,
406 uint32 socket_id,
407 bool succeeded);
408 void OnUDPSocketSendToACK(uint32 plugin_dispatcher_id,
409 uint32 socket_id,
410 bool succeeded,
411 int32_t bytes_written);
412 void OnUDPSocketRecvFromACK(uint32 plugin_dispatcher_id,
413 uint32 socket_id,
414 bool succeeded,
415 const std::string& data,
416 const PP_NetAddress_Private& addr);
417
351 CONTENT_EXPORT int GetRoutingId() const; 418 CONTENT_EXPORT int GetRoutingId() const;
352 419
353 private: 420 private:
354 // Asynchronously attempts to create a PPAPI broker for the given plugin. 421 // Asynchronously attempts to create a PPAPI broker for the given plugin.
355 scoped_refptr<PpapiBrokerImpl> CreatePpapiBroker( 422 scoped_refptr<PpapiBrokerImpl> CreatePpapiBroker(
356 webkit::ppapi::PluginModule* plugin_module); 423 webkit::ppapi::PluginModule* plugin_module);
357 424
358 bool MouseLockedOrPending() const { 425 bool MouseLockedOrPending() const {
359 return mouse_locked_ || pending_lock_request_ || pending_unlock_request_; 426 return mouse_locked_ || pending_lock_request_ || pending_unlock_request_;
360 } 427 }
361 428
362 // Implementation of PepperParentContextProvider. 429 // Implementation of PepperParentContextProvider.
363 virtual RendererGLContext* GetParentContextForPlatformContext3D() OVERRIDE; 430 virtual RendererGLContext* GetParentContextForPlatformContext3D() OVERRIDE;
364 431
432 // Helper function to check that TCP/UDP private APIs are allowed for current
433 // page. This check actually allows socket usage for NativeClient code only.
434 // It is better to move this check to browser process but Pepper message
435 // filters in browser process have no context about page that sent
436 // the request. Doing this check in render process is safe because NaCl code
437 // is executed in separate NaCl process.
438 bool CanUseSocketAPIs();
439
365 // Pointer to the RenderView that owns us. 440 // Pointer to the RenderView that owns us.
366 RenderViewImpl* render_view_; 441 RenderViewImpl* render_view_;
367 442
368 std::set<webkit::ppapi::PluginInstance*> active_instances_; 443 std::set<webkit::ppapi::PluginInstance*> active_instances_;
369 444
370 // Used to send a single context menu "completion" upon menu close. 445 // Used to send a single context menu "completion" upon menu close.
371 bool has_saved_context_menu_action_; 446 bool has_saved_context_menu_action_;
372 unsigned saved_context_menu_action_; 447 unsigned saved_context_menu_action_;
373 448
374 IDMap<AsyncOpenFileCallback> pending_async_open_files_; 449 IDMap<AsyncOpenFileCallback> pending_async_open_files_;
375 450
376 IDMap<scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl>, 451 IDMap<scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl>,
377 IDMapOwnPointer> pending_connect_tcps_; 452 IDMapOwnPointer> pending_connect_tcps_;
378 453
454 IDMap<webkit::ppapi::PPB_TCPSocket_Private_Impl> tcp_sockets_;
455
456 IDMap<webkit::ppapi::PPB_UDPSocket_Private_Impl> udp_sockets_;
457
379 IDMap<scoped_refptr<webkit::ppapi::PPB_Flash_Menu_Impl>, 458 IDMap<scoped_refptr<webkit::ppapi::PPB_Flash_Menu_Impl>,
380 IDMapOwnPointer> pending_context_menus_; 459 IDMapOwnPointer> pending_context_menus_;
381 460
382 typedef IDMap<scoped_refptr<PpapiBrokerImpl>, IDMapOwnPointer> BrokerMap; 461 typedef IDMap<scoped_refptr<PpapiBrokerImpl>, IDMapOwnPointer> BrokerMap;
383 BrokerMap pending_connect_broker_; 462 BrokerMap pending_connect_broker_;
384 463
385 // Whether or not the focus is on a PPAPI plugin 464 // Whether or not the focus is on a PPAPI plugin
386 webkit::ppapi::PluginInstance* focused_plugin_; 465 webkit::ppapi::PluginInstance* focused_plugin_;
387 466
388 // Current text input composition text. Empty if no composition is in 467 // Current text input composition text. Empty if no composition is in
(...skipping 18 matching lines...) Expand all
407 // The plugin instance that received the last mouse event. It is set to NULL 486 // The plugin instance that received the last mouse event. It is set to NULL
408 // if the last mouse event went to elements other than Pepper plugins. 487 // if the last mouse event went to elements other than Pepper plugins.
409 // |last_mouse_event_target_| is not owned by this class. We can know about 488 // |last_mouse_event_target_| is not owned by this class. We can know about
410 // when it is destroyed via InstanceDeleted(). 489 // when it is destroyed via InstanceDeleted().
411 webkit::ppapi::PluginInstance* last_mouse_event_target_; 490 webkit::ppapi::PluginInstance* last_mouse_event_target_;
412 491
413 DISALLOW_COPY_AND_ASSIGN(PepperPluginDelegateImpl); 492 DISALLOW_COPY_AND_ASSIGN(PepperPluginDelegateImpl);
414 }; 493 };
415 494
416 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_DELEGATE_IMPL_H_ 495 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_DELEGATE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698