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

Side by Side Diff: chrome/browser/chromeos/file_manager/fileapi_util.cc

Issue 296693003: Don't treat |is_directory| mismatch as an error in entry conversion in files.app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fix Created 6 years, 7 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 | « chrome/browser/chromeos/file_manager/fileapi_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/chromeos/file_manager/fileapi_util.h" 5 #include "chrome/browser/chromeos/file_manager/fileapi_util.h"
6 6
7 #include "base/files/file.h" 7 #include "base/files/file.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "chrome/browser/chromeos/drive/file_system_util.h" 9 #include "chrome/browser/chromeos/drive/file_system_util.h"
10 #include "chrome/browser/extensions/extension_util.h" 10 #include "chrome/browser/extensions/extension_util.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 fileapi::FileSystemContext::ResolvedEntryType type) { 158 fileapi::FileSystemContext::ResolvedEntryType type) {
159 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 159 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
160 160
161 if (error != base::File::FILE_OK) { 161 if (error != base::File::FILE_OK) {
162 OnIteratorConverted(self_deleter.Pass(), 162 OnIteratorConverted(self_deleter.Pass(),
163 iterator, 163 iterator,
164 CreateEntryDefinitionWithError(error)); 164 CreateEntryDefinitionWithError(error));
165 return; 165 return;
166 } 166 }
167 167
168 // Check the entry type.
169 if (iterator->is_directory &&
170 type == fileapi::FileSystemContext::RESOLVED_ENTRY_FILE) {
171 OnIteratorConverted(self_deleter.Pass(),
172 iterator,
173 CreateEntryDefinitionWithError(
174 base::File::FILE_ERROR_NOT_A_DIRECTORY));
175 return;
176 }
177 if (!iterator->is_directory &&
178 type == fileapi::FileSystemContext::RESOLVED_ENTRY_DIRECTORY) {
179 OnIteratorConverted(self_deleter.Pass(),
180 iterator,
181 CreateEntryDefinitionWithError(
182 base::File::FILE_ERROR_NOT_A_FILE));
183 return;
184 }
185
186 EntryDefinition entry_definition; 168 EntryDefinition entry_definition;
187 entry_definition.file_system_root_url = info.root_url.spec(); 169 entry_definition.file_system_root_url = info.root_url.spec();
188 entry_definition.file_system_name = info.name; 170 entry_definition.file_system_name = info.name;
189 entry_definition.is_directory = iterator->is_directory; 171 switch (type) {
172 case fileapi::FileSystemContext::RESOLVED_ENTRY_FILE:
173 entry_definition.is_directory = false;
174 break;
175 case fileapi::FileSystemContext::RESOLVED_ENTRY_DIRECTORY:
176 entry_definition.is_directory = true;
177 break;
178 case fileapi::FileSystemContext::RESOLVED_ENTRY_NOT_FOUND:
179 entry_definition.is_directory = iterator->is_directory;
180 break;
181 }
190 entry_definition.error = base::File::FILE_OK; 182 entry_definition.error = base::File::FILE_OK;
191 183
192 // Construct a target Entry.fullPath value from the virtual path and the 184 // Construct a target Entry.fullPath value from the virtual path and the
193 // root URL. Eg. Downloads/A/b.txt -> A/b.txt. 185 // root URL. Eg. Downloads/A/b.txt -> A/b.txt.
194 const base::FilePath root_virtual_path = 186 const base::FilePath root_virtual_path =
195 file_system_context_->CrackURL(info.root_url).virtual_path(); 187 file_system_context_->CrackURL(info.root_url).virtual_path();
196 DCHECK(root_virtual_path == iterator->virtual_path || 188 DCHECK(root_virtual_path == iterator->virtual_path ||
197 root_virtual_path.IsParent(iterator->virtual_path)); 189 root_virtual_path.IsParent(iterator->virtual_path));
198 base::FilePath full_path; 190 base::FilePath full_path;
199 root_virtual_path.AppendRelativePath(iterator->virtual_path, &full_path); 191 root_virtual_path.AppendRelativePath(iterator->virtual_path, &full_path);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 file_definition_list.push_back(file_definition); 323 file_definition_list.push_back(file_definition);
332 ConvertFileDefinitionListToEntryDefinitionList( 324 ConvertFileDefinitionListToEntryDefinitionList(
333 profile, 325 profile,
334 extension_id, 326 extension_id,
335 file_definition_list, 327 file_definition_list,
336 base::Bind(&OnConvertFileDefinitionDone, callback)); 328 base::Bind(&OnConvertFileDefinitionDone, callback));
337 } 329 }
338 330
339 } // namespace util 331 } // namespace util
340 } // namespace file_manager 332 } // namespace file_manager
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/file_manager/fileapi_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698