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 "chrome/browser/extensions/api/file_system/file_system_api.h" | 5 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
6 | 6 |
7 #include "apps/app_window.h" | 7 #include "apps/app_window.h" |
8 #include "apps/app_window_registry.h" | 8 #include "apps/app_window_registry.h" |
9 #include "apps/browser/file_handler_util.h" | 9 #include "apps/browser/file_handler_util.h" |
10 #include "apps/saved_files_service.h" | 10 #include "apps/saved_files_service.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 file_path = PrettifyPath(file_path); | 276 file_path = PrettifyPath(file_path); |
277 SetResult(new base::StringValue(file_path.value())); | 277 SetResult(new base::StringValue(file_path.value())); |
278 return true; | 278 return true; |
279 } | 279 } |
280 | 280 |
281 FileSystemEntryFunction::FileSystemEntryFunction() | 281 FileSystemEntryFunction::FileSystemEntryFunction() |
282 : multiple_(false), | 282 : multiple_(false), |
283 is_directory_(false), | 283 is_directory_(false), |
284 response_(NULL) {} | 284 response_(NULL) {} |
285 | 285 |
286 void FileSystemEntryFunction::CheckWritableFiles( | 286 void FileSystemEntryFunction::PrepareFilesForWritableApp( |
287 const std::vector<base::FilePath>& paths) { | 287 const std::vector<base::FilePath>& paths) { |
288 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 288 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
289 app_file_handler_util::CheckWritableFiles( | 289 app_file_handler_util::PrepareFilesForWritableApp( |
290 paths, | 290 paths, |
291 GetProfile(), | 291 GetProfile(), |
292 is_directory_, | 292 is_directory_, |
293 base::Bind(&FileSystemEntryFunction::RegisterFileSystemsAndSendResponse, | 293 base::Bind(&FileSystemEntryFunction::RegisterFileSystemsAndSendResponse, |
294 this, | 294 this, |
295 paths), | 295 paths), |
296 base::Bind(&FileSystemEntryFunction::HandleWritableFileError, this)); | 296 base::Bind(&FileSystemEntryFunction::HandleWritableFileError, this)); |
297 } | 297 } |
298 | 298 |
299 void FileSystemEntryFunction::RegisterFileSystemsAndSendResponse( | 299 void FileSystemEntryFunction::RegisterFileSystemsAndSendResponse( |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 | 385 |
386 void FileSystemGetWritableEntryFunction::CheckPermissionAndSendResponse() { | 386 void FileSystemGetWritableEntryFunction::CheckPermissionAndSendResponse() { |
387 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 387 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
388 if (is_directory_ && | 388 if (is_directory_ && |
389 !extension_->HasAPIPermission(APIPermission::kFileSystemDirectory)) { | 389 !extension_->HasAPIPermission(APIPermission::kFileSystemDirectory)) { |
390 error_ = kRequiresFileSystemDirectoryError; | 390 error_ = kRequiresFileSystemDirectoryError; |
391 SendResponse(false); | 391 SendResponse(false); |
392 } | 392 } |
393 std::vector<base::FilePath> paths; | 393 std::vector<base::FilePath> paths; |
394 paths.push_back(path_); | 394 paths.push_back(path_); |
395 CheckWritableFiles(paths); | 395 PrepareFilesForWritableApp(paths); |
396 } | 396 } |
397 | 397 |
398 void FileSystemGetWritableEntryFunction::SetIsDirectoryOnFileThread() { | 398 void FileSystemGetWritableEntryFunction::SetIsDirectoryOnFileThread() { |
399 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); | 399 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
400 if (base::DirectoryExists(path_)) { | 400 if (base::DirectoryExists(path_)) { |
401 is_directory_ = true; | 401 is_directory_ = true; |
402 } | 402 } |
403 } | 403 } |
404 | 404 |
405 bool FileSystemIsWritableEntryFunction::RunSync() { | 405 bool FileSystemIsWritableEntryFunction::RunSync() { |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 content::BrowserThread::PostTask( | 763 content::BrowserThread::PostTask( |
764 content::BrowserThread::UI, | 764 content::BrowserThread::UI, |
765 FROM_HERE, | 765 FROM_HERE, |
766 base::Bind(&FileSystemChooseEntryFunction::OnDirectoryAccessConfirmed, | 766 base::Bind(&FileSystemChooseEntryFunction::OnDirectoryAccessConfirmed, |
767 this, paths)); | 767 this, paths)); |
768 } | 768 } |
769 | 769 |
770 void FileSystemChooseEntryFunction::OnDirectoryAccessConfirmed( | 770 void FileSystemChooseEntryFunction::OnDirectoryAccessConfirmed( |
771 const std::vector<base::FilePath>& paths) { | 771 const std::vector<base::FilePath>& paths) { |
772 if (app_file_handler_util::HasFileSystemWritePermission(extension_)) { | 772 if (app_file_handler_util::HasFileSystemWritePermission(extension_)) { |
773 CheckWritableFiles(paths); | 773 PrepareFilesForWritableApp(paths); |
774 return; | 774 return; |
775 } | 775 } |
776 | 776 |
777 // Don't need to check the file, it's for reading. | 777 // Don't need to check the file, it's for reading. |
778 RegisterFileSystemsAndSendResponse(paths); | 778 RegisterFileSystemsAndSendResponse(paths); |
779 } | 779 } |
780 | 780 |
781 void FileSystemChooseEntryFunction::BuildFileTypeInfo( | 781 void FileSystemChooseEntryFunction::BuildFileTypeInfo( |
782 ui::SelectFileDialog::FileTypeInfo* file_type_info, | 782 ui::SelectFileDialog::FileTypeInfo* file_type_info, |
783 const base::FilePath::StringType& suggested_extension, | 783 const base::FilePath::StringType& suggested_extension, |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 if (needs_new_entry) { | 983 if (needs_new_entry) { |
984 is_directory_ = file_entry->is_directory; | 984 is_directory_ = file_entry->is_directory; |
985 CreateResponse(); | 985 CreateResponse(); |
986 AddEntryToResponse(file_entry->path, file_entry->id); | 986 AddEntryToResponse(file_entry->path, file_entry->id); |
987 } | 987 } |
988 SendResponse(true); | 988 SendResponse(true); |
989 return true; | 989 return true; |
990 } | 990 } |
991 | 991 |
992 } // namespace extensions | 992 } // namespace extensions |
OLD | NEW |