| 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/saved_files_service.h" | 9 #include "apps/saved_files_service.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "extensions/browser/extension_prefs.h" | 35 #include "extensions/browser/extension_prefs.h" |
| 36 #include "extensions/browser/extension_system.h" | 36 #include "extensions/browser/extension_system.h" |
| 37 #include "extensions/browser/granted_file_entry.h" | 37 #include "extensions/browser/granted_file_entry.h" |
| 38 #include "extensions/common/permissions/api_permission.h" | 38 #include "extensions/common/permissions/api_permission.h" |
| 39 #include "extensions/common/permissions/permissions_data.h" | 39 #include "extensions/common/permissions/permissions_data.h" |
| 40 #include "grit/generated_resources.h" | 40 #include "grit/generated_resources.h" |
| 41 #include "net/base/mime_util.h" | 41 #include "net/base/mime_util.h" |
| 42 #include "ui/base/l10n/l10n_util.h" | 42 #include "ui/base/l10n/l10n_util.h" |
| 43 #include "ui/shell_dialogs/select_file_dialog.h" | 43 #include "ui/shell_dialogs/select_file_dialog.h" |
| 44 #include "ui/shell_dialogs/selected_file_info.h" | 44 #include "ui/shell_dialogs/selected_file_info.h" |
| 45 #include "webkit/browser/fileapi/external_mount_points.h" | 45 #include "storage/browser/fileapi/external_mount_points.h" |
| 46 #include "webkit/browser/fileapi/isolated_context.h" | 46 #include "storage/browser/fileapi/isolated_context.h" |
| 47 #include "webkit/common/fileapi/file_system_types.h" | 47 #include "storage/common/fileapi/file_system_types.h" |
| 48 #include "webkit/common/fileapi/file_system_util.h" | 48 #include "storage/common/fileapi/file_system_util.h" |
| 49 | 49 |
| 50 #if defined(OS_MACOSX) | 50 #if defined(OS_MACOSX) |
| 51 #include <CoreFoundation/CoreFoundation.h> | 51 #include <CoreFoundation/CoreFoundation.h> |
| 52 #include "base/mac/foundation_util.h" | 52 #include "base/mac/foundation_util.h" |
| 53 #endif | 53 #endif |
| 54 | 54 |
| 55 #if defined(OS_CHROMEOS) | 55 #if defined(OS_CHROMEOS) |
| 56 #include "chrome/browser/chromeos/file_manager/filesystem_api_util.h" | 56 #include "chrome/browser/chromeos/file_manager/filesystem_api_util.h" |
| 57 #endif | 57 #endif |
| 58 | 58 |
| 59 using apps::SavedFileEntry; | 59 using apps::SavedFileEntry; |
| 60 using apps::SavedFilesService; | 60 using apps::SavedFilesService; |
| 61 using apps::AppWindow; | 61 using apps::AppWindow; |
| 62 using fileapi::IsolatedContext; | 62 using storage::IsolatedContext; |
| 63 | 63 |
| 64 const char kInvalidCallingPage[] = "Invalid calling page. This function can't " | 64 const char kInvalidCallingPage[] = "Invalid calling page. This function can't " |
| 65 "be called from a background page."; | 65 "be called from a background page."; |
| 66 const char kUserCancelled[] = "User cancelled"; | 66 const char kUserCancelled[] = "User cancelled"; |
| 67 const char kWritableFileErrorFormat[] = "Error opening %s"; | 67 const char kWritableFileErrorFormat[] = "Error opening %s"; |
| 68 const char kRequiresFileSystemWriteError[] = | 68 const char kRequiresFileSystemWriteError[] = |
| 69 "Operation requires fileSystem.write permission"; | 69 "Operation requires fileSystem.write permission"; |
| 70 const char kRequiresFileSystemDirectoryError[] = | 70 const char kRequiresFileSystemDirectoryError[] = |
| 71 "Operation requires fileSystem.directory permission"; | 71 "Operation requires fileSystem.directory permission"; |
| 72 const char kMultipleUnsupportedError[] = | 72 const char kMultipleUnsupportedError[] = |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 } | 342 } |
| 343 } | 343 } |
| 344 | 344 |
| 345 bool FileSystemIsWritableEntryFunction::RunSync() { | 345 bool FileSystemIsWritableEntryFunction::RunSync() { |
| 346 std::string filesystem_name; | 346 std::string filesystem_name; |
| 347 std::string filesystem_path; | 347 std::string filesystem_path; |
| 348 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &filesystem_name)); | 348 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &filesystem_name)); |
| 349 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &filesystem_path)); | 349 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &filesystem_path)); |
| 350 | 350 |
| 351 std::string filesystem_id; | 351 std::string filesystem_id; |
| 352 if (!fileapi::CrackIsolatedFileSystemName(filesystem_name, &filesystem_id)) { | 352 if (!storage::CrackIsolatedFileSystemName(filesystem_name, &filesystem_id)) { |
| 353 error_ = app_file_handler_util::kInvalidParameters; | 353 error_ = app_file_handler_util::kInvalidParameters; |
| 354 return false; | 354 return false; |
| 355 } | 355 } |
| 356 | 356 |
| 357 content::ChildProcessSecurityPolicy* policy = | 357 content::ChildProcessSecurityPolicy* policy = |
| 358 content::ChildProcessSecurityPolicy::GetInstance(); | 358 content::ChildProcessSecurityPolicy::GetInstance(); |
| 359 int renderer_id = render_view_host_->GetProcess()->GetID(); | 359 int renderer_id = render_view_host_->GetProcess()->GetID(); |
| 360 bool is_writable = policy->CanReadWriteFileSystem(renderer_id, | 360 bool is_writable = policy->CanReadWriteFileSystem(renderer_id, |
| 361 filesystem_id); | 361 filesystem_id); |
| 362 | 362 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 void FileSystemChooseEntryFunction::StopSkippingDirectoryConfirmationForTest() { | 563 void FileSystemChooseEntryFunction::StopSkippingDirectoryConfirmationForTest() { |
| 564 g_skip_directory_confirmation_for_test = false; | 564 g_skip_directory_confirmation_for_test = false; |
| 565 } | 565 } |
| 566 | 566 |
| 567 // static | 567 // static |
| 568 void FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest( | 568 void FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest( |
| 569 const std::string& name, const base::FilePath& path) { | 569 const std::string& name, const base::FilePath& path) { |
| 570 // For testing on Chrome OS, where to deal with remote and local paths | 570 // For testing on Chrome OS, where to deal with remote and local paths |
| 571 // smoothly, all accessed paths need to be registered in the list of | 571 // smoothly, all accessed paths need to be registered in the list of |
| 572 // external mount points. | 572 // external mount points. |
| 573 fileapi::ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( | 573 storage::ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( |
| 574 name, | 574 name, |
| 575 fileapi::kFileSystemTypeNativeLocal, | 575 storage::kFileSystemTypeNativeLocal, |
| 576 fileapi::FileSystemMountOption(), | 576 storage::FileSystemMountOption(), |
| 577 path); | 577 path); |
| 578 } | 578 } |
| 579 | 579 |
| 580 void FileSystemChooseEntryFunction::SetInitialPathOnFileThread( | 580 void FileSystemChooseEntryFunction::SetInitialPathOnFileThread( |
| 581 const base::FilePath& suggested_name, | 581 const base::FilePath& suggested_name, |
| 582 const base::FilePath& previous_path) { | 582 const base::FilePath& previous_path) { |
| 583 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); | 583 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
| 584 if (!previous_path.empty() && base::DirectoryExists(previous_path)) { | 584 if (!previous_path.empty() && base::DirectoryExists(previous_path)) { |
| 585 initial_path_ = previous_path.Append(suggested_name); | 585 initial_path_ = previous_path.Append(suggested_name); |
| 586 } else { | 586 } else { |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 return false; | 942 return false; |
| 943 } | 943 } |
| 944 | 944 |
| 945 bool FileSystemGetObservedEntriesFunction::RunSync() { | 945 bool FileSystemGetObservedEntriesFunction::RunSync() { |
| 946 NOTIMPLEMENTED(); | 946 NOTIMPLEMENTED(); |
| 947 error_ = kUnknownIdError; | 947 error_ = kUnknownIdError; |
| 948 return false; | 948 return false; |
| 949 } | 949 } |
| 950 | 950 |
| 951 } // namespace extensions | 951 } // namespace extensions |
| OLD | NEW |