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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h" |
14 #include "chrome/browser/chromeos/fileapi/file_access_permissions.h" | 15 #include "chrome/browser/chromeos/fileapi/file_access_permissions.h" |
15 #include "chrome/browser/chromeos/fileapi/file_system_backend_delegate.h" | 16 #include "chrome/browser/chromeos/fileapi/file_system_backend_delegate.h" |
16 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" | 17 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" |
17 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
18 #include "chromeos/chromeos_switches.h" | 19 #include "chromeos/chromeos_switches.h" |
19 #include "chromeos/dbus/cros_disks_client.h" | 20 #include "chromeos/dbus/cros_disks_client.h" |
| 21 #include "net/base/escape.h" |
20 #include "storage/browser/fileapi/async_file_util.h" | 22 #include "storage/browser/fileapi/async_file_util.h" |
21 #include "storage/browser/fileapi/external_mount_points.h" | 23 #include "storage/browser/fileapi/external_mount_points.h" |
22 #include "storage/browser/fileapi/file_stream_reader.h" | 24 #include "storage/browser/fileapi/file_stream_reader.h" |
23 #include "storage/browser/fileapi/file_stream_writer.h" | 25 #include "storage/browser/fileapi/file_stream_writer.h" |
24 #include "storage/browser/fileapi/file_system_context.h" | 26 #include "storage/browser/fileapi/file_system_context.h" |
25 #include "storage/browser/fileapi/file_system_operation.h" | 27 #include "storage/browser/fileapi/file_system_operation.h" |
26 #include "storage/browser/fileapi/file_system_operation_context.h" | 28 #include "storage/browser/fileapi/file_system_operation_context.h" |
27 #include "storage/browser/fileapi/file_system_url.h" | 29 #include "storage/browser/fileapi/file_system_url.h" |
28 #include "storage/common/fileapi/file_system_mount_option.h" | 30 #include "storage/common/fileapi/file_system_mount_option.h" |
| 31 #include "storage/common/fileapi/file_system_util.h" |
29 | 32 |
30 namespace chromeos { | 33 namespace chromeos { |
31 namespace { | 34 namespace { |
32 | 35 |
33 // TODO(mtomasz): Remove this hacky whitelist. | 36 // TODO(mtomasz): Remove this hacky whitelist. |
34 // See: crbug.com/271946 | 37 // See: crbug.com/271946 |
35 const char* kOemAccessibleExtensions[] = { | 38 const char* kOemAccessibleExtensions[] = { |
36 "mlbmkoenclnokonejhlfakkeabdlmpek", // TimeScapes, | 39 "mlbmkoenclnokonejhlfakkeabdlmpek", // TimeScapes, |
37 "nhpmmldpbfjofkipjaieeomhnmcgihfm", // Retail Demo (public session), | 40 "nhpmmldpbfjofkipjaieeomhnmcgihfm", // Retail Demo (public session), |
38 "klimoghijjogocdbaikffefjfcfheiel", // Retail Demo (OOBE), | 41 "klimoghijjogocdbaikffefjfcfheiel", // Retail Demo (OOBE), |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 if (components.size() < 2) { | 152 if (components.size() < 2) { |
150 // Unable to access /archive and /removable directories directly. The | 153 // Unable to access /archive and /removable directories directly. The |
151 // inner mount name must be specified. | 154 // inner mount name must be specified. |
152 callback.Run( | 155 callback.Run( |
153 GURL(root_url), std::string(), base::File::FILE_ERROR_SECURITY); | 156 GURL(root_url), std::string(), base::File::FILE_ERROR_SECURITY); |
154 return; | 157 return; |
155 } | 158 } |
156 std::string inner_mount_name = components[1]; | 159 std::string inner_mount_name = components[1]; |
157 root_url += inner_mount_name + "/"; | 160 root_url += inner_mount_name + "/"; |
158 name = inner_mount_name; | 161 name = inner_mount_name; |
| 162 } else if (id == arc::kDocumentsProviderMountPointName) { |
| 163 // For ARC documents provider file system, volumes are mounted per document |
| 164 // provider root, so we need to fix up |root_url| to point to an individual |
| 165 // root. |
| 166 std::string authority; |
| 167 std::string root_document_id; |
| 168 base::FilePath unused_path; |
| 169 if (!arc::ParseDocumentsProviderUrl(url, &authority, &root_document_id, |
| 170 &unused_path)) { |
| 171 callback.Run(GURL(root_url), std::string(), |
| 172 base::File::FILE_ERROR_SECURITY); |
| 173 return; |
| 174 } |
| 175 base::FilePath mount_path = |
| 176 arc::GetDocumentsProviderMountPath(authority, root_document_id); |
| 177 base::FilePath relative_mount_path; |
| 178 base::FilePath(arc::kDocumentsProviderMountPointPath) |
| 179 .AppendRelativePath(mount_path, &relative_mount_path); |
| 180 root_url += |
| 181 net::EscapePath(storage::FilePathToString(relative_mount_path)) + "/"; |
| 182 name = authority + ":" + root_document_id; |
159 } else { | 183 } else { |
160 name = id; | 184 name = id; |
161 } | 185 } |
162 | 186 |
163 callback.Run(GURL(root_url), name, base::File::FILE_OK); | 187 callback.Run(GURL(root_url), name, base::File::FILE_OK); |
164 } | 188 } |
165 | 189 |
166 storage::FileSystemQuotaUtil* FileSystemBackend::GetQuotaUtil() { | 190 storage::FileSystemQuotaUtil* FileSystemBackend::GetQuotaUtil() { |
167 // No quota support. | 191 // No quota support. |
168 return NULL; | 192 return NULL; |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 const base::FilePath& entry_path) const { | 486 const base::FilePath& entry_path) const { |
463 base::FilePath virtual_path; | 487 base::FilePath virtual_path; |
464 if (!GetVirtualPath(entry_path, &virtual_path)) | 488 if (!GetVirtualPath(entry_path, &virtual_path)) |
465 return storage::FileSystemURL(); | 489 return storage::FileSystemURL(); |
466 | 490 |
467 return context->CreateCrackedFileSystemURL( | 491 return context->CreateCrackedFileSystemURL( |
468 GURL() /* origin */, storage::kFileSystemTypeExternal, virtual_path); | 492 GURL() /* origin */, storage::kFileSystemTypeExternal, virtual_path); |
469 } | 493 } |
470 | 494 |
471 } // namespace chromeos | 495 } // namespace chromeos |
OLD | NEW |