| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/fileapi/file_system_operation.h" | 5 #include "webkit/fileapi/file_system_operation.h" |
| 6 | 6 |
| 7 #include "base/time.h" | 7 #include "base/time.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "net/base/escape.h" | 9 #include "net/base/escape.h" |
| 10 #include "net/url_request/url_request_context.h" | 10 #include "net/url_request/url_request_context.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 FileSystemFileUtil* dest_file_system_file_util; | 143 FileSystemFileUtil* dest_file_system_file_util; |
| 144 | 144 |
| 145 if (!VerifyFileSystemPathForRead(src_path, &src_origin_url, &src_type, | 145 if (!VerifyFileSystemPathForRead(src_path, &src_origin_url, &src_type, |
| 146 &virtual_path_0, &src_file_system_file_util) || | 146 &virtual_path_0, &src_file_system_file_util) || |
| 147 !VerifyFileSystemPathForWrite(dest_path, true /* create */, | 147 !VerifyFileSystemPathForWrite(dest_path, true /* create */, |
| 148 &dest_origin_url, &dest_type, &virtual_path_1, | 148 &dest_origin_url, &dest_type, &virtual_path_1, |
| 149 &dest_file_system_file_util)) { | 149 &dest_file_system_file_util)) { |
| 150 delete this; | 150 delete this; |
| 151 return; | 151 return; |
| 152 } | 152 } |
| 153 if (src_origin_url.GetOrigin() != dest_origin_url.GetOrigin()) { | |
| 154 // TODO(ericu): We don't yet support copying across filesystem types, from | |
| 155 // extension to sandbox, etc. From temporary to persistent works, though. | |
| 156 // Since the sandbox code isn't in yet, I'm not sure exactly what check | |
| 157 // belongs here, but there's also no danger yet. | |
| 158 delete this; | |
| 159 return; | |
| 160 } | |
| 161 if (src_file_system_file_util != dest_file_system_file_util) { | |
| 162 // TODO(ericu): implement this. | |
| 163 delete this; | |
| 164 return; | |
| 165 } | |
| 166 file_system_operation_context_.set_src_origin_url(src_origin_url); | 153 file_system_operation_context_.set_src_origin_url(src_origin_url); |
| 167 file_system_operation_context_.set_dest_origin_url(dest_origin_url); | 154 file_system_operation_context_.set_dest_origin_url(dest_origin_url); |
| 168 file_system_operation_context_.set_src_type(src_type); | 155 file_system_operation_context_.set_src_type(src_type); |
| 169 file_system_operation_context_.set_dest_type(dest_type); | 156 file_system_operation_context_.set_dest_type(dest_type); |
| 170 file_system_operation_context_.set_src_virtual_path(virtual_path_0); | 157 file_system_operation_context_.set_src_virtual_path(virtual_path_0); |
| 171 file_system_operation_context_.set_dest_virtual_path(virtual_path_1); | 158 file_system_operation_context_.set_dest_virtual_path(virtual_path_1); |
| 172 if (!file_system_operation_context_.src_file_system_file_util()) | 159 if (!file_system_operation_context_.src_file_system_file_util()) |
| 173 file_system_operation_context_.set_src_file_system_file_util( | 160 file_system_operation_context_.set_src_file_system_file_util( |
| 174 src_file_system_file_util); | 161 src_file_system_file_util); |
| 175 if (!file_system_operation_context_.dest_file_system_file_util()) | 162 if (!file_system_operation_context_.dest_file_system_file_util()) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 FileSystemFileUtil* dest_file_system_file_util; | 202 FileSystemFileUtil* dest_file_system_file_util; |
| 216 | 203 |
| 217 if (!VerifyFileSystemPathForWrite(src_path, false, &src_origin_url, &src_type, | 204 if (!VerifyFileSystemPathForWrite(src_path, false, &src_origin_url, &src_type, |
| 218 &virtual_path_0, &src_file_system_file_util) || | 205 &virtual_path_0, &src_file_system_file_util) || |
| 219 !VerifyFileSystemPathForWrite(dest_path, true /* create */, | 206 !VerifyFileSystemPathForWrite(dest_path, true /* create */, |
| 220 &dest_origin_url, &dest_type, &virtual_path_1, | 207 &dest_origin_url, &dest_type, &virtual_path_1, |
| 221 &dest_file_system_file_util)) { | 208 &dest_file_system_file_util)) { |
| 222 delete this; | 209 delete this; |
| 223 return; | 210 return; |
| 224 } | 211 } |
| 225 if (src_origin_url.GetOrigin() != dest_origin_url.GetOrigin()) { | |
| 226 // TODO(ericu): We don't yet support moving across filesystem types, from | |
| 227 // extension to sandbox, etc. From temporary to persistent works, though. | |
| 228 delete this; | |
| 229 return; | |
| 230 } | |
| 231 if (src_file_system_file_util != dest_file_system_file_util) { | |
| 232 // TODO(ericu): implement this. | |
| 233 delete this; | |
| 234 return; | |
| 235 } | |
| 236 file_system_operation_context_.set_src_origin_url(src_origin_url); | 212 file_system_operation_context_.set_src_origin_url(src_origin_url); |
| 237 file_system_operation_context_.set_dest_origin_url(dest_origin_url); | 213 file_system_operation_context_.set_dest_origin_url(dest_origin_url); |
| 238 file_system_operation_context_.set_src_type(src_type); | 214 file_system_operation_context_.set_src_type(src_type); |
| 239 file_system_operation_context_.set_dest_type(dest_type); | 215 file_system_operation_context_.set_dest_type(dest_type); |
| 240 file_system_operation_context_.set_src_virtual_path(virtual_path_0); | 216 file_system_operation_context_.set_src_virtual_path(virtual_path_0); |
| 241 file_system_operation_context_.set_dest_virtual_path(virtual_path_1); | 217 file_system_operation_context_.set_dest_virtual_path(virtual_path_1); |
| 242 if (!file_system_operation_context_.src_file_system_file_util()) | 218 if (!file_system_operation_context_.src_file_system_file_util()) |
| 243 file_system_operation_context_.set_src_file_system_file_util( | 219 file_system_operation_context_.set_src_file_system_file_util( |
| 244 src_file_system_file_util); | 220 src_file_system_file_util); |
| 245 if (!file_system_operation_context_.dest_file_system_file_util()) | 221 if (!file_system_operation_context_.dest_file_system_file_util()) |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 } | 844 } |
| 869 DCHECK(file_system_file_util); | 845 DCHECK(file_system_file_util); |
| 870 *file_system_file_util = | 846 *file_system_file_util = |
| 871 file_system_context()->path_manager()->GetFileSystemFileUtil(*type); | 847 file_system_context()->path_manager()->GetFileSystemFileUtil(*type); |
| 872 DCHECK(*file_system_file_util); | 848 DCHECK(*file_system_file_util); |
| 873 | 849 |
| 874 return true; | 850 return true; |
| 875 } | 851 } |
| 876 | 852 |
| 877 } // namespace fileapi | 853 } // namespace fileapi |
| OLD | NEW |