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/statvfs.h> | 7 #include <sys/statvfs.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 320 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
321 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 321 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
322 base::Bind(callback, type)); | 322 base::Bind(callback, type)); |
323 } | 323 } |
324 | 324 |
325 } // namespace | 325 } // namespace |
326 | 326 |
327 void FileWatchFunctionBase::Respond(bool success) { | 327 void FileWatchFunctionBase::Respond(bool success) { |
328 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 328 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
329 | 329 |
330 SetResult(base::MakeUnique<base::FundamentalValue>(success)); | 330 SetResult(base::MakeUnique<base::Value>(success)); |
331 SendResponse(success); | 331 SendResponse(success); |
332 } | 332 } |
333 | 333 |
334 bool FileWatchFunctionBase::RunAsync() { | 334 bool FileWatchFunctionBase::RunAsync() { |
335 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 335 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
336 | 336 |
337 if (!render_frame_host() || !render_frame_host()->GetProcess()) | 337 if (!render_frame_host() || !render_frame_host()->GetProcess()) |
338 return false; | 338 return false; |
339 | 339 |
340 // First param is url of a file to watch. | 340 // First param is url of a file to watch. |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 file_manager::util::GetFileSystemContextForRenderFrameHost( | 560 file_manager::util::GetFileSystemContextForRenderFrameHost( |
561 GetProfile(), render_frame_host()); | 561 GetProfile(), render_frame_host()); |
562 | 562 |
563 const storage::FileSystemURL file_system_url( | 563 const storage::FileSystemURL file_system_url( |
564 file_system_context->CrackURL(GURL(params->parent_url))); | 564 file_system_context->CrackURL(GURL(params->parent_url))); |
565 if (!chromeos::FileSystemBackend::CanHandleURL(file_system_url)) | 565 if (!chromeos::FileSystemBackend::CanHandleURL(file_system_url)) |
566 return false; | 566 return false; |
567 | 567 |
568 // No explicit limit on the length of Drive file names. | 568 // No explicit limit on the length of Drive file names. |
569 if (file_system_url.type() == storage::kFileSystemTypeDrive) { | 569 if (file_system_url.type() == storage::kFileSystemTypeDrive) { |
570 SetResult(base::MakeUnique<base::FundamentalValue>(true)); | 570 SetResult(base::MakeUnique<base::Value>(true)); |
571 SendResponse(true); | 571 SendResponse(true); |
572 return true; | 572 return true; |
573 } | 573 } |
574 | 574 |
575 base::PostTaskWithTraitsAndReplyWithResult( | 575 base::PostTaskWithTraitsAndReplyWithResult( |
576 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( | 576 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( |
577 base::TaskPriority::USER_BLOCKING), | 577 base::TaskPriority::USER_BLOCKING), |
578 base::Bind(&GetFileNameMaxLengthAsync, | 578 base::Bind(&GetFileNameMaxLengthAsync, |
579 file_system_url.path().AsUTF8Unsafe()), | 579 file_system_url.path().AsUTF8Unsafe()), |
580 base::Bind(&FileManagerPrivateInternalValidatePathNameLengthFunction:: | 580 base::Bind(&FileManagerPrivateInternalValidatePathNameLengthFunction:: |
581 OnFilePathLimitRetrieved, | 581 OnFilePathLimitRetrieved, |
582 this, params->name.size())); | 582 this, params->name.size())); |
583 return true; | 583 return true; |
584 } | 584 } |
585 | 585 |
586 void FileManagerPrivateInternalValidatePathNameLengthFunction:: | 586 void FileManagerPrivateInternalValidatePathNameLengthFunction:: |
587 OnFilePathLimitRetrieved(size_t current_length, size_t max_length) { | 587 OnFilePathLimitRetrieved(size_t current_length, size_t max_length) { |
588 SetResult( | 588 SetResult(base::MakeUnique<base::Value>(current_length <= max_length)); |
589 base::MakeUnique<base::FundamentalValue>(current_length <= max_length)); | |
590 SendResponse(true); | 589 SendResponse(true); |
591 } | 590 } |
592 | 591 |
593 bool FileManagerPrivateFormatVolumeFunction::RunAsync() { | 592 bool FileManagerPrivateFormatVolumeFunction::RunAsync() { |
594 using extensions::api::file_manager_private::FormatVolume::Params; | 593 using extensions::api::file_manager_private::FormatVolume::Params; |
595 const std::unique_ptr<Params> params(Params::Create(*args_)); | 594 const std::unique_ptr<Params> params(Params::Create(*args_)); |
596 EXTENSION_FUNCTION_VALIDATE(params); | 595 EXTENSION_FUNCTION_VALIDATE(params); |
597 | 596 |
598 using file_manager::VolumeManager; | 597 using file_manager::VolumeManager; |
599 using file_manager::Volume; | 598 using file_manager::Volume; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 &FileManagerPrivateInternalStartCopyFunction::RunAfterStartCopy, | 738 &FileManagerPrivateInternalStartCopyFunction::RunAfterStartCopy, |
740 this)); | 739 this)); |
741 if (!result) | 740 if (!result) |
742 SendResponse(false); | 741 SendResponse(false); |
743 } | 742 } |
744 | 743 |
745 void FileManagerPrivateInternalStartCopyFunction::RunAfterStartCopy( | 744 void FileManagerPrivateInternalStartCopyFunction::RunAfterStartCopy( |
746 int operation_id) { | 745 int operation_id) { |
747 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 746 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
748 | 747 |
749 SetResult(base::MakeUnique<base::FundamentalValue>(operation_id)); | 748 SetResult(base::MakeUnique<base::Value>(operation_id)); |
750 SendResponse(true); | 749 SendResponse(true); |
751 } | 750 } |
752 | 751 |
753 bool FileManagerPrivateCancelCopyFunction::RunAsync() { | 752 bool FileManagerPrivateCancelCopyFunction::RunAsync() { |
754 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 753 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
755 | 754 |
756 using extensions::api::file_manager_private::CancelCopy::Params; | 755 using extensions::api::file_manager_private::CancelCopy::Params; |
757 const std::unique_ptr<Params> params(Params::Create(*args_)); | 756 const std::unique_ptr<Params> params(Params::Create(*args_)); |
758 EXTENSION_FUNCTION_VALIDATE(params); | 757 EXTENSION_FUNCTION_VALIDATE(params); |
759 | 758 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 list->AppendString( | 946 list->AppendString( |
948 file_manager::util::ConvertDrivePathToFileSystemUrl( | 947 file_manager::util::ConvertDrivePathToFileSystemUrl( |
949 GetProfile(), hashAndPath.path, extension_id()).spec()); | 948 GetProfile(), hashAndPath.path, extension_id()).spec()); |
950 } | 949 } |
951 SetResult(std::move(result)); | 950 SetResult(std::move(result)); |
952 SendResponse(true); | 951 SendResponse(true); |
953 } | 952 } |
954 | 953 |
955 ExtensionFunction::ResponseAction | 954 ExtensionFunction::ResponseAction |
956 FileManagerPrivateIsUMAEnabledFunction::Run() { | 955 FileManagerPrivateIsUMAEnabledFunction::Run() { |
957 return RespondNow(OneArgument(base::MakeUnique<base::FundamentalValue>( | 956 return RespondNow(OneArgument(base::MakeUnique<base::Value>( |
958 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled()))); | 957 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled()))); |
959 } | 958 } |
960 | 959 |
961 FileManagerPrivateInternalSetEntryTagFunction:: | 960 FileManagerPrivateInternalSetEntryTagFunction:: |
962 FileManagerPrivateInternalSetEntryTagFunction() | 961 FileManagerPrivateInternalSetEntryTagFunction() |
963 : chrome_details_(this) {} | 962 : chrome_details_(this) {} |
964 | 963 |
965 ExtensionFunction::ResponseAction | 964 ExtensionFunction::ResponseAction |
966 FileManagerPrivateInternalSetEntryTagFunction::Run() { | 965 FileManagerPrivateInternalSetEntryTagFunction::Run() { |
967 using extensions::api::file_manager_private_internal::SetEntryTag::Params; | 966 using extensions::api::file_manager_private_internal::SetEntryTag::Params; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 base::TaskPriority::USER_VISIBLE), | 1044 base::TaskPriority::USER_VISIBLE), |
1046 base::Bind(&base::ComputeDirectorySize, root_path), | 1045 base::Bind(&base::ComputeDirectorySize, root_path), |
1047 base::Bind(&FileManagerPrivateInternalGetDirectorySizeFunction:: | 1046 base::Bind(&FileManagerPrivateInternalGetDirectorySizeFunction:: |
1048 OnDirectorySizeRetrieved, | 1047 OnDirectorySizeRetrieved, |
1049 this)); | 1048 this)); |
1050 return true; | 1049 return true; |
1051 } | 1050 } |
1052 | 1051 |
1053 void FileManagerPrivateInternalGetDirectorySizeFunction:: | 1052 void FileManagerPrivateInternalGetDirectorySizeFunction:: |
1054 OnDirectorySizeRetrieved(int64_t size) { | 1053 OnDirectorySizeRetrieved(int64_t size) { |
1055 SetResult( | 1054 SetResult(base::MakeUnique<base::Value>(static_cast<double>(size))); |
1056 base::MakeUnique<base::FundamentalValue>(static_cast<double>(size))); | |
1057 SendResponse(true); | 1055 SendResponse(true); |
1058 } | 1056 } |
1059 | 1057 |
1060 } // namespace extensions | 1058 } // namespace extensions |
OLD | NEW |