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

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: fix destruction issue 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 virtual void OnDestruct() OVERRIDE;
389
390 void OnTCPSocketConnectACK(uint32 plugin_dispatcher_id,
391 uint32 socket_id,
392 bool succeeded,
393 const PP_NetAddress_Private& local_addr,
394 const PP_NetAddress_Private& remote_addr);
395 void OnTCPSocketSSLHandshakeACK(uint32 plugin_dispatcher_id,
396 uint32 socket_id,
397 bool succeeded);
398 void OnTCPSocketReadACK(uint32 plugin_dispatcher_id,
399 uint32 socket_id,
400 bool succeeded,
401 const std::string& data);
402 void OnTCPSocketWriteACK(uint32 plugin_dispatcher_id,
403 uint32 socket_id,
404 bool succeeded,
405 int32_t bytes_written);
406 void OnUDPSocketBindACK(uint32 plugin_dispatcher_id,
407 uint32 socket_id,
408 bool succeeded);
409 void OnUDPSocketSendToACK(uint32 plugin_dispatcher_id,
410 uint32 socket_id,
411 bool succeeded,
412 int32_t bytes_written);
413 void OnUDPSocketRecvFromACK(uint32 plugin_dispatcher_id,
414 uint32 socket_id,
415 bool succeeded,
416 const std::string& data,
417 const PP_NetAddress_Private& addr);
418
351 CONTENT_EXPORT int GetRoutingId() const; 419 CONTENT_EXPORT int GetRoutingId() const;
352 420
353 private: 421 private:
354 // Asynchronously attempts to create a PPAPI broker for the given plugin. 422 // Asynchronously attempts to create a PPAPI broker for the given plugin.
355 scoped_refptr<PpapiBrokerImpl> CreatePpapiBroker( 423 scoped_refptr<PpapiBrokerImpl> CreatePpapiBroker(
356 webkit::ppapi::PluginModule* plugin_module); 424 webkit::ppapi::PluginModule* plugin_module);
357 425
358 bool MouseLockedOrPending() const { 426 bool MouseLockedOrPending() const {
359 return mouse_locked_ || pending_lock_request_ || pending_unlock_request_; 427 return mouse_locked_ || pending_lock_request_ || pending_unlock_request_;
360 } 428 }
361 429
362 // Implementation of PepperParentContextProvider. 430 // Implementation of PepperParentContextProvider.
363 virtual RendererGLContext* GetParentContextForPlatformContext3D() OVERRIDE; 431 virtual RendererGLContext* GetParentContextForPlatformContext3D() OVERRIDE;
364 432
433 // Helper function to check that TCP/UDP private APIs are allowed for current
434 // page. This check actually allows socket usage for NativeClient code only.
435 // It is better to move this check to browser process but Pepper message
436 // filters in browser process have no context about page that sent
437 // the request. Doing this check in render process is safe because NaCl code
438 // is executed in separate NaCl process.
439 // TODO(dpolukhin, yzshen): make the check consistent for in- and out-process
440 // cases and do the check during socket creation in the browser process.
441 bool CanUseSocketAPIs();
442
365 // Pointer to the RenderView that owns us. 443 // Pointer to the RenderView that owns us.
366 RenderViewImpl* render_view_; 444 RenderViewImpl* render_view_;
367 445
368 std::set<webkit::ppapi::PluginInstance*> active_instances_; 446 std::set<webkit::ppapi::PluginInstance*> active_instances_;
369 447
370 // Used to send a single context menu "completion" upon menu close. 448 // Used to send a single context menu "completion" upon menu close.
371 bool has_saved_context_menu_action_; 449 bool has_saved_context_menu_action_;
372 unsigned saved_context_menu_action_; 450 unsigned saved_context_menu_action_;
373 451
374 IDMap<AsyncOpenFileCallback> pending_async_open_files_; 452 IDMap<AsyncOpenFileCallback> pending_async_open_files_;
375 453
376 IDMap<scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl>, 454 IDMap<scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl>,
377 IDMapOwnPointer> pending_connect_tcps_; 455 IDMapOwnPointer> pending_connect_tcps_;
378 456
457 IDMap<webkit::ppapi::PPB_TCPSocket_Private_Impl> tcp_sockets_;
458
459 IDMap<webkit::ppapi::PPB_UDPSocket_Private_Impl> udp_sockets_;
460
379 IDMap<scoped_refptr<webkit::ppapi::PPB_Flash_Menu_Impl>, 461 IDMap<scoped_refptr<webkit::ppapi::PPB_Flash_Menu_Impl>,
380 IDMapOwnPointer> pending_context_menus_; 462 IDMapOwnPointer> pending_context_menus_;
381 463
382 typedef IDMap<scoped_refptr<PpapiBrokerImpl>, IDMapOwnPointer> BrokerMap; 464 typedef IDMap<scoped_refptr<PpapiBrokerImpl>, IDMapOwnPointer> BrokerMap;
383 BrokerMap pending_connect_broker_; 465 BrokerMap pending_connect_broker_;
384 466
385 // Whether or not the focus is on a PPAPI plugin 467 // Whether or not the focus is on a PPAPI plugin
386 webkit::ppapi::PluginInstance* focused_plugin_; 468 webkit::ppapi::PluginInstance* focused_plugin_;
387 469
388 // Current text input composition text. Empty if no composition is in 470 // 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 489 // 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. 490 // 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 491 // |last_mouse_event_target_| is not owned by this class. We can know about
410 // when it is destroyed via InstanceDeleted(). 492 // when it is destroyed via InstanceDeleted().
411 webkit::ppapi::PluginInstance* last_mouse_event_target_; 493 webkit::ppapi::PluginInstance* last_mouse_event_target_;
412 494
413 DISALLOW_COPY_AND_ASSIGN(PepperPluginDelegateImpl); 495 DISALLOW_COPY_AND_ASSIGN(PepperPluginDelegateImpl);
414 }; 496 };
415 497
416 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_DELEGATE_IMPL_H_ 498 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_DELEGATE_IMPL_H_
OLDNEW
« no previous file with comments | « content/renderer/mock_content_renderer_client.cc ('k') | content/renderer/pepper_plugin_delegate_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698