Chromium Code Reviews| 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 class AsyncOpenFileSystemURLCallbackTranslator | |
| 197 : public fileapi::FileSystemCallbackDispatcher { | |
| 198 public: | |
| 199 AsyncOpenFileSystemURLCallbackTranslator( | |
| 200 const webkit::ppapi::PluginDelegate::AsyncOpenFileSystemURLCallback& | |
| 201 callback, | |
| 202 const webkit::ppapi::PluginDelegate::NotifyCloseFileCallback& | |
| 203 close_file_callback) | |
| 204 : callback_(callback), | |
| 205 close_file_callback_(close_file_callback) { | |
| 206 } | |
| 207 | |
| 208 virtual ~AsyncOpenFileSystemURLCallbackTranslator() {} | |
| 209 | |
| 210 virtual void DidSucceed() { | |
| 211 NOTREACHED(); | |
| 212 } | |
| 213 virtual void DidReadMetadata( | |
| 214 const base::PlatformFileInfo& file_info, | |
| 215 const FilePath& platform_path) { | |
| 216 NOTREACHED(); | |
| 217 } | |
| 218 virtual void DidReadDirectory( | |
| 219 const std::vector<base::FileUtilProxy::Entry>& entries, | |
| 220 bool has_more) { | |
| 221 NOTREACHED(); | |
| 222 } | |
| 223 virtual void DidOpenFileSystem(const std::string& name, | |
| 224 const GURL& root) { | |
| 225 NOTREACHED(); | |
| 226 } | |
| 227 | |
| 228 virtual void DidFail(base::PlatformFileError error_code) { | |
| 229 base::PlatformFile invalid_file = base::kInvalidPlatformFileValue; | |
| 230 callback_.Run(error_code, | |
| 231 base::PassPlatformFile(&invalid_file), | |
| 232 webkit::ppapi::PluginDelegate::NotifyCloseFileCallback()); | |
| 233 } | |
| 234 | |
| 235 virtual void DidWrite(int64 bytes, bool complete) { | |
| 236 NOTREACHED(); | |
| 237 } | |
| 238 | |
| 239 virtual void DidOpenFile( | |
| 240 base::PlatformFile file) { | |
|
yzshen1
2012/07/03 17:26:31
nit: No need to put it on a separate line.
kinaba
2012/07/04 04:26:22
Done.
| |
| 241 callback_.Run(base::PLATFORM_FILE_OK, | |
| 242 base::PassPlatformFile(&file), | |
| 243 close_file_callback_); | |
| 244 // Make sure we won't leak file handle if the requester has died. | |
| 245 if (file != base::kInvalidPlatformFileValue) { | |
| 246 base::FileUtilProxy::Close( | |
| 247 RenderThreadImpl::current()->GetFileThreadMessageLoopProxy(), file, | |
| 248 close_file_callback_); | |
| 249 } | |
| 250 } | |
| 251 | |
| 252 private: | |
| 253 webkit::ppapi::PluginDelegate::AsyncOpenFileSystemURLCallback callback_; | |
| 254 webkit::ppapi::PluginDelegate::NotifyCloseFileCallback close_file_callback_; | |
| 255 }; | |
| 256 | |
| 257 void DoNotifyCloseFile(const GURL& path, base::PlatformFileError /* unused */) { | |
| 258 ChildThread::current()->file_system_dispatcher()->NotifyCloseFile(path); | |
| 259 } | |
| 260 | |
| 196 } // namespace | 261 } // namespace |
| 197 | 262 |
| 198 PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderViewImpl* render_view) | 263 PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderViewImpl* render_view) |
| 199 : RenderViewObserver(render_view), | 264 : RenderViewObserver(render_view), |
| 200 render_view_(render_view), | 265 render_view_(render_view), |
| 201 has_saved_context_menu_action_(false), | 266 has_saved_context_menu_action_(false), |
| 202 saved_context_menu_action_(0), | 267 saved_context_menu_action_(0), |
| 203 focused_plugin_(NULL), | 268 focused_plugin_(NULL), |
| 204 last_mouse_event_target_(NULL), | 269 last_mouse_event_target_(NULL), |
| 205 device_enumeration_event_handler_( | 270 device_enumeration_event_handler_( |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 844 } | 909 } |
| 845 | 910 |
| 846 void PepperPluginDelegateImpl::WillUpdateFile(const GURL& path) { | 911 void PepperPluginDelegateImpl::WillUpdateFile(const GURL& path) { |
| 847 ChildThread::current()->Send(new FileSystemHostMsg_WillUpdate(path)); | 912 ChildThread::current()->Send(new FileSystemHostMsg_WillUpdate(path)); |
| 848 } | 913 } |
| 849 | 914 |
| 850 void PepperPluginDelegateImpl::DidUpdateFile(const GURL& path, int64_t delta) { | 915 void PepperPluginDelegateImpl::DidUpdateFile(const GURL& path, int64_t delta) { |
| 851 ChildThread::current()->Send(new FileSystemHostMsg_DidUpdate(path, delta)); | 916 ChildThread::current()->Send(new FileSystemHostMsg_DidUpdate(path, delta)); |
| 852 } | 917 } |
| 853 | 918 |
| 854 class AsyncOpenFileSystemURLCallbackTranslator | |
| 855 : public fileapi::FileSystemCallbackDispatcher { | |
| 856 public: | |
| 857 AsyncOpenFileSystemURLCallbackTranslator( | |
| 858 const webkit::ppapi::PluginDelegate::AsyncOpenFileCallback& callback) | |
| 859 : callback_(callback) { | |
| 860 } | |
| 861 | |
| 862 virtual ~AsyncOpenFileSystemURLCallbackTranslator() {} | |
| 863 | |
| 864 virtual void DidSucceed() { | |
| 865 NOTREACHED(); | |
| 866 } | |
| 867 virtual void DidReadMetadata( | |
| 868 const base::PlatformFileInfo& file_info, | |
| 869 const FilePath& platform_path) { | |
| 870 NOTREACHED(); | |
| 871 } | |
| 872 virtual void DidReadDirectory( | |
| 873 const std::vector<base::FileUtilProxy::Entry>& entries, | |
| 874 bool has_more) { | |
| 875 NOTREACHED(); | |
| 876 } | |
| 877 virtual void DidOpenFileSystem(const std::string& name, | |
| 878 const GURL& root) { | |
| 879 NOTREACHED(); | |
| 880 } | |
| 881 | |
| 882 virtual void DidFail(base::PlatformFileError error_code) { | |
| 883 base::PlatformFile invalid_file = base::kInvalidPlatformFileValue; | |
| 884 callback_.Run(error_code, base::PassPlatformFile(&invalid_file)); | |
| 885 } | |
| 886 | |
| 887 virtual void DidWrite(int64 bytes, bool complete) { | |
| 888 NOTREACHED(); | |
| 889 } | |
| 890 | |
| 891 virtual void DidOpenFile( | |
| 892 base::PlatformFile file) { | |
| 893 callback_.Run(base::PLATFORM_FILE_OK, base::PassPlatformFile(&file)); | |
| 894 // Make sure we won't leak file handle if the requester has died. | |
| 895 if (file != base::kInvalidPlatformFileValue) { | |
| 896 base::FileUtilProxy::Close( | |
| 897 RenderThreadImpl::current()->GetFileThreadMessageLoopProxy(), file, | |
| 898 base::FileUtilProxy::StatusCallback()); | |
| 899 } | |
| 900 } | |
| 901 | |
| 902 private: // TODO(ericu): Delete this? | |
| 903 webkit::ppapi::PluginDelegate::AsyncOpenFileCallback callback_; | |
| 904 }; | |
| 905 | |
| 906 bool PepperPluginDelegateImpl::AsyncOpenFileSystemURL( | 919 bool PepperPluginDelegateImpl::AsyncOpenFileSystemURL( |
| 907 const GURL& path, int flags, const AsyncOpenFileCallback& callback) { | 920 const GURL& path, |
| 921 int flags, | |
| 922 const AsyncOpenFileSystemURLCallback& callback) { | |
| 908 | 923 |
| 909 FileSystemDispatcher* file_system_dispatcher = | 924 FileSystemDispatcher* file_system_dispatcher = |
| 910 ChildThread::current()->file_system_dispatcher(); | 925 ChildThread::current()->file_system_dispatcher(); |
| 911 return file_system_dispatcher->OpenFile(path, flags, | 926 return file_system_dispatcher->OpenFile(path, flags, |
| 912 new AsyncOpenFileSystemURLCallbackTranslator(callback)); | 927 new AsyncOpenFileSystemURLCallbackTranslator( |
| 928 callback, | |
| 929 base::Bind(&DoNotifyCloseFile, path))); | |
| 913 } | 930 } |
| 914 | 931 |
| 915 base::PlatformFileError PepperPluginDelegateImpl::OpenFile( | 932 base::PlatformFileError PepperPluginDelegateImpl::OpenFile( |
| 916 const ppapi::PepperFilePath& path, | 933 const ppapi::PepperFilePath& path, |
| 917 int flags, | 934 int flags, |
| 918 base::PlatformFile* file) { | 935 base::PlatformFile* file) { |
| 919 IPC::PlatformFileForTransit transit_file; | 936 IPC::PlatformFileForTransit transit_file; |
| 920 base::PlatformFileError error; | 937 base::PlatformFileError error; |
| 921 IPC::Message* msg = new PepperFileMsg_OpenFile( | 938 IPC::Message* msg = new PepperFileMsg_OpenFile( |
| 922 path, flags, &error, &transit_file); | 939 path, flags, &error, &transit_file); |
| (...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1705 else | 1722 else |
| 1706 return render_view_->mouse_lock_dispatcher(); | 1723 return render_view_->mouse_lock_dispatcher(); |
| 1707 } | 1724 } |
| 1708 | 1725 |
| 1709 webkit_glue::ClipboardClient* | 1726 webkit_glue::ClipboardClient* |
| 1710 PepperPluginDelegateImpl::CreateClipboardClient() const { | 1727 PepperPluginDelegateImpl::CreateClipboardClient() const { |
| 1711 return new RendererClipboardClient; | 1728 return new RendererClipboardClient; |
| 1712 } | 1729 } |
| 1713 | 1730 |
| 1714 } // namespace content | 1731 } // namespace content |
| OLD | NEW |