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_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 <map> |
10 #include <set> | 10 #include <set> |
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/public/renderer/render_view_observer.h" |
| 19 #include "content/renderer/mouse_lock_dispatcher.h" |
19 #include "content/renderer/pepper_parent_context_provider.h" | 20 #include "content/renderer/pepper_parent_context_provider.h" |
20 #include "ppapi/proxy/broker_dispatcher.h" | 21 #include "ppapi/proxy/broker_dispatcher.h" |
21 #include "ppapi/proxy/proxy_channel.h" | 22 #include "ppapi/proxy/proxy_channel.h" |
22 #include "ppapi/shared_impl/private/tcp_socket_private_impl.h" | 23 #include "ppapi/shared_impl/private/tcp_socket_private_impl.h" |
23 #include "ppapi/shared_impl/private/udp_socket_private_impl.h" | 24 #include "ppapi/shared_impl/private/udp_socket_private_impl.h" |
24 #include "ui/base/ime/text_input_type.h" | 25 #include "ui/base/ime/text_input_type.h" |
25 #include "webkit/plugins/ppapi/plugin_delegate.h" | 26 #include "webkit/plugins/ppapi/plugin_delegate.h" |
26 #include "webkit/plugins/ppapi/ppb_broker_impl.h" | 27 #include "webkit/plugins/ppapi/ppb_broker_impl.h" |
27 #include "webkit/plugins/ppapi/ppb_flash_menu_impl.h" | 28 #include "webkit/plugins/ppapi/ppb_flash_menu_impl.h" |
28 | 29 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 bool CanComposeInline() const; | 191 bool CanComposeInline() const; |
191 | 192 |
192 // IME events. | 193 // IME events. |
193 void OnImeSetComposition( | 194 void OnImeSetComposition( |
194 const string16& text, | 195 const string16& text, |
195 const std::vector<WebKit::WebCompositionUnderline>& underlines, | 196 const std::vector<WebKit::WebCompositionUnderline>& underlines, |
196 int selection_start, | 197 int selection_start, |
197 int selection_end); | 198 int selection_end); |
198 void OnImeConfirmComposition(const string16& text); | 199 void OnImeConfirmComposition(const string16& text); |
199 | 200 |
200 // Notification that the request to lock the mouse has completed. | |
201 void OnLockMouseACK(bool succeeded); | |
202 // Notification that the plugin instance has lost the mouse lock. | |
203 void OnMouseLockLost(); | |
204 // Notification that a mouse event has arrived at the render view. | 201 // Notification that a mouse event has arrived at the render view. |
205 // Returns true if no further handling is needed. For example, if the mouse is | 202 void WillHandleMouseEvent(); |
206 // currently locked, this method directly dispatches the event to the owner of | |
207 // the mouse lock and returns true. | |
208 bool HandleMouseEvent(const WebKit::WebMouseEvent& event); | |
209 | 203 |
210 // PluginDelegate implementation. | 204 // PluginDelegate implementation. |
211 virtual void PluginFocusChanged(webkit::ppapi::PluginInstance* instance, | 205 virtual void PluginFocusChanged(webkit::ppapi::PluginInstance* instance, |
212 bool focused) OVERRIDE; | 206 bool focused) OVERRIDE; |
213 virtual void PluginTextInputTypeChanged( | 207 virtual void PluginTextInputTypeChanged( |
214 webkit::ppapi::PluginInstance* instance) OVERRIDE; | 208 webkit::ppapi::PluginInstance* instance) OVERRIDE; |
215 virtual void PluginCaretPositionChanged( | 209 virtual void PluginCaretPositionChanged( |
216 webkit::ppapi::PluginInstance* instance) OVERRIDE; | 210 webkit::ppapi::PluginInstance* instance) OVERRIDE; |
217 virtual void PluginRequestedCancelComposition( | 211 virtual void PluginRequestedCancelComposition( |
218 webkit::ppapi::PluginInstance* instance) OVERRIDE; | 212 webkit::ppapi::PluginInstance* instance) OVERRIDE; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 virtual void DidStartLoading() OVERRIDE; | 370 virtual void DidStartLoading() OVERRIDE; |
377 virtual void DidStopLoading() OVERRIDE; | 371 virtual void DidStopLoading() OVERRIDE; |
378 virtual void SetContentRestriction(int restrictions) OVERRIDE; | 372 virtual void SetContentRestriction(int restrictions) OVERRIDE; |
379 virtual void SaveURLAs(const GURL& url) OVERRIDE; | 373 virtual void SaveURLAs(const GURL& url) OVERRIDE; |
380 virtual webkit_glue::P2PTransport* CreateP2PTransport() OVERRIDE; | 374 virtual webkit_glue::P2PTransport* CreateP2PTransport() OVERRIDE; |
381 virtual double GetLocalTimeZoneOffset(base::Time t) OVERRIDE; | 375 virtual double GetLocalTimeZoneOffset(base::Time t) OVERRIDE; |
382 virtual std::string GetFlashCommandLineArgs() OVERRIDE; | 376 virtual std::string GetFlashCommandLineArgs() OVERRIDE; |
383 virtual base::SharedMemory* CreateAnonymousSharedMemory(uint32_t size) | 377 virtual base::SharedMemory* CreateAnonymousSharedMemory(uint32_t size) |
384 OVERRIDE; | 378 OVERRIDE; |
385 virtual ::ppapi::Preferences GetPreferences() OVERRIDE; | 379 virtual ::ppapi::Preferences GetPreferences() OVERRIDE; |
386 virtual void LockMouse(webkit::ppapi::PluginInstance* instance) OVERRIDE; | 380 virtual bool LockMouse(webkit::ppapi::PluginInstance* instance) OVERRIDE; |
387 virtual void UnlockMouse(webkit::ppapi::PluginInstance* instance) OVERRIDE; | 381 virtual void UnlockMouse(webkit::ppapi::PluginInstance* instance) OVERRIDE; |
| 382 virtual bool IsMouseLocked(webkit::ppapi::PluginInstance* instance) OVERRIDE; |
388 virtual void DidChangeCursor(webkit::ppapi::PluginInstance* instance, | 383 virtual void DidChangeCursor(webkit::ppapi::PluginInstance* instance, |
389 const WebKit::WebCursorInfo& cursor) OVERRIDE; | 384 const WebKit::WebCursorInfo& cursor) OVERRIDE; |
390 virtual void DidReceiveMouseEvent( | 385 virtual void DidReceiveMouseEvent( |
391 webkit::ppapi::PluginInstance* instance) OVERRIDE; | 386 webkit::ppapi::PluginInstance* instance) OVERRIDE; |
392 virtual bool IsInFullscreenMode() OVERRIDE; | 387 virtual bool IsInFullscreenMode() OVERRIDE; |
393 virtual void SampleGamepads(WebKit::WebGamepads* data) OVERRIDE; | 388 virtual void SampleGamepads(WebKit::WebGamepads* data) OVERRIDE; |
394 virtual bool IsPageVisible() const OVERRIDE; | 389 virtual bool IsPageVisible() const OVERRIDE; |
395 | 390 |
396 // RenderViewObserver implementation. | 391 // RenderViewObserver implementation. |
397 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 392 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
(...skipping 28 matching lines...) Expand all Loading... |
426 const std::string& data, | 421 const std::string& data, |
427 const PP_NetAddress_Private& addr); | 422 const PP_NetAddress_Private& addr); |
428 | 423 |
429 CONTENT_EXPORT int GetRoutingId() const; | 424 CONTENT_EXPORT int GetRoutingId() const; |
430 | 425 |
431 private: | 426 private: |
432 // Asynchronously attempts to create a PPAPI broker for the given plugin. | 427 // Asynchronously attempts to create a PPAPI broker for the given plugin. |
433 scoped_refptr<PpapiBrokerImpl> CreatePpapiBroker( | 428 scoped_refptr<PpapiBrokerImpl> CreatePpapiBroker( |
434 webkit::ppapi::PluginModule* plugin_module); | 429 webkit::ppapi::PluginModule* plugin_module); |
435 | 430 |
436 bool MouseLockedOrPending() const { | |
437 return mouse_locked_ || pending_lock_request_ || pending_unlock_request_; | |
438 } | |
439 | |
440 // Implementation of PepperParentContextProvider. | 431 // Implementation of PepperParentContextProvider. |
441 virtual RendererGLContext* GetParentContextForPlatformContext3D() OVERRIDE; | 432 virtual RendererGLContext* GetParentContextForPlatformContext3D() OVERRIDE; |
442 | 433 |
443 // Helper function to check that TCP/UDP private APIs are allowed for current | 434 // Helper function to check that TCP/UDP private APIs are allowed for current |
444 // page. This check actually allows socket usage for NativeClient code only. | 435 // page. This check actually allows socket usage for NativeClient code only. |
445 // It is better to move this check to browser process but Pepper message | 436 // It is better to move this check to browser process but Pepper message |
446 // filters in browser process have no context about page that sent | 437 // filters in browser process have no context about page that sent |
447 // the request. Doing this check in render process is safe because NaCl code | 438 // the request. Doing this check in render process is safe because NaCl code |
448 // is executed in separate NaCl process. | 439 // is executed in separate NaCl process. |
449 // TODO(dpolukhin, yzshen): make the check consistent for in- and out-process | 440 // TODO(dpolukhin, yzshen): make the check consistent for in- and out-process |
450 // cases and do the check during socket creation in the browser process. | 441 // cases and do the check during socket creation in the browser process. |
451 bool CanUseSocketAPIs(); | 442 bool CanUseSocketAPIs(); |
452 | 443 |
| 444 MouseLockDispatcher::LockTarget* GetOrCreateLockTargetAdapter( |
| 445 webkit::ppapi::PluginInstance* instance); |
| 446 void UnSetAndDeleteLockTargetAdapter(webkit::ppapi::PluginInstance* instance); |
| 447 |
453 // Pointer to the RenderView that owns us. | 448 // Pointer to the RenderView that owns us. |
454 RenderViewImpl* render_view_; | 449 RenderViewImpl* render_view_; |
455 | 450 |
456 std::set<webkit::ppapi::PluginInstance*> active_instances_; | 451 std::set<webkit::ppapi::PluginInstance*> active_instances_; |
| 452 typedef std::map<webkit::ppapi::PluginInstance*, |
| 453 MouseLockDispatcher::LockTarget*> LockTargetMap; |
| 454 LockTargetMap mouse_lock_instances_; |
457 | 455 |
458 // Used to send a single context menu "completion" upon menu close. | 456 // Used to send a single context menu "completion" upon menu close. |
459 bool has_saved_context_menu_action_; | 457 bool has_saved_context_menu_action_; |
460 unsigned saved_context_menu_action_; | 458 unsigned saved_context_menu_action_; |
461 | 459 |
462 IDMap<AsyncOpenFileCallback> pending_async_open_files_; | 460 IDMap<AsyncOpenFileCallback> pending_async_open_files_; |
463 | 461 |
464 IDMap<scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl>, | 462 IDMap<scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl>, |
465 IDMapOwnPointer> pending_connect_tcps_; | 463 IDMapOwnPointer> pending_connect_tcps_; |
466 | 464 |
467 IDMap<webkit::ppapi::PPB_TCPSocket_Private_Impl> tcp_sockets_; | 465 IDMap<webkit::ppapi::PPB_TCPSocket_Private_Impl> tcp_sockets_; |
468 | 466 |
469 IDMap<webkit::ppapi::PPB_UDPSocket_Private_Impl> udp_sockets_; | 467 IDMap<webkit::ppapi::PPB_UDPSocket_Private_Impl> udp_sockets_; |
470 | 468 |
471 IDMap<scoped_refptr<webkit::ppapi::PPB_Flash_Menu_Impl>, | 469 IDMap<scoped_refptr<webkit::ppapi::PPB_Flash_Menu_Impl>, |
472 IDMapOwnPointer> pending_context_menus_; | 470 IDMapOwnPointer> pending_context_menus_; |
473 | 471 |
474 typedef IDMap<scoped_refptr<PpapiBrokerImpl>, IDMapOwnPointer> BrokerMap; | 472 typedef IDMap<scoped_refptr<PpapiBrokerImpl>, IDMapOwnPointer> BrokerMap; |
475 BrokerMap pending_connect_broker_; | 473 BrokerMap pending_connect_broker_; |
476 | 474 |
477 // Whether or not the focus is on a PPAPI plugin | 475 // Whether or not the focus is on a PPAPI plugin |
478 webkit::ppapi::PluginInstance* focused_plugin_; | 476 webkit::ppapi::PluginInstance* focused_plugin_; |
479 | 477 |
480 // Current text input composition text. Empty if no composition is in | 478 // Current text input composition text. Empty if no composition is in |
481 // progress. | 479 // progress. |
482 string16 composition_text_; | 480 string16 composition_text_; |
483 | 481 |
484 // |mouse_lock_owner_| is not owned by this class. We can know about when it | |
485 // is destroyed via InstanceDeleted(). | |
486 // |mouse_lock_owner_| being non-NULL doesn't indicate that currently the | |
487 // mouse has been locked. It is possible that a request to lock the mouse has | |
488 // been sent, but the response hasn't arrived yet. | |
489 webkit::ppapi::PluginInstance* mouse_lock_owner_; | |
490 bool mouse_locked_; | |
491 // If both |pending_lock_request_| and |pending_unlock_request_| are true, | |
492 // it means a lock request was sent before an unlock request and we haven't | |
493 // received responses for them. | |
494 // The logic in LockMouse() makes sure that a lock request won't be sent when | |
495 // there is a pending unlock request. | |
496 bool pending_lock_request_; | |
497 bool pending_unlock_request_; | |
498 | |
499 // The plugin instance that received the last mouse event. It is set to NULL | 482 // The plugin instance that received the last mouse event. It is set to NULL |
500 // if the last mouse event went to elements other than Pepper plugins. | 483 // if the last mouse event went to elements other than Pepper plugins. |
501 // |last_mouse_event_target_| is not owned by this class. We can know about | 484 // |last_mouse_event_target_| is not owned by this class. We can know about |
502 // when it is destroyed via InstanceDeleted(). | 485 // when it is destroyed via InstanceDeleted(). |
503 webkit::ppapi::PluginInstance* last_mouse_event_target_; | 486 webkit::ppapi::PluginInstance* last_mouse_event_target_; |
504 | 487 |
505 scoped_ptr<content::GamepadSharedMemoryReader> gamepad_shared_memory_reader_; | 488 scoped_ptr<content::GamepadSharedMemoryReader> gamepad_shared_memory_reader_; |
506 | 489 |
507 DISALLOW_COPY_AND_ASSIGN(PepperPluginDelegateImpl); | 490 DISALLOW_COPY_AND_ASSIGN(PepperPluginDelegateImpl); |
508 }; | 491 }; |
509 | 492 |
510 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_DELEGATE_IMPL_H_ | 493 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_DELEGATE_IMPL_H_ |
OLD | NEW |