OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_file_system_host.h" | 5 #include "content/renderer/pepper/pepper_file_system_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "content/child/child_thread.h" | 9 #include "content/child/child_thread.h" |
10 #include "content/child/fileapi/file_system_dispatcher.h" | 10 #include "content/child/fileapi/file_system_dispatcher.h" |
11 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 11 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
12 #include "content/public/renderer/render_view.h" | 12 #include "content/public/renderer/render_view.h" |
13 #include "content/public/renderer/renderer_ppapi_host.h" | 13 #include "content/public/renderer/renderer_ppapi_host.h" |
14 #include "ppapi/c/pp_errors.h" | 14 #include "ppapi/c/pp_errors.h" |
15 #include "ppapi/host/dispatch_host_message.h" | 15 #include "ppapi/host/dispatch_host_message.h" |
16 #include "ppapi/host/ppapi_host.h" | 16 #include "ppapi/host/ppapi_host.h" |
17 #include "ppapi/proxy/ppapi_messages.h" | 17 #include "ppapi/proxy/ppapi_messages.h" |
| 18 #include "ppapi/shared_impl/file_system_util.h" |
18 #include "ppapi/shared_impl/file_type_conversion.h" | 19 #include "ppapi/shared_impl/file_type_conversion.h" |
19 #include "third_party/WebKit/public/web/WebDocument.h" | 20 #include "third_party/WebKit/public/web/WebDocument.h" |
20 #include "third_party/WebKit/public/web/WebFrame.h" | 21 #include "third_party/WebKit/public/web/WebFrame.h" |
21 #include "third_party/WebKit/public/web/WebView.h" | 22 #include "third_party/WebKit/public/web/WebView.h" |
22 #include "webkit/common/fileapi/file_system_util.h" | 23 #include "webkit/common/fileapi/file_system_util.h" |
23 | 24 |
24 namespace content { | 25 namespace content { |
25 | 26 |
26 PepperFileSystemHost::PepperFileSystemHost(RendererPpapiHost* host, | 27 PepperFileSystemHost::PepperFileSystemHost(RendererPpapiHost* host, |
27 PP_Instance instance, | 28 PP_Instance instance, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 91 } |
91 | 92 |
92 int32_t PepperFileSystemHost::OnHostMsgOpen( | 93 int32_t PepperFileSystemHost::OnHostMsgOpen( |
93 ppapi::host::HostMessageContext* context, | 94 ppapi::host::HostMessageContext* context, |
94 int64_t expected_size) { | 95 int64_t expected_size) { |
95 // Not allow multiple opens. | 96 // Not allow multiple opens. |
96 if (called_open_) | 97 if (called_open_) |
97 return PP_ERROR_INPROGRESS; | 98 return PP_ERROR_INPROGRESS; |
98 called_open_ = true; | 99 called_open_ = true; |
99 | 100 |
100 fileapi::FileSystemType file_system_type; | 101 fileapi::FileSystemType file_system_type = |
101 switch (type_) { | 102 ppapi::PepperFileSystemTypeToFileSystemType(type_); |
102 case PP_FILESYSTEMTYPE_LOCALTEMPORARY: | 103 if (file_system_type == fileapi::kFileSystemTypeUnknown) |
103 file_system_type = fileapi::kFileSystemTypeTemporary; | 104 return PP_ERROR_FAILED; |
104 break; | |
105 case PP_FILESYSTEMTYPE_LOCALPERSISTENT: | |
106 file_system_type = fileapi::kFileSystemTypePersistent; | |
107 break; | |
108 case PP_FILESYSTEMTYPE_EXTERNAL: | |
109 file_system_type = fileapi::kFileSystemTypeExternal; | |
110 break; | |
111 default: | |
112 return PP_ERROR_FAILED; | |
113 } | |
114 | 105 |
115 GURL document_url = renderer_ppapi_host_->GetDocumentURL(pp_instance()); | 106 GURL document_url = renderer_ppapi_host_->GetDocumentURL(pp_instance()); |
116 if (!document_url.is_valid()) | 107 if (!document_url.is_valid()) |
117 return PP_ERROR_FAILED; | 108 return PP_ERROR_FAILED; |
118 | 109 |
119 FileSystemDispatcher* file_system_dispatcher = | 110 FileSystemDispatcher* file_system_dispatcher = |
120 ChildThread::current()->file_system_dispatcher(); | 111 ChildThread::current()->file_system_dispatcher(); |
121 reply_context_ = context->MakeReplyMessageContext(); | 112 reply_context_ = context->MakeReplyMessageContext(); |
122 file_system_dispatcher->OpenFileSystem( | 113 file_system_dispatcher->OpenFileSystem( |
123 document_url.GetOrigin(), | 114 document_url.GetOrigin(), |
(...skipping 20 matching lines...) Expand all Loading... |
144 if (!view) | 135 if (!view) |
145 return PP_ERROR_FAILED; | 136 return PP_ERROR_FAILED; |
146 const GURL& url = view->GetWebView()->mainFrame()->document().url(); | 137 const GURL& url = view->GetWebView()->mainFrame()->document().url(); |
147 root_url_ = GURL(fileapi::GetIsolatedFileSystemRootURIString( | 138 root_url_ = GURL(fileapi::GetIsolatedFileSystemRootURIString( |
148 url.GetOrigin(), fsid, "crxfs")); | 139 url.GetOrigin(), fsid, "crxfs")); |
149 opened_ = true; | 140 opened_ = true; |
150 return PP_OK; | 141 return PP_OK; |
151 } | 142 } |
152 | 143 |
153 } // namespace content | 144 } // namespace content |
OLD | NEW |