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

Side by Side Diff: webkit/fileapi/isolated_file_util.cc

Issue 10825316: Invalid FileSystemURL should not be given to FileUtils (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 4 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
« no previous file with comments | « no previous file | webkit/fileapi/isolated_file_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/fileapi/isolated_file_util.h" 5 #include "webkit/fileapi/isolated_file_util.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 //------------------------------------------------------------------------- 112 //-------------------------------------------------------------------------
113 113
114 IsolatedFileUtil::IsolatedFileUtil() {} 114 IsolatedFileUtil::IsolatedFileUtil() {}
115 115
116 PlatformFileError IsolatedFileUtil::GetLocalFilePath( 116 PlatformFileError IsolatedFileUtil::GetLocalFilePath(
117 FileSystemOperationContext* context, 117 FileSystemOperationContext* context,
118 const FileSystemURL& url, 118 const FileSystemURL& url,
119 FilePath* local_file_path) { 119 FilePath* local_file_path) {
120 DCHECK(local_file_path); 120 DCHECK(local_file_path);
121 DCHECK(url.is_valid());
121 if (url.path().empty()) { 122 if (url.path().empty()) {
122 // Root direcory case, which should not be accessed. 123 // Root direcory case, which should not be accessed.
123 return base::PLATFORM_FILE_ERROR_ACCESS_DENIED; 124 return base::PLATFORM_FILE_ERROR_ACCESS_DENIED;
124 } 125 }
125 *local_file_path = url.path(); 126 *local_file_path = url.path();
126 return base::PLATFORM_FILE_OK; 127 return base::PLATFORM_FILE_OK;
127 } 128 }
128 129
129 //------------------------------------------------------------------------- 130 //-------------------------------------------------------------------------
130 131
131 DraggedFileUtil::DraggedFileUtil() {} 132 DraggedFileUtil::DraggedFileUtil() {}
132 133
133 PlatformFileError DraggedFileUtil::GetFileInfo( 134 PlatformFileError DraggedFileUtil::GetFileInfo(
134 FileSystemOperationContext* context, 135 FileSystemOperationContext* context,
135 const FileSystemURL& url, 136 const FileSystemURL& url,
136 PlatformFileInfo* file_info, 137 PlatformFileInfo* file_info,
137 FilePath* platform_path) { 138 FilePath* platform_path) {
138 DCHECK(file_info); 139 DCHECK(file_info);
139 std::string filesystem_id; 140 std::string filesystem_id;
141 DCHECK(url.is_valid());
140 if (url.path().empty()) { 142 if (url.path().empty()) {
141 // The root directory case. 143 // The root directory case.
142 // For now we leave three time fields (modified/accessed/creation time) 144 // For now we leave three time fields (modified/accessed/creation time)
143 // NULL as it is not really clear what to be set for this virtual directory. 145 // NULL as it is not really clear what to be set for this virtual directory.
144 // TODO(kinuko): Maybe we want to set the time when this filesystem is 146 // TODO(kinuko): Maybe we want to set the time when this filesystem is
145 // created (i.e. when the files/directories are dropped). 147 // created (i.e. when the files/directories are dropped).
146 file_info->is_directory = true; 148 file_info->is_directory = true;
147 file_info->is_symbolic_link = false; 149 file_info->is_symbolic_link = false;
148 file_info->size = 0; 150 file_info->size = 0;
149 return base::PLATFORM_FILE_OK; 151 return base::PLATFORM_FILE_OK;
150 } 152 }
151 base::PlatformFileError error = 153 base::PlatformFileError error =
152 NativeFileUtil::GetFileInfo(url.path(), file_info); 154 NativeFileUtil::GetFileInfo(url.path(), file_info);
153 if (file_util::IsLink(url.path()) && !FilePath().IsParent(url.path())) { 155 if (file_util::IsLink(url.path()) && !FilePath().IsParent(url.path())) {
154 // Don't follow symlinks unless it's the one that are selected by the user. 156 // Don't follow symlinks unless it's the one that are selected by the user.
155 return base::PLATFORM_FILE_ERROR_NOT_FOUND; 157 return base::PLATFORM_FILE_ERROR_NOT_FOUND;
156 } 158 }
157 if (error == base::PLATFORM_FILE_OK) 159 if (error == base::PLATFORM_FILE_OK)
158 *platform_path = url.path(); 160 *platform_path = url.path();
159 return error; 161 return error;
160 } 162 }
161 163
162 FileSystemFileUtil::AbstractFileEnumerator* 164 FileSystemFileUtil::AbstractFileEnumerator*
163 DraggedFileUtil::CreateFileEnumerator( 165 DraggedFileUtil::CreateFileEnumerator(
164 FileSystemOperationContext* context, 166 FileSystemOperationContext* context,
165 const FileSystemURL& root, 167 const FileSystemURL& root,
166 bool recursive) { 168 bool recursive) {
169 DCHECK(root.is_valid());
167 if (!root.path().empty()) 170 if (!root.path().empty())
168 return NativeFileUtil::CreateFileEnumerator(root.path(), recursive); 171 return NativeFileUtil::CreateFileEnumerator(root.path(), recursive);
169 172
170 // Root path case. 173 // Root path case.
171 std::vector<FileInfo> toplevels; 174 std::vector<FileInfo> toplevels;
172 IsolatedContext::GetInstance()->GetDraggedFileInfo( 175 IsolatedContext::GetInstance()->GetDraggedFileInfo(
173 root.filesystem_id(), &toplevels); 176 root.filesystem_id(), &toplevels);
174 if (!recursive) 177 if (!recursive)
175 return new SetFileEnumerator(toplevels); 178 return new SetFileEnumerator(toplevels);
176 return new RecursiveSetFileEnumerator(toplevels); 179 return new RecursiveSetFileEnumerator(toplevels);
177 } 180 }
178 181
179 bool DraggedFileUtil::IsDirectoryEmpty( 182 bool DraggedFileUtil::IsDirectoryEmpty(
180 FileSystemOperationContext* context, 183 FileSystemOperationContext* context,
181 const FileSystemURL& url) { 184 const FileSystemURL& url) {
185 DCHECK(url.is_valid());
182 if (url.path().empty()) { 186 if (url.path().empty()) {
183 // The root directory case. 187 // The root directory case.
184 std::vector<FileInfo> toplevels; 188 std::vector<FileInfo> toplevels;
185 bool success = IsolatedContext::GetInstance()->GetDraggedFileInfo( 189 bool success = IsolatedContext::GetInstance()->GetDraggedFileInfo(
186 url.filesystem_id(), &toplevels); 190 url.filesystem_id(), &toplevels);
187 DCHECK(success); 191 DCHECK(success);
188 return toplevels.empty(); 192 return toplevels.empty();
189 } 193 }
190 return NativeFileUtil::IsDirectoryEmpty(url.path()); 194 return NativeFileUtil::IsDirectoryEmpty(url.path());
191 } 195 }
192 196
193 } // namespace 197 } // namespace
OLDNEW
« no previous file with comments | « no previous file | webkit/fileapi/isolated_file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698