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