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/saved_files_service.h" | 7 #include "apps/saved_files_service.h" |
8 #include "apps/shell_window.h" | 8 #include "apps/shell_window.h" |
9 #include "apps/shell_window_registry.h" | 9 #include "apps/shell_window_registry.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 std::string filesystem_path; | 483 std::string filesystem_path; |
484 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &filesystem_name)); | 484 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &filesystem_name)); |
485 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &filesystem_path)); | 485 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &filesystem_path)); |
486 | 486 |
487 base::FilePath file_path; | 487 base::FilePath file_path; |
488 if (!GetFilePathOfFileEntry(filesystem_name, filesystem_path, | 488 if (!GetFilePathOfFileEntry(filesystem_name, filesystem_path, |
489 render_view_host_, &file_path, &error_)) | 489 render_view_host_, &file_path, &error_)) |
490 return false; | 490 return false; |
491 | 491 |
492 file_path = PrettifyPath(file_path); | 492 file_path = PrettifyPath(file_path); |
493 SetResult(base::Value::CreateStringValue(file_path.value())); | 493 SetResult(new base::StringValue(file_path.value())); |
494 return true; | 494 return true; |
495 } | 495 } |
496 | 496 |
497 FileSystemEntryFunction::FileSystemEntryFunction() | 497 FileSystemEntryFunction::FileSystemEntryFunction() |
498 : multiple_(false), | 498 : multiple_(false), |
499 entry_type_(READ_ONLY), | 499 entry_type_(READ_ONLY), |
500 response_(NULL) {} | 500 response_(NULL) {} |
501 | 501 |
502 bool FileSystemEntryFunction::HasFileSystemWritePermission() { | 502 bool FileSystemEntryFunction::HasFileSystemWritePermission() { |
503 const extensions::Extension* extension = GetExtension(); | 503 const extensions::Extension* extension = GetExtension(); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 error_ = kInvalidParameters; | 606 error_ = kInvalidParameters; |
607 return false; | 607 return false; |
608 } | 608 } |
609 | 609 |
610 content::ChildProcessSecurityPolicy* policy = | 610 content::ChildProcessSecurityPolicy* policy = |
611 content::ChildProcessSecurityPolicy::GetInstance(); | 611 content::ChildProcessSecurityPolicy::GetInstance(); |
612 int renderer_id = render_view_host_->GetProcess()->GetID(); | 612 int renderer_id = render_view_host_->GetProcess()->GetID(); |
613 bool is_writable = policy->CanReadWriteFileSystem(renderer_id, | 613 bool is_writable = policy->CanReadWriteFileSystem(renderer_id, |
614 filesystem_id); | 614 filesystem_id); |
615 | 615 |
616 SetResult(base::Value::CreateBooleanValue(is_writable)); | 616 SetResult(new base::FundamentalValue(is_writable)); |
617 return true; | 617 return true; |
618 } | 618 } |
619 | 619 |
620 // Handles showing a dialog to the user to ask for the filename for a file to | 620 // Handles showing a dialog to the user to ask for the filename for a file to |
621 // save or open. | 621 // save or open. |
622 class FileSystemChooseEntryFunction::FilePicker | 622 class FileSystemChooseEntryFunction::FilePicker |
623 : public ui::SelectFileDialog::Listener { | 623 : public ui::SelectFileDialog::Listener { |
624 public: | 624 public: |
625 FilePicker(FileSystemChooseEntryFunction* function, | 625 FilePicker(FileSystemChooseEntryFunction* function, |
626 content::WebContents* web_contents, | 626 content::WebContents* web_contents, |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 if (needs_new_entry) { | 1031 if (needs_new_entry) { |
1032 entry_type_ = file_entry->writable ? WRITABLE : READ_ONLY; | 1032 entry_type_ = file_entry->writable ? WRITABLE : READ_ONLY; |
1033 CreateResponse(); | 1033 CreateResponse(); |
1034 AddEntryToResponse(file_entry->path, file_entry->id); | 1034 AddEntryToResponse(file_entry->path, file_entry->id); |
1035 } | 1035 } |
1036 SendResponse(true); | 1036 SendResponse(true); |
1037 return true; | 1037 return true; |
1038 } | 1038 } |
1039 | 1039 |
1040 } // namespace extensions | 1040 } // namespace extensions |
OLD | NEW |