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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 virtual bool HandleMouseLockedInputEvent( | 186 virtual bool HandleMouseLockedInputEvent( |
187 const WebKit::WebMouseEvent &event) OVERRIDE { | 187 const WebKit::WebMouseEvent &event) OVERRIDE { |
188 plugin_->HandleMouseLockedInputEvent(event); | 188 plugin_->HandleMouseLockedInputEvent(event); |
189 return true; | 189 return true; |
190 } | 190 } |
191 | 191 |
192 private: | 192 private: |
193 webkit::ppapi::PluginInstance* plugin_; | 193 webkit::ppapi::PluginInstance* plugin_; |
194 }; | 194 }; |
195 | 195 |
196 void DoNothing() {} | |
197 | |
196 } // namespace | 198 } // namespace |
197 | 199 |
198 PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderViewImpl* render_view) | 200 PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderViewImpl* render_view) |
199 : RenderViewObserver(render_view), | 201 : RenderViewObserver(render_view), |
200 render_view_(render_view), | 202 render_view_(render_view), |
201 has_saved_context_menu_action_(false), | 203 has_saved_context_menu_action_(false), |
202 saved_context_menu_action_(0), | 204 saved_context_menu_action_(0), |
203 focused_plugin_(NULL), | 205 focused_plugin_(NULL), |
204 last_mouse_event_target_(NULL), | 206 last_mouse_event_target_(NULL), |
205 device_enumeration_event_handler_( | 207 device_enumeration_event_handler_( |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
730 base::PlatformFile file, | 732 base::PlatformFile file, |
731 int message_id) { | 733 int message_id) { |
732 AsyncOpenFileCallback* callback = | 734 AsyncOpenFileCallback* callback = |
733 pending_async_open_files_.Lookup(message_id); | 735 pending_async_open_files_.Lookup(message_id); |
734 DCHECK(callback); | 736 DCHECK(callback); |
735 pending_async_open_files_.Remove(message_id); | 737 pending_async_open_files_.Remove(message_id); |
736 callback->Run(error_code, base::PassPlatformFile(&file)); | 738 callback->Run(error_code, base::PassPlatformFile(&file)); |
737 // Make sure we won't leak file handle if the requester has died. | 739 // Make sure we won't leak file handle if the requester has died. |
738 if (file != base::kInvalidPlatformFileValue) | 740 if (file != base::kInvalidPlatformFileValue) |
739 base::FileUtilProxy::Close(GetFileThreadMessageLoopProxy(), file, | 741 base::FileUtilProxy::Close(GetFileThreadMessageLoopProxy(), file, |
740 base::FileUtilProxy::StatusCallback()); | 742 base::FileUtilProxy::StatusCallback()); |
kinuko
2012/06/13 06:38:29
Do we need to call NotifyCloseFile on this case?
kinaba
2012/06/25 11:14:02
This method is for opening local FilePath's, not f
| |
741 delete callback; | 743 delete callback; |
742 } | 744 } |
743 | 745 |
744 void PepperPluginDelegateImpl::OnSetFocus(bool has_focus) { | 746 void PepperPluginDelegateImpl::OnSetFocus(bool has_focus) { |
745 for (std::set<webkit::ppapi::PluginInstance*>::iterator i = | 747 for (std::set<webkit::ppapi::PluginInstance*>::iterator i = |
746 active_instances_.begin(); | 748 active_instances_.begin(); |
747 i != active_instances_.end(); ++i) | 749 i != active_instances_.end(); ++i) |
748 (*i)->SetContentAreaFocus(has_focus); | 750 (*i)->SetContentAreaFocus(has_focus); |
749 } | 751 } |
750 | 752 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
888 NOTREACHED(); | 890 NOTREACHED(); |
889 } | 891 } |
890 | 892 |
891 virtual void DidOpenFile( | 893 virtual void DidOpenFile( |
892 base::PlatformFile file) { | 894 base::PlatformFile file) { |
893 callback_.Run(base::PLATFORM_FILE_OK, base::PassPlatformFile(&file)); | 895 callback_.Run(base::PLATFORM_FILE_OK, base::PassPlatformFile(&file)); |
894 // Make sure we won't leak file handle if the requester has died. | 896 // Make sure we won't leak file handle if the requester has died. |
895 if (file != base::kInvalidPlatformFileValue) { | 897 if (file != base::kInvalidPlatformFileValue) { |
896 base::FileUtilProxy::Close( | 898 base::FileUtilProxy::Close( |
897 RenderThreadImpl::current()->GetFileThreadMessageLoopProxy(), file, | 899 RenderThreadImpl::current()->GetFileThreadMessageLoopProxy(), file, |
898 base::FileUtilProxy::StatusCallback()); | 900 base::FileUtilProxy::StatusCallback()); |
kinuko
2012/06/13 06:38:29
Ditto. Close is often called in async helper destr
kinaba
2012/06/25 11:14:02
Yes, thanks.
| |
899 } | 901 } |
900 } | 902 } |
901 | 903 |
902 private: // TODO(ericu): Delete this? | 904 private: // TODO(ericu): Delete this? |
903 webkit::ppapi::PluginDelegate::AsyncOpenFileCallback callback_; | 905 webkit::ppapi::PluginDelegate::AsyncOpenFileCallback callback_; |
904 }; | 906 }; |
905 | 907 |
906 bool PepperPluginDelegateImpl::AsyncOpenFileSystemURL( | 908 bool PepperPluginDelegateImpl::AsyncOpenFileSystemURL( |
907 const GURL& path, int flags, const AsyncOpenFileCallback& callback) { | 909 const GURL& path, int flags, const AsyncOpenFileCallback& callback) { |
908 | 910 |
909 FileSystemDispatcher* file_system_dispatcher = | 911 FileSystemDispatcher* file_system_dispatcher = |
910 ChildThread::current()->file_system_dispatcher(); | 912 ChildThread::current()->file_system_dispatcher(); |
911 return file_system_dispatcher->OpenFile(path, flags, | 913 return file_system_dispatcher->OpenFile(path, flags, |
912 new AsyncOpenFileSystemURLCallbackTranslator(callback)); | 914 new AsyncOpenFileSystemURLCallbackTranslator(callback)); |
913 } | 915 } |
914 | 916 |
917 bool PepperPluginDelegateImpl::AsyncNotifyCloseFileSystemURL(const GURL& path) { | |
918 // Schedule the notification task in the file thread, to make sure that the | |
919 // actual close operation has finished. | |
920 return GetFileThreadMessageLoopProxy()->PostTaskAndReply( | |
921 FROM_HERE, | |
922 base::Bind(&DoNothing), | |
923 base::Bind(&PepperPluginDelegateImpl::DoNotifyCloseFile, | |
924 AsWeakPtr(), path)); | |
kinuko
2012/06/13 06:38:29
What happens if the plugin goes away before this i
kinaba
2012/06/25 11:14:02
PepperPluginDelegateImpl is associated with a rend
| |
925 } | |
926 | |
927 void PepperPluginDelegateImpl::DoNotifyCloseFile(const GURL& path) { | |
928 ChildThread::current()->file_system_dispatcher()->NotifyCloseFile(path); | |
929 } | |
930 | |
915 base::PlatformFileError PepperPluginDelegateImpl::OpenFile( | 931 base::PlatformFileError PepperPluginDelegateImpl::OpenFile( |
916 const ppapi::PepperFilePath& path, | 932 const ppapi::PepperFilePath& path, |
917 int flags, | 933 int flags, |
918 base::PlatformFile* file) { | 934 base::PlatformFile* file) { |
919 IPC::PlatformFileForTransit transit_file; | 935 IPC::PlatformFileForTransit transit_file; |
920 base::PlatformFileError error; | 936 base::PlatformFileError error; |
921 IPC::Message* msg = new PepperFileMsg_OpenFile( | 937 IPC::Message* msg = new PepperFileMsg_OpenFile( |
922 path, flags, &error, &transit_file); | 938 path, flags, &error, &transit_file); |
923 if (!render_view_->Send(msg)) { | 939 if (!render_view_->Send(msg)) { |
924 *file = base::kInvalidPlatformFileValue; | 940 *file = base::kInvalidPlatformFileValue; |
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1691 else | 1707 else |
1692 return render_view_->mouse_lock_dispatcher(); | 1708 return render_view_->mouse_lock_dispatcher(); |
1693 } | 1709 } |
1694 | 1710 |
1695 webkit_glue::ClipboardClient* | 1711 webkit_glue::ClipboardClient* |
1696 PepperPluginDelegateImpl::CreateClipboardClient() const { | 1712 PepperPluginDelegateImpl::CreateClipboardClient() const { |
1697 return new RendererClipboardClient; | 1713 return new RendererClipboardClient; |
1698 } | 1714 } |
1699 | 1715 |
1700 } // namespace content | 1716 } // namespace content |
OLD | NEW |