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 <set> | 10 #include <set> |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 ->GrantCreateReadWriteFile(render_frame_host()->GetProcess()->GetID(), | 302 ->GrantCreateReadWriteFile(render_frame_host()->GetProcess()->GetID(), |
303 file_system_url.path()); | 303 file_system_url.path()); |
304 } | 304 } |
305 } | 305 } |
306 return RespondNow(NoArguments()); | 306 return RespondNow(NoArguments()); |
307 } | 307 } |
308 | 308 |
309 void FileWatchFunctionBase::Respond(bool success) { | 309 void FileWatchFunctionBase::Respond(bool success) { |
310 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 310 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
311 | 311 |
312 SetResult(base::MakeUnique<base::FundamentalValue>(success)); | 312 SetResult(base::MakeUnique<base::Value>(success)); |
313 SendResponse(success); | 313 SendResponse(success); |
314 } | 314 } |
315 | 315 |
316 bool FileWatchFunctionBase::RunAsync() { | 316 bool FileWatchFunctionBase::RunAsync() { |
317 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 317 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
318 | 318 |
319 if (!render_frame_host() || !render_frame_host()->GetProcess()) | 319 if (!render_frame_host() || !render_frame_host()->GetProcess()) |
320 return false; | 320 return false; |
321 | 321 |
322 // First param is url of a file to watch. | 322 // First param is url of a file to watch. |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 file_manager::util::GetFileSystemContextForRenderFrameHost( | 508 file_manager::util::GetFileSystemContextForRenderFrameHost( |
509 GetProfile(), render_frame_host()); | 509 GetProfile(), render_frame_host()); |
510 | 510 |
511 const storage::FileSystemURL file_system_url( | 511 const storage::FileSystemURL file_system_url( |
512 file_system_context->CrackURL(GURL(params->parent_url))); | 512 file_system_context->CrackURL(GURL(params->parent_url))); |
513 if (!chromeos::FileSystemBackend::CanHandleURL(file_system_url)) | 513 if (!chromeos::FileSystemBackend::CanHandleURL(file_system_url)) |
514 return false; | 514 return false; |
515 | 515 |
516 // No explicit limit on the length of Drive file names. | 516 // No explicit limit on the length of Drive file names. |
517 if (file_system_url.type() == storage::kFileSystemTypeDrive) { | 517 if (file_system_url.type() == storage::kFileSystemTypeDrive) { |
518 SetResult(base::MakeUnique<base::FundamentalValue>(true)); | 518 SetResult(base::MakeUnique<base::Value>(true)); |
519 SendResponse(true); | 519 SendResponse(true); |
520 return true; | 520 return true; |
521 } | 521 } |
522 | 522 |
523 base::PostTaskAndReplyWithResult( | 523 base::PostTaskAndReplyWithResult( |
524 BrowserThread::GetBlockingPool(), FROM_HERE, | 524 BrowserThread::GetBlockingPool(), FROM_HERE, |
525 base::Bind(&GetFileNameMaxLengthOnBlockingPool, | 525 base::Bind(&GetFileNameMaxLengthOnBlockingPool, |
526 file_system_url.path().AsUTF8Unsafe()), | 526 file_system_url.path().AsUTF8Unsafe()), |
527 base::Bind(&FileManagerPrivateInternalValidatePathNameLengthFunction:: | 527 base::Bind(&FileManagerPrivateInternalValidatePathNameLengthFunction:: |
528 OnFilePathLimitRetrieved, | 528 OnFilePathLimitRetrieved, |
529 this, params->name.size())); | 529 this, params->name.size())); |
530 return true; | 530 return true; |
531 } | 531 } |
532 | 532 |
533 void FileManagerPrivateInternalValidatePathNameLengthFunction:: | 533 void FileManagerPrivateInternalValidatePathNameLengthFunction:: |
534 OnFilePathLimitRetrieved(size_t current_length, size_t max_length) { | 534 OnFilePathLimitRetrieved(size_t current_length, size_t max_length) { |
535 SetResult( | 535 SetResult(base::MakeUnique<base::Value>(current_length <= max_length)); |
536 base::MakeUnique<base::FundamentalValue>(current_length <= max_length)); | |
537 SendResponse(true); | 536 SendResponse(true); |
538 } | 537 } |
539 | 538 |
540 bool FileManagerPrivateFormatVolumeFunction::RunAsync() { | 539 bool FileManagerPrivateFormatVolumeFunction::RunAsync() { |
541 using extensions::api::file_manager_private::FormatVolume::Params; | 540 using extensions::api::file_manager_private::FormatVolume::Params; |
542 const std::unique_ptr<Params> params(Params::Create(*args_)); | 541 const std::unique_ptr<Params> params(Params::Create(*args_)); |
543 EXTENSION_FUNCTION_VALIDATE(params); | 542 EXTENSION_FUNCTION_VALIDATE(params); |
544 | 543 |
545 using file_manager::VolumeManager; | 544 using file_manager::VolumeManager; |
546 using file_manager::Volume; | 545 using file_manager::Volume; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 &FileManagerPrivateInternalStartCopyFunction::RunAfterStartCopy, | 685 &FileManagerPrivateInternalStartCopyFunction::RunAfterStartCopy, |
687 this)); | 686 this)); |
688 if (!result) | 687 if (!result) |
689 SendResponse(false); | 688 SendResponse(false); |
690 } | 689 } |
691 | 690 |
692 void FileManagerPrivateInternalStartCopyFunction::RunAfterStartCopy( | 691 void FileManagerPrivateInternalStartCopyFunction::RunAfterStartCopy( |
693 int operation_id) { | 692 int operation_id) { |
694 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 693 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
695 | 694 |
696 SetResult(base::MakeUnique<base::FundamentalValue>(operation_id)); | 695 SetResult(base::MakeUnique<base::Value>(operation_id)); |
697 SendResponse(true); | 696 SendResponse(true); |
698 } | 697 } |
699 | 698 |
700 bool FileManagerPrivateCancelCopyFunction::RunAsync() { | 699 bool FileManagerPrivateCancelCopyFunction::RunAsync() { |
701 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 700 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
702 | 701 |
703 using extensions::api::file_manager_private::CancelCopy::Params; | 702 using extensions::api::file_manager_private::CancelCopy::Params; |
704 const std::unique_ptr<Params> params(Params::Create(*args_)); | 703 const std::unique_ptr<Params> params(Params::Create(*args_)); |
705 EXTENSION_FUNCTION_VALIDATE(params); | 704 EXTENSION_FUNCTION_VALIDATE(params); |
706 | 705 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 list->AppendString( | 893 list->AppendString( |
895 file_manager::util::ConvertDrivePathToFileSystemUrl( | 894 file_manager::util::ConvertDrivePathToFileSystemUrl( |
896 GetProfile(), hashAndPath.path, extension_id()).spec()); | 895 GetProfile(), hashAndPath.path, extension_id()).spec()); |
897 } | 896 } |
898 SetResult(std::move(result)); | 897 SetResult(std::move(result)); |
899 SendResponse(true); | 898 SendResponse(true); |
900 } | 899 } |
901 | 900 |
902 ExtensionFunction::ResponseAction | 901 ExtensionFunction::ResponseAction |
903 FileManagerPrivateIsUMAEnabledFunction::Run() { | 902 FileManagerPrivateIsUMAEnabledFunction::Run() { |
904 return RespondNow(OneArgument(base::MakeUnique<base::FundamentalValue>( | 903 return RespondNow(OneArgument(base::MakeUnique<base::Value>( |
905 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled()))); | 904 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled()))); |
906 } | 905 } |
907 | 906 |
908 FileManagerPrivateInternalSetEntryTagFunction:: | 907 FileManagerPrivateInternalSetEntryTagFunction:: |
909 FileManagerPrivateInternalSetEntryTagFunction() | 908 FileManagerPrivateInternalSetEntryTagFunction() |
910 : chrome_details_(this) {} | 909 : chrome_details_(this) {} |
911 | 910 |
912 ExtensionFunction::ResponseAction | 911 ExtensionFunction::ResponseAction |
913 FileManagerPrivateInternalSetEntryTagFunction::Run() { | 912 FileManagerPrivateInternalSetEntryTagFunction::Run() { |
914 using extensions::api::file_manager_private_internal::SetEntryTag::Params; | 913 using extensions::api::file_manager_private_internal::SetEntryTag::Params; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 BrowserThread::GetBlockingPool(), FROM_HERE, | 990 BrowserThread::GetBlockingPool(), FROM_HERE, |
992 base::Bind(&base::ComputeDirectorySize, root_path), | 991 base::Bind(&base::ComputeDirectorySize, root_path), |
993 base::Bind(&FileManagerPrivateInternalGetDirectorySizeFunction:: | 992 base::Bind(&FileManagerPrivateInternalGetDirectorySizeFunction:: |
994 OnDirectorySizeRetrieved, | 993 OnDirectorySizeRetrieved, |
995 this)); | 994 this)); |
996 return true; | 995 return true; |
997 } | 996 } |
998 | 997 |
999 void FileManagerPrivateInternalGetDirectorySizeFunction:: | 998 void FileManagerPrivateInternalGetDirectorySizeFunction:: |
1000 OnDirectorySizeRetrieved(int64_t size) { | 999 OnDirectorySizeRetrieved(int64_t size) { |
1001 SetResult( | 1000 SetResult(base::MakeUnique<base::Value>(static_cast<double>(size))); |
1002 base::MakeUnique<base::FundamentalValue>(static_cast<double>(size))); | |
1003 SendResponse(true); | 1001 SendResponse(true); |
1004 } | 1002 } |
1005 | 1003 |
1006 } // namespace extensions | 1004 } // namespace extensions |
OLD | NEW |