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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 std::string filesystem_id; | 622 std::string filesystem_id; |
623 if (!storage::CrackIsolatedFileSystemName(filesystem_name, &filesystem_id)) | 623 if (!storage::CrackIsolatedFileSystemName(filesystem_name, &filesystem_id)) |
624 return RespondNow(Error(app_file_handler_util::kInvalidParameters)); | 624 return RespondNow(Error(app_file_handler_util::kInvalidParameters)); |
625 | 625 |
626 content::ChildProcessSecurityPolicy* policy = | 626 content::ChildProcessSecurityPolicy* policy = |
627 content::ChildProcessSecurityPolicy::GetInstance(); | 627 content::ChildProcessSecurityPolicy::GetInstance(); |
628 int renderer_id = render_frame_host()->GetProcess()->GetID(); | 628 int renderer_id = render_frame_host()->GetProcess()->GetID(); |
629 bool is_writable = policy->CanReadWriteFileSystem(renderer_id, | 629 bool is_writable = policy->CanReadWriteFileSystem(renderer_id, |
630 filesystem_id); | 630 filesystem_id); |
631 | 631 |
632 return RespondNow( | 632 return RespondNow(OneArgument(base::MakeUnique<base::Value>(is_writable))); |
633 OneArgument(base::MakeUnique<base::FundamentalValue>(is_writable))); | |
634 } | 633 } |
635 | 634 |
636 // Handles showing a dialog to the user to ask for the filename for a file to | 635 // Handles showing a dialog to the user to ask for the filename for a file to |
637 // save or open. | 636 // save or open. |
638 class FileSystemChooseEntryFunction::FilePicker | 637 class FileSystemChooseEntryFunction::FilePicker |
639 : public ui::SelectFileDialog::Listener { | 638 : public ui::SelectFileDialog::Listener { |
640 public: | 639 public: |
641 FilePicker(FileSystemChooseEntryFunction* function, | 640 FilePicker(FileSystemChooseEntryFunction* function, |
642 content::WebContents* web_contents, | 641 content::WebContents* web_contents, |
643 const base::FilePath& suggested_name, | 642 const base::FilePath& suggested_name, |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 SavedFilesService* saved_files_service = SavedFilesService::Get(GetProfile()); | 1187 SavedFilesService* saved_files_service = SavedFilesService::Get(GetProfile()); |
1189 saved_files_service->RegisterFileEntry( | 1188 saved_files_service->RegisterFileEntry( |
1190 extension_->id(), entry_id, path, file_info->is_directory); | 1189 extension_->id(), entry_id, path, file_info->is_directory); |
1191 saved_files_service->EnqueueFileEntry(extension_->id(), entry_id); | 1190 saved_files_service->EnqueueFileEntry(extension_->id(), entry_id); |
1192 SendResponse(true); | 1191 SendResponse(true); |
1193 } | 1192 } |
1194 | 1193 |
1195 ExtensionFunction::ResponseAction FileSystemIsRestorableFunction::Run() { | 1194 ExtensionFunction::ResponseAction FileSystemIsRestorableFunction::Run() { |
1196 std::string entry_id; | 1195 std::string entry_id; |
1197 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &entry_id)); | 1196 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &entry_id)); |
1198 return RespondNow(OneArgument(base::MakeUnique<base::FundamentalValue>( | 1197 return RespondNow(OneArgument(base::MakeUnique<base::Value>( |
1199 SavedFilesService::Get(Profile::FromBrowserContext(browser_context())) | 1198 SavedFilesService::Get(Profile::FromBrowserContext(browser_context())) |
1200 ->IsRegistered(extension_->id(), entry_id)))); | 1199 ->IsRegistered(extension_->id(), entry_id)))); |
1201 } | 1200 } |
1202 | 1201 |
1203 bool FileSystemRestoreEntryFunction::RunAsync() { | 1202 bool FileSystemRestoreEntryFunction::RunAsync() { |
1204 std::string entry_id; | 1203 std::string entry_id; |
1205 bool needs_new_entry; | 1204 bool needs_new_entry; |
1206 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &entry_id)); | 1205 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &entry_id)); |
1207 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, &needs_new_entry)); | 1206 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, &needs_new_entry)); |
1208 const SavedFileEntry* file_entry = SavedFilesService::Get( | 1207 const SavedFileEntry* file_entry = SavedFilesService::Get( |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1436 return RespondNow(Error(kNotSupportedOnNonKioskSessionError)); | 1435 return RespondNow(Error(kNotSupportedOnNonKioskSessionError)); |
1437 std::vector<api::file_system::Volume> result_volume_list; | 1436 std::vector<api::file_system::Volume> result_volume_list; |
1438 FillVolumeList(chrome_details_.GetProfile(), &result_volume_list); | 1437 FillVolumeList(chrome_details_.GetProfile(), &result_volume_list); |
1439 | 1438 |
1440 return RespondNow(ArgumentList( | 1439 return RespondNow(ArgumentList( |
1441 api::file_system::GetVolumeList::Results::Create(result_volume_list))); | 1440 api::file_system::GetVolumeList::Results::Create(result_volume_list))); |
1442 } | 1441 } |
1443 #endif | 1442 #endif |
1444 | 1443 |
1445 } // namespace extensions | 1444 } // namespace extensions |
OLD | NEW |