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 "webkit/chromeos/fileapi/cros_mount_point_provider.h" | 5 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h" |
6 | 6 |
7 #include "base/chromeos/chromeos_version.h" | 7 #include "base/chromeos/chromeos_version.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } | 58 } |
59 | 59 |
60 CrosMountPointProvider::~CrosMountPointProvider() { | 60 CrosMountPointProvider::~CrosMountPointProvider() { |
61 } | 61 } |
62 | 62 |
63 void CrosMountPointProvider::ValidateFileSystemRoot( | 63 void CrosMountPointProvider::ValidateFileSystemRoot( |
64 const GURL& origin_url, | 64 const GURL& origin_url, |
65 fileapi::FileSystemType type, | 65 fileapi::FileSystemType type, |
66 bool create, | 66 bool create, |
67 const ValidateFileSystemCallback& callback) { | 67 const ValidateFileSystemCallback& callback) { |
| 68 DCHECK(fileapi::IsolatedContext::IsIsolatedType(type)); |
68 // Nothing to validate for external filesystem. | 69 // Nothing to validate for external filesystem. |
69 DCHECK(type == fileapi::kFileSystemTypeExternal); | |
70 callback.Run(base::PLATFORM_FILE_OK); | 70 callback.Run(base::PLATFORM_FILE_OK); |
71 } | 71 } |
72 | 72 |
73 FilePath CrosMountPointProvider::GetFileSystemRootPathOnFileThread( | 73 FilePath CrosMountPointProvider::GetFileSystemRootPathOnFileThread( |
74 const GURL& origin_url, | 74 const GURL& origin_url, |
75 fileapi::FileSystemType type, | 75 fileapi::FileSystemType type, |
76 const FilePath& virtual_path, | 76 const FilePath& virtual_path, |
77 bool create) { | 77 bool create) { |
78 DCHECK(type == fileapi::kFileSystemTypeExternal); | 78 DCHECK(fileapi::IsolatedContext::IsIsolatedType(type)); |
79 fileapi::FileSystemURL url(origin_url, type, virtual_path); | 79 fileapi::FileSystemURL url(origin_url, type, virtual_path); |
80 if (!url.is_valid()) | 80 if (!url.is_valid()) |
81 return FilePath(); | 81 return FilePath(); |
82 | 82 |
83 FilePath root_path; | 83 FilePath root_path; |
84 if (!isolated_context()->GetRegisteredPath(url.filesystem_id(), &root_path)) | 84 if (!isolated_context()->GetRegisteredPath(url.filesystem_id(), &root_path)) |
85 return FilePath(); | 85 return FilePath(); |
86 | 86 |
87 return root_path.DirName(); | 87 return root_path.DirName(); |
88 } | 88 } |
89 | 89 |
90 bool CrosMountPointProvider::IsAccessAllowed( | 90 bool CrosMountPointProvider::IsAccessAllowed( |
91 const fileapi::FileSystemURL& url) { | 91 const fileapi::FileSystemURL& url) { |
92 // TODO(kinuko): this should call CanHandleURL() once | 92 if (!CanHandleURL(url)) |
93 // http://crbug.com/142267 is fixed. | |
94 if (url.type() != fileapi::kFileSystemTypeNativeLocal && | |
95 url.type() != fileapi::kFileSystemTypeDrive) | |
96 return false; | 93 return false; |
97 | 94 |
| 95 // No extra check is needed for isolated file systems. |
| 96 if (url.mount_type() == fileapi::kFileSystemTypeIsolated) |
| 97 return true; |
| 98 |
98 // Permit access to mount points from internal WebUI. | 99 // Permit access to mount points from internal WebUI. |
99 const GURL& origin_url = url.origin(); | 100 const GURL& origin_url = url.origin(); |
100 if (origin_url.SchemeIs(kChromeUIScheme)) | 101 if (origin_url.SchemeIs(kChromeUIScheme)) |
101 return true; | 102 return true; |
102 | 103 |
103 std::string extension_id = origin_url.host(); | 104 std::string extension_id = origin_url.host(); |
104 // Check first to make sure this extension has fileBrowserHander permissions. | 105 // Check first to make sure this extension has fileBrowserHander permissions. |
105 if (!special_storage_policy_->IsFileHandler(extension_id)) | 106 if (!special_storage_policy_->IsFileHandler(extension_id)) |
106 return false; | 107 return false; |
107 | 108 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 } | 279 } |
279 return iter->first.DirName().AppendRelativePath( | 280 return iter->first.DirName().AppendRelativePath( |
280 filesystem_path, virtual_path); | 281 filesystem_path, virtual_path); |
281 } | 282 } |
282 | 283 |
283 fileapi::IsolatedContext* CrosMountPointProvider::isolated_context() const { | 284 fileapi::IsolatedContext* CrosMountPointProvider::isolated_context() const { |
284 return fileapi::IsolatedContext::GetInstance(); | 285 return fileapi::IsolatedContext::GetInstance(); |
285 } | 286 } |
286 | 287 |
287 } // namespace chromeos | 288 } // namespace chromeos |
OLD | NEW |