| 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 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h" | 5 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <cstddef> | 8 #include <cstddef> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <queue> | 10 #include <queue> |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 int message_id) { | 567 int message_id) { |
| 568 AsyncOpenFileCallback* callback = | 568 AsyncOpenFileCallback* callback = |
| 569 pending_async_open_files_.Lookup(message_id); | 569 pending_async_open_files_.Lookup(message_id); |
| 570 DCHECK(callback); | 570 DCHECK(callback); |
| 571 pending_async_open_files_.Remove(message_id); | 571 pending_async_open_files_.Remove(message_id); |
| 572 | 572 |
| 573 base::PlatformFile file = | 573 base::PlatformFile file = |
| 574 IPC::PlatformFileForTransitToPlatformFile(file_for_transit); | 574 IPC::PlatformFileForTransitToPlatformFile(file_for_transit); |
| 575 callback->Run(error_code, base::PassPlatformFile(&file)); | 575 callback->Run(error_code, base::PassPlatformFile(&file)); |
| 576 // Make sure we won't leak file handle if the requester has died. | 576 // Make sure we won't leak file handle if the requester has died. |
| 577 if (file != base::kInvalidPlatformFileValue) | 577 if (file != base::kInvalidPlatformFileValue) { |
| 578 base::FileUtilProxy::Close(GetFileThreadMessageLoopProxy().get(), | 578 base::FileUtilProxy::Close( |
| 579 file, | 579 RenderThreadImpl::current()->GetFileThreadMessageLoopProxy().get(), |
| 580 base::FileUtilProxy::StatusCallback()); | 580 file, |
| 581 base::FileUtilProxy::StatusCallback()); |
| 582 } |
| 581 delete callback; | 583 delete callback; |
| 582 } | 584 } |
| 583 | 585 |
| 584 void PepperPluginDelegateImpl::OnSetFocus(bool has_focus) { | 586 void PepperPluginDelegateImpl::OnSetFocus(bool has_focus) { |
| 585 for (std::set<PepperPluginInstanceImpl*>::iterator i = | 587 for (std::set<PepperPluginInstanceImpl*>::iterator i = |
| 586 active_instances_.begin(); | 588 active_instances_.begin(); |
| 587 i != active_instances_.end(); ++i) | 589 i != active_instances_.end(); ++i) |
| 588 (*i)->SetContentAreaFocus(has_focus); | 590 (*i)->SetContentAreaFocus(has_focus); |
| 589 } | 591 } |
| 590 | 592 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 603 // This method is called for every mouse event that the render view receives. | 605 // This method is called for every mouse event that the render view receives. |
| 604 // And then the mouse event is forwarded to WebKit, which dispatches it to the | 606 // And then the mouse event is forwarded to WebKit, which dispatches it to the |
| 605 // event target. Potentially a Pepper plugin will receive the event. | 607 // event target. Potentially a Pepper plugin will receive the event. |
| 606 // In order to tell whether a plugin gets the last mouse event and which it | 608 // In order to tell whether a plugin gets the last mouse event and which it |
| 607 // is, we set |last_mouse_event_target_| to NULL here. If a plugin gets the | 609 // is, we set |last_mouse_event_target_| to NULL here. If a plugin gets the |
| 608 // event, it will notify us via DidReceiveMouseEvent() and set itself as | 610 // event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 609 // |last_mouse_event_target_|. | 611 // |last_mouse_event_target_|. |
| 610 last_mouse_event_target_ = NULL; | 612 last_mouse_event_target_ = NULL; |
| 611 } | 613 } |
| 612 | 614 |
| 613 scoped_refptr<base::MessageLoopProxy> | |
| 614 PepperPluginDelegateImpl::GetFileThreadMessageLoopProxy() { | |
| 615 return RenderThreadImpl::current()->GetFileThreadMessageLoopProxy(); | |
| 616 } | |
| 617 | |
| 618 void PepperPluginDelegateImpl::RegisterTCPSocket( | 615 void PepperPluginDelegateImpl::RegisterTCPSocket( |
| 619 PPB_TCPSocket_Private_Impl* socket, | 616 PPB_TCPSocket_Private_Impl* socket, |
| 620 uint32 socket_id) { | 617 uint32 socket_id) { |
| 621 tcp_sockets_.AddWithID(socket, socket_id); | 618 tcp_sockets_.AddWithID(socket, socket_id); |
| 622 } | 619 } |
| 623 | 620 |
| 624 void PepperPluginDelegateImpl::UnregisterTCPSocket(uint32 socket_id) { | 621 void PepperPluginDelegateImpl::UnregisterTCPSocket(uint32 socket_id) { |
| 625 // There is no DCHECK(tcp_sockets_.Lookup(socket_id)) because this method | 622 // There is no DCHECK(tcp_sockets_.Lookup(socket_id)) because this method |
| 626 // can be called before TCPSocketConnect or TCPSocketConnectWithNetAddress. | 623 // can be called before TCPSocketConnect or TCPSocketConnectWithNetAddress. |
| 627 if (tcp_sockets_.Lookup(socket_id)) | 624 if (tcp_sockets_.Lookup(socket_id)) |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 socket->OnAcceptCompleted(succeeded, | 843 socket->OnAcceptCompleted(succeeded, |
| 847 accepted_socket_id, | 844 accepted_socket_id, |
| 848 local_addr, | 845 local_addr, |
| 849 remote_addr); | 846 remote_addr); |
| 850 } else if (accepted_socket_id != 0) { | 847 } else if (accepted_socket_id != 0) { |
| 851 Send(new PpapiHostMsg_PPBTCPSocket_Disconnect(accepted_socket_id)); | 848 Send(new PpapiHostMsg_PPBTCPSocket_Disconnect(accepted_socket_id)); |
| 852 } | 849 } |
| 853 } | 850 } |
| 854 | 851 |
| 855 } // namespace content | 852 } // namespace content |
| OLD | NEW |