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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 const FilePath& virtual_path, | 89 const FilePath& virtual_path, |
90 bool create) { | 90 bool create) { |
91 DCHECK(type == fileapi::kFileSystemTypeExternal); | 91 DCHECK(type == fileapi::kFileSystemTypeExternal); |
92 FilePath root_path; | 92 FilePath root_path; |
93 if (!GetRootForVirtualPath(virtual_path, &root_path)) | 93 if (!GetRootForVirtualPath(virtual_path, &root_path)) |
94 return FilePath(); | 94 return FilePath(); |
95 | 95 |
96 return root_path; | 96 return root_path; |
97 } | 97 } |
98 | 98 |
99 bool CrosMountPointProvider::IsAccessAllowed(const GURL& origin_url, | 99 bool CrosMountPointProvider::IsAccessAllowed( |
100 fileapi::FileSystemType type, | 100 const fileapi::FileSystemURL& url) { |
101 const FilePath& virtual_path) { | 101 if (url.type() != fileapi::kFileSystemTypeExternal) |
102 if (type != fileapi::kFileSystemTypeExternal) | |
103 return false; | 102 return false; |
104 | 103 |
105 // Permit access to mount points from internal WebUI. | 104 // Permit access to mount points from internal WebUI. |
| 105 const GURL& origin_url = url.origin(); |
106 if (origin_url.SchemeIs(kChromeUIScheme)) | 106 if (origin_url.SchemeIs(kChromeUIScheme)) |
107 return true; | 107 return true; |
108 | 108 |
109 std::string extension_id = origin_url.host(); | 109 std::string extension_id = origin_url.host(); |
110 // Check first to make sure this extension has fileBrowserHander permissions. | 110 // Check first to make sure this extension has fileBrowserHander permissions. |
111 if (!special_storage_policy_->IsFileHandler(extension_id)) | 111 if (!special_storage_policy_->IsFileHandler(extension_id)) |
112 return false; | 112 return false; |
113 | 113 |
114 return file_access_permissions_->HasAccessPermission(extension_id, | 114 return file_access_permissions_->HasAccessPermission(extension_id, |
115 virtual_path); | 115 url.path()); |
116 } | 116 } |
117 | 117 |
118 // TODO(zelidrag): Share this code with SandboxMountPointProvider impl. | 118 // TODO(zelidrag): Share this code with SandboxMountPointProvider impl. |
119 bool CrosMountPointProvider::IsRestrictedFileName(const FilePath& path) const { | 119 bool CrosMountPointProvider::IsRestrictedFileName(const FilePath& path) const { |
120 return false; | 120 return false; |
121 } | 121 } |
122 | 122 |
123 fileapi::FileSystemQuotaUtil* CrosMountPointProvider::GetQuotaUtil() { | 123 fileapi::FileSystemQuotaUtil* CrosMountPointProvider::GetQuotaUtil() { |
124 // No quota support. | 124 // No quota support. |
125 return NULL; | 125 return NULL; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 if (mount_prefix == filesystem_path) { | 295 if (mount_prefix == filesystem_path) { |
296 return true; | 296 return true; |
297 } else if (mount_prefix.AppendRelativePath(filesystem_path, virtual_path)) { | 297 } else if (mount_prefix.AppendRelativePath(filesystem_path, virtual_path)) { |
298 return true; | 298 return true; |
299 } | 299 } |
300 } | 300 } |
301 return false; | 301 return false; |
302 } | 302 } |
303 | 303 |
304 } // namespace chromeos | 304 } // namespace chromeos |
OLD | NEW |