Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: webkit/chromeos/fileapi/cros_mount_point_provider.cc

Issue 12193007: Deprecate MountPointProvider::IsAccessAllowed in favor of GetPermissionPolicy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: base::FilePath fix Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 base::FilePath root_path; 82 base::FilePath root_path;
83 std::string mount_name = url.filesystem_id(); 83 std::string mount_name = url.filesystem_id();
84 if (!mount_points_->GetRegisteredPath(mount_name, &root_path) && 84 if (!mount_points_->GetRegisteredPath(mount_name, &root_path) &&
85 !system_mount_points_->GetRegisteredPath(mount_name, &root_path)) { 85 !system_mount_points_->GetRegisteredPath(mount_name, &root_path)) {
86 return base::FilePath(); 86 return base::FilePath();
87 } 87 }
88 88
89 return root_path.DirName(); 89 return root_path.DirName();
90 } 90 }
91 91
92 fileapi::FileSystemQuotaUtil* CrosMountPointProvider::GetQuotaUtil() {
93 // No quota support.
94 return NULL;
95 }
96
97 void CrosMountPointProvider::DeleteFileSystem(
98 const GURL& origin_url,
99 fileapi::FileSystemType type,
100 fileapi::FileSystemContext* context,
101 const DeleteFileSystemCallback& callback) {
102 NOTREACHED();
103 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
104 }
105
92 bool CrosMountPointProvider::IsAccessAllowed( 106 bool CrosMountPointProvider::IsAccessAllowed(
93 const fileapi::FileSystemURL& url) { 107 const fileapi::FileSystemURL& url) const {
94 if (!url.is_valid()) 108 if (!url.is_valid())
95 return false; 109 return false;
96 110
97 // Permit access to mount points from internal WebUI. 111 // Permit access to mount points from internal WebUI.
98 const GURL& origin_url = url.origin(); 112 const GURL& origin_url = url.origin();
99 if (origin_url.SchemeIs(kChromeUIScheme)) 113 if (origin_url.SchemeIs(kChromeUIScheme))
100 return true; 114 return true;
101 115
102 // No extra check is needed for isolated file systems. 116 // No extra check is needed for isolated file systems.
103 if (url.mount_type() == fileapi::kFileSystemTypeIsolated) 117 if (url.mount_type() == fileapi::kFileSystemTypeIsolated)
104 return true; 118 return true;
105 119
106 if (!CanHandleURL(url)) 120 if (!CanHandleURL(url))
107 return false; 121 return false;
108 122
109 std::string extension_id = origin_url.host(); 123 std::string extension_id = origin_url.host();
110 // Check first to make sure this extension has fileBrowserHander permissions. 124 // Check first to make sure this extension has fileBrowserHander permissions.
111 if (!special_storage_policy_->IsFileHandler(extension_id)) 125 if (!special_storage_policy_->IsFileHandler(extension_id))
112 return false; 126 return false;
113 127
114 return file_access_permissions_->HasAccessPermission(extension_id, 128 return file_access_permissions_->HasAccessPermission(extension_id,
115 url.virtual_path()); 129 url.virtual_path());
116 } 130 }
117 131
118 // TODO(zelidrag): Share this code with SandboxMountPointProvider impl.
119 bool CrosMountPointProvider::IsRestrictedFileName(
120 const base::FilePath& path) const {
121 return false;
122 }
123
124 fileapi::FileSystemQuotaUtil* CrosMountPointProvider::GetQuotaUtil() {
125 // No quota support.
126 return NULL;
127 }
128
129 void CrosMountPointProvider::DeleteFileSystem(
130 const GURL& origin_url,
131 fileapi::FileSystemType type,
132 fileapi::FileSystemContext* context,
133 const DeleteFileSystemCallback& callback) {
134 NOTREACHED();
135 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
136 }
137
138 void CrosMountPointProvider::GrantFullAccessToExtension( 132 void CrosMountPointProvider::GrantFullAccessToExtension(
139 const std::string& extension_id) { 133 const std::string& extension_id) {
140 DCHECK(special_storage_policy_->IsFileHandler(extension_id)); 134 DCHECK(special_storage_policy_->IsFileHandler(extension_id));
141 if (!special_storage_policy_->IsFileHandler(extension_id)) 135 if (!special_storage_policy_->IsFileHandler(extension_id))
142 return; 136 return;
143 137
144 std::vector<fileapi::MountPoints::MountPointInfo> files; 138 std::vector<fileapi::MountPoints::MountPointInfo> files;
145 mount_points_->AddMountPointInfosTo(&files); 139 mount_points_->AddMountPointInfosTo(&files);
146 system_mount_points_->AddMountPointInfosTo(&files); 140 system_mount_points_->AddMountPointInfosTo(&files);
147 141
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 195
202 fileapi::AsyncFileUtil* CrosMountPointProvider::GetAsyncFileUtil( 196 fileapi::AsyncFileUtil* CrosMountPointProvider::GetAsyncFileUtil(
203 fileapi::FileSystemType type) { 197 fileapi::FileSystemType type) {
204 DCHECK(type == fileapi::kFileSystemTypeNativeLocal || 198 DCHECK(type == fileapi::kFileSystemTypeNativeLocal ||
205 type == fileapi::kFileSystemTypeRestrictedNativeLocal); 199 type == fileapi::kFileSystemTypeRestrictedNativeLocal);
206 return local_file_util_.get(); 200 return local_file_util_.get();
207 } 201 }
208 202
209 fileapi::FilePermissionPolicy CrosMountPointProvider::GetPermissionPolicy( 203 fileapi::FilePermissionPolicy CrosMountPointProvider::GetPermissionPolicy(
210 const fileapi::FileSystemURL& url, int permissions) const { 204 const fileapi::FileSystemURL& url, int permissions) const {
205 if (url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal &&
206 (permissions & ~fileapi::kReadFilePermissions)) {
207 // Restricted file system is read-only.
208 return fileapi::FILE_PERMISSION_ALWAYS_DENY;
209 }
210
211 if (!IsAccessAllowed(url))
212 return fileapi::FILE_PERMISSION_ALWAYS_DENY;
213
214 // Permit access to mount points from internal WebUI.
215 const GURL& origin_url = url.origin();
216 if (origin_url.SchemeIs(kChromeUIScheme))
217 return fileapi::FILE_PERMISSION_ALWAYS_ALLOW;
218
211 if (url.mount_type() == fileapi::kFileSystemTypeIsolated) { 219 if (url.mount_type() == fileapi::kFileSystemTypeIsolated) {
212 // Permissions in isolated filesystems should be examined with 220 // Permissions in isolated filesystems should be examined with
213 // FileSystem permission. 221 // FileSystem permission.
214 return fileapi::FILE_PERMISSION_USE_FILESYSTEM_PERMISSION; 222 return fileapi::FILE_PERMISSION_USE_FILESYSTEM_PERMISSION;
215 } 223 }
224
225 // Also apply system's file permission by default.
216 return fileapi::FILE_PERMISSION_USE_FILE_PERMISSION; 226 return fileapi::FILE_PERMISSION_USE_FILE_PERMISSION;
217 } 227 }
218 228
219 fileapi::FileSystemOperation* CrosMountPointProvider::CreateFileSystemOperation( 229 fileapi::FileSystemOperation* CrosMountPointProvider::CreateFileSystemOperation(
220 const fileapi::FileSystemURL& url, 230 const fileapi::FileSystemURL& url,
221 fileapi::FileSystemContext* context, 231 fileapi::FileSystemContext* context,
222 base::PlatformFileError* error_code) const { 232 base::PlatformFileError* error_code) const {
223 DCHECK(url.is_valid()); 233 DCHECK(url.is_valid());
224 234
225 if (url.type() == fileapi::kFileSystemTypeDrive) { 235 if (url.type() == fileapi::kFileSystemTypeDrive) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 return new fileapi::RemoteFileStreamWriter(remote_proxy, url, offset); 276 return new fileapi::RemoteFileStreamWriter(remote_proxy, url, offset);
267 } 277 }
268 278
269 if (url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal) 279 if (url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal)
270 return NULL; 280 return NULL;
271 281
272 DCHECK(url.type() == fileapi::kFileSystemTypeNativeLocal); 282 DCHECK(url.type() == fileapi::kFileSystemTypeNativeLocal);
273 return new fileapi::LocalFileStreamWriter(url.path(), offset); 283 return new fileapi::LocalFileStreamWriter(url.path(), offset);
274 } 284 }
275 285
276 bool CrosMountPointProvider::GetVirtualPath(const base::FilePath& filesystem_pat h, 286 bool CrosMountPointProvider::GetVirtualPath(
277 base::FilePath* virtual_path) { 287 const base::FilePath& filesystem_path,
288 base::FilePath* virtual_path) {
278 return mount_points_->GetVirtualPath(filesystem_path, virtual_path) || 289 return mount_points_->GetVirtualPath(filesystem_path, virtual_path) ||
279 system_mount_points_->GetVirtualPath(filesystem_path, virtual_path); 290 system_mount_points_->GetVirtualPath(filesystem_path, virtual_path);
280 } 291 }
281 292
282 fileapi::RemoteFileSystemProxyInterface* CrosMountPointProvider::GetRemoteProxy( 293 fileapi::RemoteFileSystemProxyInterface* CrosMountPointProvider::GetRemoteProxy(
283 const std::string& mount_name) const { 294 const std::string& mount_name) const {
284 fileapi::RemoteFileSystemProxyInterface* proxy = 295 fileapi::RemoteFileSystemProxyInterface* proxy =
285 mount_points_->GetRemoteFileSystemProxy(mount_name); 296 mount_points_->GetRemoteFileSystemProxy(mount_name);
286 if (proxy) 297 if (proxy)
287 return proxy; 298 return proxy;
288 return system_mount_points_->GetRemoteFileSystemProxy(mount_name); 299 return system_mount_points_->GetRemoteFileSystemProxy(mount_name);
289 } 300 }
290 301
291 } // namespace chromeos 302 } // namespace chromeos
OLDNEW
« no previous file with comments | « webkit/chromeos/fileapi/cros_mount_point_provider.h ('k') | webkit/chromeos/fileapi/cros_mount_point_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698