OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/chromeos/fileapi/file_system_backend.h" | 5 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "chrome/browser/chromeos/fileapi/file_access_permissions.h" | 10 #include "chrome/browser/chromeos/fileapi/file_access_permissions.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 } | 89 } |
90 | 90 |
91 void FileSystemBackend::Initialize(fileapi::FileSystemContext* context) { | 91 void FileSystemBackend::Initialize(fileapi::FileSystemContext* context) { |
92 } | 92 } |
93 | 93 |
94 void FileSystemBackend::ResolveURL(const fileapi::FileSystemURL& url, | 94 void FileSystemBackend::ResolveURL(const fileapi::FileSystemURL& url, |
95 fileapi::OpenFileSystemMode mode, | 95 fileapi::OpenFileSystemMode mode, |
96 const OpenFileSystemCallback& callback) { | 96 const OpenFileSystemCallback& callback) { |
97 std::string id; | 97 std::string id; |
98 fileapi::FileSystemType type; | 98 fileapi::FileSystemType type; |
| 99 std::string cracked_id; |
99 base::FilePath path; | 100 base::FilePath path; |
100 fileapi::FileSystemMountOption option; | 101 fileapi::FileSystemMountOption option; |
101 if (!mount_points_->CrackVirtualPath( | 102 if (!mount_points_->CrackVirtualPath( |
102 url.virtual_path(), &id, &type, &path, &option) && | 103 url.virtual_path(), &id, &type, &cracked_id, &path, &option) && |
103 !system_mount_points_->CrackVirtualPath( | 104 !system_mount_points_->CrackVirtualPath( |
104 url.virtual_path(), &id, &type, &path, &option)) { | 105 url.virtual_path(), &id, &type, &cracked_id, &path, &option)) { |
105 // Not under a mount point, so return an error, since the root is not | 106 // Not under a mount point, so return an error, since the root is not |
106 // accessible. | 107 // accessible. |
107 GURL root_url = GURL(fileapi::GetExternalFileSystemRootURIString( | 108 GURL root_url = GURL(fileapi::GetExternalFileSystemRootURIString( |
108 url.origin(), std::string())); | 109 url.origin(), std::string())); |
109 callback.Run(root_url, std::string(), base::File::FILE_ERROR_SECURITY); | 110 callback.Run(root_url, std::string(), base::File::FILE_ERROR_SECURITY); |
110 return; | 111 return; |
111 } | 112 } |
112 | 113 |
113 std::string name; | 114 std::string name; |
114 // Construct a URL restricted to the found mount point. | 115 // Construct a URL restricted to the found mount point. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 182 |
182 void FileSystemBackend::GrantFileAccessToExtension( | 183 void FileSystemBackend::GrantFileAccessToExtension( |
183 const std::string& extension_id, const base::FilePath& virtual_path) { | 184 const std::string& extension_id, const base::FilePath& virtual_path) { |
184 // All we care about here is access from extensions for now. | 185 // All we care about here is access from extensions for now. |
185 DCHECK(special_storage_policy_->IsFileHandler(extension_id)); | 186 DCHECK(special_storage_policy_->IsFileHandler(extension_id)); |
186 if (!special_storage_policy_->IsFileHandler(extension_id)) | 187 if (!special_storage_policy_->IsFileHandler(extension_id)) |
187 return; | 188 return; |
188 | 189 |
189 std::string id; | 190 std::string id; |
190 fileapi::FileSystemType type; | 191 fileapi::FileSystemType type; |
| 192 std::string cracked_id; |
191 base::FilePath path; | 193 base::FilePath path; |
192 fileapi::FileSystemMountOption option; | 194 fileapi::FileSystemMountOption option; |
193 if (!mount_points_->CrackVirtualPath(virtual_path, | 195 if (!mount_points_->CrackVirtualPath(virtual_path, &id, &type, &cracked_id, |
194 &id, &type, &path, &option) && | 196 &path, &option) && |
195 !system_mount_points_->CrackVirtualPath(virtual_path, | 197 !system_mount_points_->CrackVirtualPath(virtual_path, &id, &type, |
196 &id, &type, &path, &option)) { | 198 &cracked_id, &path, &option)) { |
197 return; | 199 return; |
198 } | 200 } |
199 | 201 |
200 if (type == fileapi::kFileSystemTypeRestrictedNativeLocal) { | 202 if (type == fileapi::kFileSystemTypeRestrictedNativeLocal) { |
201 LOG(ERROR) << "Can't grant access for restricted mount point"; | 203 LOG(ERROR) << "Can't grant access for restricted mount point"; |
202 return; | 204 return; |
203 } | 205 } |
204 | 206 |
205 file_access_permissions_->GrantAccessPermission(extension_id, virtual_path); | 207 file_access_permissions_->GrantAccessPermission(extension_id, virtual_path); |
206 } | 208 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 url.type() == fileapi::kFileSystemTypeDrive || | 273 url.type() == fileapi::kFileSystemTypeDrive || |
272 url.type() == fileapi::kFileSystemTypeProvided); | 274 url.type() == fileapi::kFileSystemTypeProvided); |
273 return fileapi::FileSystemOperation::Create( | 275 return fileapi::FileSystemOperation::Create( |
274 url, context, | 276 url, context, |
275 make_scoped_ptr(new fileapi::FileSystemOperationContext(context))); | 277 make_scoped_ptr(new fileapi::FileSystemOperationContext(context))); |
276 } | 278 } |
277 | 279 |
278 bool FileSystemBackend::SupportsStreaming( | 280 bool FileSystemBackend::SupportsStreaming( |
279 const fileapi::FileSystemURL& url) const { | 281 const fileapi::FileSystemURL& url) const { |
280 return url.type() == fileapi::kFileSystemTypeDrive || | 282 return url.type() == fileapi::kFileSystemTypeDrive || |
281 url.type() == fileapi::kFileSystemTypeProvided; | 283 url.type() == fileapi::kFileSystemTypeProvided || |
| 284 url.type() == fileapi::kFileSystemTypeDeviceMediaAsFileStorage; |
282 } | 285 } |
283 | 286 |
284 scoped_ptr<webkit_blob::FileStreamReader> | 287 scoped_ptr<webkit_blob::FileStreamReader> |
285 FileSystemBackend::CreateFileStreamReader( | 288 FileSystemBackend::CreateFileStreamReader( |
286 const fileapi::FileSystemURL& url, | 289 const fileapi::FileSystemURL& url, |
287 int64 offset, | 290 int64 offset, |
288 const base::Time& expected_modification_time, | 291 const base::Time& expected_modification_time, |
289 fileapi::FileSystemContext* context) const { | 292 fileapi::FileSystemContext* context) const { |
290 DCHECK(url.is_valid()); | 293 DCHECK(url.is_valid()); |
291 | 294 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 } | 349 } |
347 | 350 |
348 bool FileSystemBackend::GetVirtualPath( | 351 bool FileSystemBackend::GetVirtualPath( |
349 const base::FilePath& filesystem_path, | 352 const base::FilePath& filesystem_path, |
350 base::FilePath* virtual_path) { | 353 base::FilePath* virtual_path) { |
351 return mount_points_->GetVirtualPath(filesystem_path, virtual_path) || | 354 return mount_points_->GetVirtualPath(filesystem_path, virtual_path) || |
352 system_mount_points_->GetVirtualPath(filesystem_path, virtual_path); | 355 system_mount_points_->GetVirtualPath(filesystem_path, virtual_path); |
353 } | 356 } |
354 | 357 |
355 } // namespace chromeos | 358 } // namespace chromeos |
OLD | NEW |