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

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

Issue 9016020: Cleanup FileSystemOperation for preparing for adding FSO-factory method (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more cleanup around ValidateFileSystemRoot Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_callback_factory.h" 8 #include "base/memory/scoped_callback_factory.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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 base::AutoLock locker(lock_); 72 base::AutoLock locker(lock_);
73 // Check if this root mount point is exposed by this provider. 73 // Check if this root mount point is exposed by this provider.
74 MountPointMap::iterator iter = mount_point_map_.find(components[0]); 74 MountPointMap::iterator iter = mount_point_map_.find(components[0]);
75 if (iter == mount_point_map_.end()) { 75 if (iter == mount_point_map_.end()) {
76 return false; 76 return false;
77 } 77 }
78 *root_path = iter->second; 78 *root_path = iter->second;
79 return true; 79 return true;
80 } 80 }
81 81
82 void CrosMountPointProvider::ValidateFileSystemRootAndGetURL( 82 void CrosMountPointProvider::ValidateFileSystemRoot(
83 const GURL& origin_url, 83 const GURL& origin_url,
84 fileapi::FileSystemType type, 84 fileapi::FileSystemType type,
85 bool create, 85 bool create,
86 const GetRootPathCallback& callback) { 86 const ValidateFileSystemCallback& callback) {
87 // Nothing to validate for external filesystem.
87 DCHECK(type == fileapi::kFileSystemTypeExternal); 88 DCHECK(type == fileapi::kFileSystemTypeExternal);
88 std::string name(GetOriginIdentifierFromURL(origin_url)); 89 callback.Run(base::PLATFORM_FILE_OK);
89 name += ':';
90 name += fileapi::kExternalName;
91 FilePath root_path;
92 root_path = FilePath(fileapi::kExternalDir);
93 callback.Run(true, root_path, name);
94 } 90 }
95 91
96 FilePath CrosMountPointProvider::ValidateFileSystemRootAndGetPathOnFileThread( 92 FilePath CrosMountPointProvider::GetFileSystemRootPathOnFileThread(
97 const GURL& origin_url, 93 const GURL& origin_url,
98 fileapi::FileSystemType type, 94 fileapi::FileSystemType type,
99 const FilePath& virtual_path, 95 const FilePath& virtual_path,
100 bool create) { 96 bool create) {
101 DCHECK(type == fileapi::kFileSystemTypeExternal); 97 DCHECK(type == fileapi::kFileSystemTypeExternal);
102 FilePath root_path; 98 FilePath root_path;
103 if (!GetRootForVirtualPath(virtual_path, &root_path)) 99 if (!GetRootForVirtualPath(virtual_path, &root_path))
104 return FilePath(); 100 return FilePath();
105 101
106 return root_path; 102 return root_path;
107 } 103 }
108 104
109 // TODO(zelidrag): Share this code with SandboxMountPointProvider impl.
110 bool CrosMountPointProvider::IsRestrictedFileName(const FilePath& path) const {
111 return false;
112 }
113
114 bool CrosMountPointProvider::IsAccessAllowed(const GURL& origin_url, 105 bool CrosMountPointProvider::IsAccessAllowed(const GURL& origin_url,
115 fileapi::FileSystemType type, 106 fileapi::FileSystemType type,
116 const FilePath& virtual_path) { 107 const FilePath& virtual_path) {
117 if (type != fileapi::kFileSystemTypeExternal) 108 if (type != fileapi::kFileSystemTypeExternal)
118 return false; 109 return false;
119 110
120 // Permit access to mount points from internal WebUI. 111 // Permit access to mount points from internal WebUI.
121 if (origin_url.SchemeIs(kChromeUIScheme)) 112 if (origin_url.SchemeIs(kChromeUIScheme))
122 return true; 113 return true;
123 114
124 std::string extension_id = origin_url.host(); 115 std::string extension_id = origin_url.host();
125 // Check first to make sure this extension has fileBrowserHander permissions. 116 // Check first to make sure this extension has fileBrowserHander permissions.
126 if (!special_storage_policy_->IsFileHandler(extension_id)) 117 if (!special_storage_policy_->IsFileHandler(extension_id))
127 return false; 118 return false;
128 119
129 return file_access_permissions_->HasAccessPermission(extension_id, 120 return file_access_permissions_->HasAccessPermission(extension_id,
130 virtual_path); 121 virtual_path);
131 } 122 }
132 123
124 // TODO(zelidrag): Share this code with SandboxMountPointProvider impl.
125 bool CrosMountPointProvider::IsRestrictedFileName(const FilePath& path) const {
126 return false;
127 }
128
133 void CrosMountPointProvider::AddMountPoint(FilePath mount_point) { 129 void CrosMountPointProvider::AddMountPoint(FilePath mount_point) {
134 base::AutoLock locker(lock_); 130 base::AutoLock locker(lock_);
135 mount_point_map_.erase(mount_point.BaseName().value()); 131 mount_point_map_.erase(mount_point.BaseName().value());
136 mount_point_map_.insert(std::pair<std::string, FilePath>( 132 mount_point_map_.insert(std::pair<std::string, FilePath>(
137 mount_point.BaseName().value(), mount_point.DirName())); 133 mount_point.BaseName().value(), mount_point.DirName()));
138 } 134 }
139 135
140 void CrosMountPointProvider::RemoveMountPoint(FilePath mount_point) { 136 void CrosMountPointProvider::RemoveMountPoint(FilePath mount_point) {
141 base::AutoLock locker(lock_); 137 base::AutoLock locker(lock_);
142 mount_point_map_.erase(mount_point.BaseName().value()); 138 mount_point_map_.erase(mount_point.BaseName().value());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } else if (mount_prefix == filesystem_path) { 190 } else if (mount_prefix == filesystem_path) {
195 FilePath root = FilePath(FILE_PATH_LITERAL("/")); 191 FilePath root = FilePath(FILE_PATH_LITERAL("/"));
196 *virtual_path = root.Append(iter->first); 192 *virtual_path = root.Append(iter->first);
197 return true; 193 return true;
198 } 194 }
199 } 195 }
200 return false; 196 return false;
201 } 197 }
202 198
203 } // namespace chromeos 199 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698