OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/chromeos/extensions/file_manager/private_api_file_syste
m.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_file_syste
m.h" |
6 | 6 |
7 #include <sys/stat.h> | 7 #include <sys/stat.h> |
8 #include <sys/statvfs.h> | 8 #include <sys/statvfs.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #include <utime.h> | 10 #include <utime.h> |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 scoped_refptr<fileapi::FileSystemContext> file_system_context, | 290 scoped_refptr<fileapi::FileSystemContext> file_system_context, |
291 fileapi::FileSystemOperationRunner::OperationID operation_id) { | 291 fileapi::FileSystemOperationRunner::OperationID operation_id) { |
292 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 292 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
293 | 293 |
294 file_system_context->operation_runner()->Cancel( | 294 file_system_context->operation_runner()->Cancel( |
295 operation_id, base::Bind(&OnCopyCancelled)); | 295 operation_id, base::Bind(&OnCopyCancelled)); |
296 } | 296 } |
297 | 297 |
298 } // namespace | 298 } // namespace |
299 | 299 |
300 FileBrowserPrivateRequestFileSystemFunction:: | |
301 FileBrowserPrivateRequestFileSystemFunction() { | |
302 } | |
303 | |
304 FileBrowserPrivateRequestFileSystemFunction:: | |
305 ~FileBrowserPrivateRequestFileSystemFunction() { | |
306 } | |
307 | |
308 void FileBrowserPrivateRequestFileSystemFunction::DidOpenFileSystem( | 300 void FileBrowserPrivateRequestFileSystemFunction::DidOpenFileSystem( |
309 scoped_refptr<fileapi::FileSystemContext> file_system_context, | 301 scoped_refptr<fileapi::FileSystemContext> file_system_context, |
310 base::PlatformFileError result, | 302 base::PlatformFileError result, |
311 const std::string& name, | 303 const std::string& name, |
312 const GURL& root_url) { | 304 const GURL& root_url) { |
313 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 305 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
314 | 306 |
315 if (result != base::PLATFORM_FILE_OK) { | 307 if (result != base::PLATFORM_FILE_OK) { |
316 DidFail(result); | 308 DidFail(result); |
317 return; | 309 return; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 origin_url, | 408 origin_url, |
417 fileapi::kFileSystemTypeExternal, | 409 fileapi::kFileSystemTypeExternal, |
418 fileapi::OPEN_FILE_SYSTEM_FAIL_IF_NONEXISTENT, | 410 fileapi::OPEN_FILE_SYSTEM_FAIL_IF_NONEXISTENT, |
419 base::Bind(&FileBrowserPrivateRequestFileSystemFunction:: | 411 base::Bind(&FileBrowserPrivateRequestFileSystemFunction:: |
420 DidOpenFileSystem, | 412 DidOpenFileSystem, |
421 this, | 413 this, |
422 file_system_context)); | 414 file_system_context)); |
423 return true; | 415 return true; |
424 } | 416 } |
425 | 417 |
426 FileWatchFunctionBase::FileWatchFunctionBase() { | |
427 } | |
428 | |
429 FileWatchFunctionBase::~FileWatchFunctionBase() { | |
430 } | |
431 | |
432 void FileWatchFunctionBase::Respond(bool success) { | 418 void FileWatchFunctionBase::Respond(bool success) { |
433 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 419 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
434 | 420 |
435 SetResult(Value::CreateBooleanValue(success)); | 421 SetResult(Value::CreateBooleanValue(success)); |
436 SendResponse(success); | 422 SendResponse(success); |
437 } | 423 } |
438 | 424 |
439 bool FileWatchFunctionBase::RunImpl() { | 425 bool FileWatchFunctionBase::RunImpl() { |
440 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 426 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
441 | 427 |
(...skipping 14 matching lines...) Expand all Loading... |
456 base::FilePath virtual_path = file_watch_url.virtual_path(); | 442 base::FilePath virtual_path = file_watch_url.virtual_path(); |
457 if (local_path.empty()) { | 443 if (local_path.empty()) { |
458 Respond(false); | 444 Respond(false); |
459 return true; | 445 return true; |
460 } | 446 } |
461 PerformFileWatchOperation(local_path, virtual_path, extension_id()); | 447 PerformFileWatchOperation(local_path, virtual_path, extension_id()); |
462 | 448 |
463 return true; | 449 return true; |
464 } | 450 } |
465 | 451 |
466 FileBrowserPrivateAddFileWatchFunction:: | |
467 FileBrowserPrivateAddFileWatchFunction() { | |
468 } | |
469 | |
470 FileBrowserPrivateAddFileWatchFunction:: | |
471 ~FileBrowserPrivateAddFileWatchFunction() { | |
472 } | |
473 | |
474 void FileBrowserPrivateAddFileWatchFunction::PerformFileWatchOperation( | 452 void FileBrowserPrivateAddFileWatchFunction::PerformFileWatchOperation( |
475 const base::FilePath& local_path, | 453 const base::FilePath& local_path, |
476 const base::FilePath& virtual_path, | 454 const base::FilePath& virtual_path, |
477 const std::string& extension_id) { | 455 const std::string& extension_id) { |
478 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 456 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
479 | 457 |
480 file_manager::EventRouter* event_router = | 458 file_manager::EventRouter* event_router = |
481 file_manager::FileBrowserPrivateAPI::Get(profile_)->event_router(); | 459 file_manager::FileBrowserPrivateAPI::Get(profile_)->event_router(); |
482 event_router->AddFileWatch( | 460 event_router->AddFileWatch( |
483 local_path, | 461 local_path, |
484 virtual_path, | 462 virtual_path, |
485 extension_id, | 463 extension_id, |
486 base::Bind(&FileBrowserPrivateAddFileWatchFunction::Respond, this)); | 464 base::Bind(&FileBrowserPrivateAddFileWatchFunction::Respond, this)); |
487 } | 465 } |
488 | 466 |
489 FileBrowserPrivateRemoveFileWatchFunction:: | |
490 FileBrowserPrivateRemoveFileWatchFunction() { | |
491 } | |
492 | |
493 FileBrowserPrivateRemoveFileWatchFunction:: | |
494 ~FileBrowserPrivateRemoveFileWatchFunction() { | |
495 } | |
496 | |
497 void FileBrowserPrivateRemoveFileWatchFunction::PerformFileWatchOperation( | 467 void FileBrowserPrivateRemoveFileWatchFunction::PerformFileWatchOperation( |
498 const base::FilePath& local_path, | 468 const base::FilePath& local_path, |
499 const base::FilePath& unused, | 469 const base::FilePath& unused, |
500 const std::string& extension_id) { | 470 const std::string& extension_id) { |
501 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 471 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
502 | 472 |
503 file_manager::EventRouter* event_router = | 473 file_manager::EventRouter* event_router = |
504 file_manager::FileBrowserPrivateAPI::Get(profile_)->event_router(); | 474 file_manager::FileBrowserPrivateAPI::Get(profile_)->event_router(); |
505 event_router->RemoveFileWatch(local_path, extension_id); | 475 event_router->RemoveFileWatch(local_path, extension_id); |
506 Respond(true); | 476 Respond(true); |
507 } | 477 } |
508 | 478 |
509 FileBrowserPrivateSetLastModifiedFunction:: | |
510 FileBrowserPrivateSetLastModifiedFunction() { | |
511 } | |
512 | |
513 FileBrowserPrivateSetLastModifiedFunction:: | |
514 ~FileBrowserPrivateSetLastModifiedFunction() { | |
515 } | |
516 | |
517 bool FileBrowserPrivateSetLastModifiedFunction::RunImpl() { | 479 bool FileBrowserPrivateSetLastModifiedFunction::RunImpl() { |
518 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 480 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
519 | 481 using extensions::api::file_browser_private::SetLastModified::Params; |
520 if (args_->GetSize() != 2) { | 482 const scoped_ptr<Params> params(Params::Create(*args_)); |
521 return false; | 483 EXTENSION_FUNCTION_VALIDATE(params); |
522 } | |
523 | |
524 std::string file_url; | |
525 if (!args_->GetString(0, &file_url)) | |
526 return false; | |
527 | |
528 std::string timestamp; | |
529 if (!args_->GetString(1, ×tamp)) | |
530 return false; | |
531 | 484 |
532 base::FilePath local_path = file_manager::util::GetLocalPathFromURL( | 485 base::FilePath local_path = file_manager::util::GetLocalPathFromURL( |
533 render_view_host(), profile(), GURL(file_url)); | 486 render_view_host(), profile(), GURL(params->file_url)); |
534 | 487 |
535 base::PostTaskAndReplyWithResult( | 488 base::PostTaskAndReplyWithResult( |
536 BrowserThread::GetBlockingPool(), | 489 BrowserThread::GetBlockingPool(), |
537 FROM_HERE, | 490 FROM_HERE, |
538 base::Bind(&SetLastModifiedOnBlockingPool, | 491 base::Bind(&SetLastModifiedOnBlockingPool, |
539 local_path, | 492 local_path, |
540 strtoul(timestamp.c_str(), NULL, 0)), | 493 strtoul(params->last_modified.c_str(), NULL, 0)), |
541 base::Bind(&FileBrowserPrivateSetLastModifiedFunction::SendResponse, | 494 base::Bind(&FileBrowserPrivateSetLastModifiedFunction::SendResponse, |
542 this)); | 495 this)); |
543 return true; | 496 return true; |
544 } | 497 } |
545 | 498 |
546 FileBrowserPrivateGetSizeStatsFunction:: | |
547 FileBrowserPrivateGetSizeStatsFunction() { | |
548 } | |
549 | |
550 FileBrowserPrivateGetSizeStatsFunction:: | |
551 ~FileBrowserPrivateGetSizeStatsFunction() { | |
552 } | |
553 | |
554 bool FileBrowserPrivateGetSizeStatsFunction::RunImpl() { | 499 bool FileBrowserPrivateGetSizeStatsFunction::RunImpl() { |
555 if (args_->GetSize() != 1) { | 500 using extensions::api::file_browser_private::GetSizeStats::Params; |
556 return false; | 501 const scoped_ptr<Params> params(Params::Create(*args_)); |
557 } | 502 EXTENSION_FUNCTION_VALIDATE(params); |
558 | |
559 std::string mount_url; | |
560 if (!args_->GetString(0, &mount_url)) | |
561 return false; | |
562 | 503 |
563 base::FilePath file_path = file_manager::util::GetLocalPathFromURL( | 504 base::FilePath file_path = file_manager::util::GetLocalPathFromURL( |
564 render_view_host(), profile(), GURL(mount_url)); | 505 render_view_host(), profile(), GURL(params->mount_path)); |
565 if (file_path.empty()) | 506 if (file_path.empty()) |
566 return false; | 507 return false; |
567 | 508 |
568 if (file_path == drive::util::GetDriveMountPointPath()) { | 509 if (file_path == drive::util::GetDriveMountPointPath()) { |
569 drive::FileSystemInterface* file_system = | 510 drive::FileSystemInterface* file_system = |
570 drive::util::GetFileSystemByProfile(profile()); | 511 drive::util::GetFileSystemByProfile(profile()); |
571 if (!file_system) { | 512 if (!file_system) { |
572 // |file_system| is NULL if Drive is disabled. | 513 // |file_system| is NULL if Drive is disabled. |
573 // If stats couldn't be gotten for drive, result should be left | 514 // If stats couldn't be gotten for drive, result should be left |
574 // undefined. See comments in GetDriveAvailableSpaceCallback(). | 515 // undefined. See comments in GetDriveAvailableSpaceCallback(). |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 const uint64* remaining_size) { | 559 const uint64* remaining_size) { |
619 base::DictionaryValue* sizes = new base::DictionaryValue(); | 560 base::DictionaryValue* sizes = new base::DictionaryValue(); |
620 SetResult(sizes); | 561 SetResult(sizes); |
621 | 562 |
622 sizes->SetDouble("totalSize", static_cast<double>(*total_size)); | 563 sizes->SetDouble("totalSize", static_cast<double>(*total_size)); |
623 sizes->SetDouble("remainingSize", static_cast<double>(*remaining_size)); | 564 sizes->SetDouble("remainingSize", static_cast<double>(*remaining_size)); |
624 | 565 |
625 SendResponse(true); | 566 SendResponse(true); |
626 } | 567 } |
627 | 568 |
628 FileBrowserPrivateGetVolumeMetadataFunction:: | |
629 FileBrowserPrivateGetVolumeMetadataFunction() { | |
630 } | |
631 | |
632 FileBrowserPrivateGetVolumeMetadataFunction:: | |
633 ~FileBrowserPrivateGetVolumeMetadataFunction() { | |
634 } | |
635 | |
636 bool FileBrowserPrivateGetVolumeMetadataFunction::RunImpl() { | 569 bool FileBrowserPrivateGetVolumeMetadataFunction::RunImpl() { |
637 if (args_->GetSize() != 1) { | 570 using extensions::api::file_browser_private::GetVolumeMetadata::Params; |
638 error_ = "Invalid argument count"; | 571 const scoped_ptr<Params> params(Params::Create(*args_)); |
639 return false; | 572 EXTENSION_FUNCTION_VALIDATE(params); |
640 } | |
641 | |
642 std::string volume_mount_url; | |
643 if (!args_->GetString(0, &volume_mount_url)) { | |
644 NOTREACHED(); | |
645 return false; | |
646 } | |
647 | 573 |
648 base::FilePath file_path = file_manager::util::GetLocalPathFromURL( | 574 base::FilePath file_path = file_manager::util::GetLocalPathFromURL( |
649 render_view_host(), profile(), GURL(volume_mount_url)); | 575 render_view_host(), profile(), GURL(params->mount_url)); |
650 if (file_path.empty()) { | 576 if (file_path.empty()) { |
651 error_ = "Invalid mount path."; | 577 error_ = "Invalid mount path."; |
652 return false; | 578 return false; |
653 } | 579 } |
654 | 580 |
655 results_.reset(); | 581 results_.reset(); |
656 | 582 |
657 base::FilePath home_path; | 583 base::FilePath home_path; |
658 // TODO(hidehiko): Return the volume info for Drive File System. | 584 // TODO(hidehiko): Return the volume info for Drive File System. |
659 if (PathService::Get(base::DIR_HOME, &home_path) && | 585 if (PathService::Get(base::DIR_HOME, &home_path) && |
660 file_path == home_path.AppendASCII("Downloads")) { | 586 file_path == home_path.AppendASCII("Downloads")) { |
661 // Return simple (fake) volume metadata for Downloads volume. | 587 // Return simple (fake) volume metadata for Downloads volume. |
662 SetResult(CreateDownloadsVolumeMetadata()); | 588 SetResult(CreateDownloadsVolumeMetadata()); |
663 } else { | 589 } else { |
664 const DiskMountManager::Disk* volume = GetVolumeAsDisk(file_path.value()); | 590 const DiskMountManager::Disk* volume = GetVolumeAsDisk(file_path.value()); |
665 if (volume) | 591 if (volume) |
666 SetResult(CreateValueFromDisk(profile_, extension_->id(), volume)); | 592 SetResult(CreateValueFromDisk(profile_, extension_->id(), volume)); |
667 } | 593 } |
668 | 594 |
669 SendResponse(true); | 595 SendResponse(true); |
670 return true; | 596 return true; |
671 } | 597 } |
672 | 598 |
673 FileBrowserPrivateValidatePathNameLengthFunction:: | |
674 FileBrowserPrivateValidatePathNameLengthFunction() { | |
675 } | |
676 | |
677 FileBrowserPrivateValidatePathNameLengthFunction:: | |
678 ~FileBrowserPrivateValidatePathNameLengthFunction() { | |
679 } | |
680 | |
681 bool FileBrowserPrivateValidatePathNameLengthFunction::RunImpl() { | 599 bool FileBrowserPrivateValidatePathNameLengthFunction::RunImpl() { |
682 std::string parent_url; | 600 using extensions::api::file_browser_private::ValidatePathNameLength::Params; |
683 if (!args_->GetString(0, &parent_url)) | 601 const scoped_ptr<Params> params(Params::Create(*args_)); |
684 return false; | 602 EXTENSION_FUNCTION_VALIDATE(params); |
685 | |
686 std::string name; | |
687 if (!args_->GetString(1, &name)) | |
688 return false; | |
689 | 603 |
690 scoped_refptr<fileapi::FileSystemContext> file_system_context = | 604 scoped_refptr<fileapi::FileSystemContext> file_system_context = |
691 file_manager::util::GetFileSystemContextForRenderViewHost( | 605 file_manager::util::GetFileSystemContextForRenderViewHost( |
692 profile(), render_view_host()); | 606 profile(), render_view_host()); |
693 | 607 |
694 fileapi::FileSystemURL filesystem_url( | 608 fileapi::FileSystemURL filesystem_url( |
695 file_system_context->CrackURL(GURL(parent_url))); | 609 file_system_context->CrackURL(GURL(params->parent_directory_url))); |
696 if (!chromeos::FileSystemBackend::CanHandleURL(filesystem_url)) | 610 if (!chromeos::FileSystemBackend::CanHandleURL(filesystem_url)) |
697 return false; | 611 return false; |
698 | 612 |
699 // No explicit limit on the length of Drive file names. | 613 // No explicit limit on the length of Drive file names. |
700 if (filesystem_url.type() == fileapi::kFileSystemTypeDrive) { | 614 if (filesystem_url.type() == fileapi::kFileSystemTypeDrive) { |
701 SetResult(new base::FundamentalValue(true)); | 615 SetResult(new base::FundamentalValue(true)); |
702 SendResponse(true); | 616 SendResponse(true); |
703 return true; | 617 return true; |
704 } | 618 } |
705 | 619 |
706 base::PostTaskAndReplyWithResult( | 620 base::PostTaskAndReplyWithResult( |
707 BrowserThread::GetBlockingPool(), | 621 BrowserThread::GetBlockingPool(), |
708 FROM_HERE, | 622 FROM_HERE, |
709 base::Bind(&GetFileNameMaxLengthOnBlockingPool, | 623 base::Bind(&GetFileNameMaxLengthOnBlockingPool, |
710 filesystem_url.path().AsUTF8Unsafe()), | 624 filesystem_url.path().AsUTF8Unsafe()), |
711 base::Bind(&FileBrowserPrivateValidatePathNameLengthFunction:: | 625 base::Bind(&FileBrowserPrivateValidatePathNameLengthFunction:: |
712 OnFilePathLimitRetrieved, | 626 OnFilePathLimitRetrieved, |
713 this, name.size())); | 627 this, params->name.size())); |
714 return true; | 628 return true; |
715 } | 629 } |
716 | 630 |
717 void FileBrowserPrivateValidatePathNameLengthFunction::OnFilePathLimitRetrieved( | 631 void FileBrowserPrivateValidatePathNameLengthFunction::OnFilePathLimitRetrieved( |
718 size_t current_length, | 632 size_t current_length, |
719 size_t max_length) { | 633 size_t max_length) { |
720 SetResult(new base::FundamentalValue(current_length <= max_length)); | 634 SetResult(new base::FundamentalValue(current_length <= max_length)); |
721 SendResponse(true); | 635 SendResponse(true); |
722 } | 636 } |
723 | 637 |
724 FileBrowserPrivateFormatDeviceFunction:: | |
725 FileBrowserPrivateFormatDeviceFunction() { | |
726 } | |
727 | |
728 FileBrowserPrivateFormatDeviceFunction:: | |
729 ~FileBrowserPrivateFormatDeviceFunction() { | |
730 } | |
731 | |
732 bool FileBrowserPrivateFormatDeviceFunction::RunImpl() { | 638 bool FileBrowserPrivateFormatDeviceFunction::RunImpl() { |
733 if (args_->GetSize() != 1) { | 639 using extensions::api::file_browser_private::FormatDevice::Params; |
734 return false; | 640 const scoped_ptr<Params> params(Params::Create(*args_)); |
735 } | 641 EXTENSION_FUNCTION_VALIDATE(params); |
736 | |
737 std::string volume_file_url; | |
738 if (!args_->GetString(0, &volume_file_url)) { | |
739 NOTREACHED(); | |
740 return false; | |
741 } | |
742 | 642 |
743 base::FilePath file_path = file_manager::util::GetLocalPathFromURL( | 643 base::FilePath file_path = file_manager::util::GetLocalPathFromURL( |
744 render_view_host(), profile(), GURL(volume_file_url)); | 644 render_view_host(), profile(), GURL(params->mount_path)); |
745 if (file_path.empty()) | 645 if (file_path.empty()) |
746 return false; | 646 return false; |
747 | 647 |
748 DiskMountManager::GetInstance()->FormatMountedDevice(file_path.value()); | 648 DiskMountManager::GetInstance()->FormatMountedDevice(file_path.value()); |
749 SendResponse(true); | 649 SendResponse(true); |
750 return true; | 650 return true; |
751 } | 651 } |
752 | 652 |
753 FileBrowserPrivateStartCopyFunction::FileBrowserPrivateStartCopyFunction() { | |
754 } | |
755 | |
756 FileBrowserPrivateStartCopyFunction::~FileBrowserPrivateStartCopyFunction() { | |
757 } | |
758 | |
759 bool FileBrowserPrivateStartCopyFunction::RunImpl() { | 653 bool FileBrowserPrivateStartCopyFunction::RunImpl() { |
760 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 654 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
761 | 655 |
762 using extensions::api::file_browser_private::StartCopy::Params; | 656 using extensions::api::file_browser_private::StartCopy::Params; |
763 const scoped_ptr<Params> params(Params::Create(*args_)); | 657 const scoped_ptr<Params> params(Params::Create(*args_)); |
764 EXTENSION_FUNCTION_VALIDATE(params); | 658 EXTENSION_FUNCTION_VALIDATE(params); |
765 | 659 |
766 if (params->source_url.empty() || params->parent.empty() || | 660 if (params->source_url.empty() || params->parent.empty() || |
767 params->new_name.empty()) { | 661 params->new_name.empty()) { |
768 error_ = base::IntToString(fileapi::PlatformFileErrorToWebFileError( | 662 error_ = base::IntToString(fileapi::PlatformFileErrorToWebFileError( |
(...skipping 26 matching lines...) Expand all Loading... |
795 } | 689 } |
796 | 690 |
797 void FileBrowserPrivateStartCopyFunction::RunAfterStartCopy( | 691 void FileBrowserPrivateStartCopyFunction::RunAfterStartCopy( |
798 int operation_id) { | 692 int operation_id) { |
799 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 693 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
800 | 694 |
801 SetResult(Value::CreateIntegerValue(operation_id)); | 695 SetResult(Value::CreateIntegerValue(operation_id)); |
802 SendResponse(true); | 696 SendResponse(true); |
803 } | 697 } |
804 | 698 |
805 FileBrowserPrivateCancelCopyFunction::FileBrowserPrivateCancelCopyFunction() { | |
806 } | |
807 | |
808 FileBrowserPrivateCancelCopyFunction::~FileBrowserPrivateCancelCopyFunction() { | |
809 } | |
810 | |
811 bool FileBrowserPrivateCancelCopyFunction::RunImpl() { | 699 bool FileBrowserPrivateCancelCopyFunction::RunImpl() { |
812 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 700 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
813 | 701 |
814 using extensions::api::file_browser_private::CancelCopy::Params; | 702 using extensions::api::file_browser_private::CancelCopy::Params; |
815 const scoped_ptr<Params> params(Params::Create(*args_)); | 703 const scoped_ptr<Params> params(Params::Create(*args_)); |
816 EXTENSION_FUNCTION_VALIDATE(params); | 704 EXTENSION_FUNCTION_VALIDATE(params); |
817 | 705 |
818 scoped_refptr<fileapi::FileSystemContext> file_system_context = | 706 scoped_refptr<fileapi::FileSystemContext> file_system_context = |
819 file_manager::util::GetFileSystemContextForRenderViewHost( | 707 file_manager::util::GetFileSystemContextForRenderViewHost( |
820 profile(), render_view_host()); | 708 profile(), render_view_host()); |
821 | 709 |
822 // We don't much take care about the result of cancellation. | 710 // We don't much take care about the result of cancellation. |
823 BrowserThread::PostTask( | 711 BrowserThread::PostTask( |
824 BrowserThread::IO, | 712 BrowserThread::IO, |
825 FROM_HERE, | 713 FROM_HERE, |
826 base::Bind(&CancelCopyOnIOThread, file_system_context, params->copy_id)); | 714 base::Bind(&CancelCopyOnIOThread, file_system_context, params->copy_id)); |
827 SendResponse(true); | 715 SendResponse(true); |
828 return true; | 716 return true; |
829 } | 717 } |
830 | 718 |
831 } // namespace extensions | 719 } // namespace extensions |
OLD | NEW |