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 17 matching lines...) Expand all Loading... |
28 #include "chrome/common/chrome_paths.h" | 28 #include "chrome/common/chrome_paths.h" |
29 #include "chrome/common/extensions/api/file_system.h" | 29 #include "chrome/common/extensions/api/file_system.h" |
30 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
31 #include "content/public/browser/child_process_security_policy.h" | 31 #include "content/public/browser/child_process_security_policy.h" |
32 #include "content/public/browser/render_process_host.h" | 32 #include "content/public/browser/render_process_host.h" |
33 #include "content/public/browser/render_view_host.h" | 33 #include "content/public/browser/render_view_host.h" |
34 #include "content/public/browser/web_contents.h" | 34 #include "content/public/browser/web_contents.h" |
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/common/permissions/api_permission.h" | 37 #include "extensions/common/permissions/api_permission.h" |
| 38 #include "extensions/common/permissions/permissions_data.h" |
38 #include "grit/generated_resources.h" | 39 #include "grit/generated_resources.h" |
39 #include "net/base/mime_util.h" | 40 #include "net/base/mime_util.h" |
40 #include "ui/base/l10n/l10n_util.h" | 41 #include "ui/base/l10n/l10n_util.h" |
41 #include "ui/shell_dialogs/select_file_dialog.h" | 42 #include "ui/shell_dialogs/select_file_dialog.h" |
42 #include "ui/shell_dialogs/selected_file_info.h" | 43 #include "ui/shell_dialogs/selected_file_info.h" |
43 #include "webkit/browser/fileapi/external_mount_points.h" | 44 #include "webkit/browser/fileapi/external_mount_points.h" |
44 #include "webkit/browser/fileapi/isolated_context.h" | 45 #include "webkit/browser/fileapi/isolated_context.h" |
45 #include "webkit/common/fileapi/file_system_types.h" | 46 #include "webkit/common/fileapi/file_system_types.h" |
46 #include "webkit/common/fileapi/file_system_util.h" | 47 #include "webkit/common/fileapi/file_system_util.h" |
47 | 48 |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 this), | 380 this), |
380 base::Bind( | 381 base::Bind( |
381 &FileSystemGetWritableEntryFunction::CheckPermissionAndSendResponse, | 382 &FileSystemGetWritableEntryFunction::CheckPermissionAndSendResponse, |
382 this)); | 383 this)); |
383 return true; | 384 return true; |
384 } | 385 } |
385 | 386 |
386 void FileSystemGetWritableEntryFunction::CheckPermissionAndSendResponse() { | 387 void FileSystemGetWritableEntryFunction::CheckPermissionAndSendResponse() { |
387 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 388 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
388 if (is_directory_ && | 389 if (is_directory_ && |
389 !extension_->HasAPIPermission(APIPermission::kFileSystemDirectory)) { | 390 !extension_->permissions_data()->HasAPIPermission( |
| 391 APIPermission::kFileSystemDirectory)) { |
390 error_ = kRequiresFileSystemDirectoryError; | 392 error_ = kRequiresFileSystemDirectoryError; |
391 SendResponse(false); | 393 SendResponse(false); |
392 } | 394 } |
393 std::vector<base::FilePath> paths; | 395 std::vector<base::FilePath> paths; |
394 paths.push_back(path_); | 396 paths.push_back(path_); |
395 PrepareFilesForWritableApp(paths); | 397 PrepareFilesForWritableApp(paths); |
396 } | 398 } |
397 | 399 |
398 void FileSystemGetWritableEntryFunction::SetIsDirectoryOnFileThread() { | 400 void FileSystemGetWritableEntryFunction::SetIsDirectoryOnFileThread() { |
399 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); | 401 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 error_ = kRequiresFileSystemWriteError; | 864 error_ = kRequiresFileSystemWriteError; |
863 return false; | 865 return false; |
864 } | 866 } |
865 if (multiple_) { | 867 if (multiple_) { |
866 error_ = kMultipleUnsupportedError; | 868 error_ = kMultipleUnsupportedError; |
867 return false; | 869 return false; |
868 } | 870 } |
869 picker_type = ui::SelectFileDialog::SELECT_SAVEAS_FILE; | 871 picker_type = ui::SelectFileDialog::SELECT_SAVEAS_FILE; |
870 } else if (options->type == file_system::CHOOSE_ENTRY_TYPE_OPENDIRECTORY) { | 872 } else if (options->type == file_system::CHOOSE_ENTRY_TYPE_OPENDIRECTORY) { |
871 is_directory_ = true; | 873 is_directory_ = true; |
872 if (!extension_->HasAPIPermission(APIPermission::kFileSystemDirectory)) { | 874 if (!extension_->permissions_data()->HasAPIPermission( |
| 875 APIPermission::kFileSystemDirectory)) { |
873 error_ = kRequiresFileSystemDirectoryError; | 876 error_ = kRequiresFileSystemDirectoryError; |
874 return false; | 877 return false; |
875 } | 878 } |
876 if (multiple_) { | 879 if (multiple_) { |
877 error_ = kMultipleUnsupportedError; | 880 error_ = kMultipleUnsupportedError; |
878 return false; | 881 return false; |
879 } | 882 } |
880 picker_type = ui::SelectFileDialog::SELECT_FOLDER; | 883 picker_type = ui::SelectFileDialog::SELECT_FOLDER; |
881 } | 884 } |
882 | 885 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 if (needs_new_entry) { | 986 if (needs_new_entry) { |
984 is_directory_ = file_entry->is_directory; | 987 is_directory_ = file_entry->is_directory; |
985 CreateResponse(); | 988 CreateResponse(); |
986 AddEntryToResponse(file_entry->path, file_entry->id); | 989 AddEntryToResponse(file_entry->path, file_entry->id); |
987 } | 990 } |
988 SendResponse(true); | 991 SendResponse(true); |
989 return true; | 992 return true; |
990 } | 993 } |
991 | 994 |
992 } // namespace extensions | 995 } // namespace extensions |
OLD | NEW |