Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc

Issue 257333002: Drive extension functions from ExtensionFunction::Run. The (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comment Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_drive.h" 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_drive.h"
6 6
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 8 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
9 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" 9 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h"
10 #include "chrome/browser/chromeos/file_manager/file_tasks.h" 10 #include "chrome/browser/chromeos/file_manager/file_tasks.h"
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 342
343 } // namespace 343 } // namespace
344 344
345 FileBrowserPrivateGetDriveEntryPropertiesFunction:: 345 FileBrowserPrivateGetDriveEntryPropertiesFunction::
346 FileBrowserPrivateGetDriveEntryPropertiesFunction() 346 FileBrowserPrivateGetDriveEntryPropertiesFunction()
347 : processed_count_(0) {} 347 : processed_count_(0) {}
348 348
349 FileBrowserPrivateGetDriveEntryPropertiesFunction:: 349 FileBrowserPrivateGetDriveEntryPropertiesFunction::
350 ~FileBrowserPrivateGetDriveEntryPropertiesFunction() {} 350 ~FileBrowserPrivateGetDriveEntryPropertiesFunction() {}
351 351
352 bool FileBrowserPrivateGetDriveEntryPropertiesFunction::RunImpl() { 352 bool FileBrowserPrivateGetDriveEntryPropertiesFunction::RunAsync() {
353 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 353 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
354 354
355 using api::file_browser_private::GetDriveEntryProperties::Params; 355 using api::file_browser_private::GetDriveEntryProperties::Params;
356 const scoped_ptr<Params> params(Params::Create(*args_)); 356 const scoped_ptr<Params> params(Params::Create(*args_));
357 EXTENSION_FUNCTION_VALIDATE(params); 357 EXTENSION_FUNCTION_VALIDATE(params);
358 358
359 properties_list_.resize(params->file_urls.size()); 359 properties_list_.resize(params->file_urls.size());
360 360
361 for (size_t i = 0; i < params->file_urls.size(); i++) { 361 for (size_t i = 0; i < params->file_urls.size(); i++) {
362 const GURL url = GURL(params->file_urls[i]); 362 const GURL url = GURL(params->file_urls[i]);
(...skipping 20 matching lines...) Expand all
383 383
384 processed_count_++; 384 processed_count_++;
385 if (processed_count_ < properties_list_.size()) 385 if (processed_count_ < properties_list_.size())
386 return; 386 return;
387 387
388 results_ = extensions::api::file_browser_private::GetDriveEntryProperties:: 388 results_ = extensions::api::file_browser_private::GetDriveEntryProperties::
389 Results::Create(properties_list_); 389 Results::Create(properties_list_);
390 SendResponse(true); 390 SendResponse(true);
391 } 391 }
392 392
393 bool FileBrowserPrivatePinDriveFileFunction::RunImpl() { 393 bool FileBrowserPrivatePinDriveFileFunction::RunAsync() {
394 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 394 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
395 395
396 using extensions::api::file_browser_private::PinDriveFile::Params; 396 using extensions::api::file_browser_private::PinDriveFile::Params;
397 const scoped_ptr<Params> params(Params::Create(*args_)); 397 const scoped_ptr<Params> params(Params::Create(*args_));
398 EXTENSION_FUNCTION_VALIDATE(params); 398 EXTENSION_FUNCTION_VALIDATE(params);
399 399
400 drive::FileSystemInterface* const file_system = 400 drive::FileSystemInterface* const file_system =
401 drive::util::GetFileSystemByProfile(GetProfile()); 401 drive::util::GetFileSystemByProfile(GetProfile());
402 if (!file_system) // |file_system| is NULL if Drive is disabled. 402 if (!file_system) // |file_system| is NULL if Drive is disabled.
403 return false; 403 return false;
(...skipping 26 matching lines...) Expand all
430 } 430 }
431 431
432 FileBrowserPrivateGetDriveFilesFunction:: 432 FileBrowserPrivateGetDriveFilesFunction::
433 FileBrowserPrivateGetDriveFilesFunction() { 433 FileBrowserPrivateGetDriveFilesFunction() {
434 } 434 }
435 435
436 FileBrowserPrivateGetDriveFilesFunction:: 436 FileBrowserPrivateGetDriveFilesFunction::
437 ~FileBrowserPrivateGetDriveFilesFunction() { 437 ~FileBrowserPrivateGetDriveFilesFunction() {
438 } 438 }
439 439
440 bool FileBrowserPrivateGetDriveFilesFunction::RunImpl() { 440 bool FileBrowserPrivateGetDriveFilesFunction::RunAsync() {
441 using extensions::api::file_browser_private::GetDriveFiles::Params; 441 using extensions::api::file_browser_private::GetDriveFiles::Params;
442 const scoped_ptr<Params> params(Params::Create(*args_)); 442 const scoped_ptr<Params> params(Params::Create(*args_));
443 EXTENSION_FUNCTION_VALIDATE(params); 443 EXTENSION_FUNCTION_VALIDATE(params);
444 444
445 // Convert the list of strings to a list of GURLs. 445 // Convert the list of strings to a list of GURLs.
446 for (size_t i = 0; i < params->file_urls.size(); ++i) { 446 for (size_t i = 0; i < params->file_urls.size(); ++i) {
447 const base::FilePath path = file_manager::util::GetLocalPathFromURL( 447 const base::FilePath path = file_manager::util::GetLocalPathFromURL(
448 render_view_host(), GetProfile(), GURL(params->file_urls[i])); 448 render_view_host(), GetProfile(), GURL(params->file_urls[i]));
449 DCHECK(drive::util::IsUnderDriveMountPoint(path)); 449 DCHECK(drive::util::IsUnderDriveMountPoint(path));
450 base::FilePath drive_path = drive::util::ExtractDrivePath(path); 450 base::FilePath drive_path = drive::util::ExtractDrivePath(path);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 DVLOG(1) << "Failed to get " << drive_path.value() 496 DVLOG(1) << "Failed to get " << drive_path.value()
497 << " with error code: " << error; 497 << " with error code: " << error;
498 } 498 }
499 499
500 remaining_drive_paths_.pop(); 500 remaining_drive_paths_.pop();
501 501
502 // Start getting the next file. 502 // Start getting the next file.
503 GetFileOrSendResponse(); 503 GetFileOrSendResponse();
504 } 504 }
505 505
506 bool FileBrowserPrivateCancelFileTransfersFunction::RunImpl() { 506 bool FileBrowserPrivateCancelFileTransfersFunction::RunAsync() {
507 using extensions::api::file_browser_private::CancelFileTransfers::Params; 507 using extensions::api::file_browser_private::CancelFileTransfers::Params;
508 const scoped_ptr<Params> params(Params::Create(*args_)); 508 const scoped_ptr<Params> params(Params::Create(*args_));
509 EXTENSION_FUNCTION_VALIDATE(params); 509 EXTENSION_FUNCTION_VALIDATE(params);
510 510
511 drive::DriveIntegrationService* integration_service = 511 drive::DriveIntegrationService* integration_service =
512 drive::DriveIntegrationServiceFactory::FindForProfile(GetProfile()); 512 drive::DriveIntegrationServiceFactory::FindForProfile(GetProfile());
513 if (!integration_service || !integration_service->IsMounted()) 513 if (!integration_service || !integration_service->IsMounted())
514 return false; 514 return false;
515 515
516 // Create the mapping from file path to job ID. 516 // Create the mapping from file path to job ID.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 // and eliminate this field; it is just returning a copy of the argument. 550 // and eliminate this field; it is just returning a copy of the argument.
551 result->file_url = params->file_urls[i]; 551 result->file_url = params->file_urls[i];
552 responses.push_back(result); 552 responses.push_back(result);
553 } 553 }
554 results_ = api::file_browser_private::CancelFileTransfers::Results::Create( 554 results_ = api::file_browser_private::CancelFileTransfers::Results::Create(
555 responses); 555 responses);
556 SendResponse(true); 556 SendResponse(true);
557 return true; 557 return true;
558 } 558 }
559 559
560 bool FileBrowserPrivateSearchDriveFunction::RunImpl() { 560 bool FileBrowserPrivateSearchDriveFunction::RunAsync() {
561 using extensions::api::file_browser_private::SearchDrive::Params; 561 using extensions::api::file_browser_private::SearchDrive::Params;
562 const scoped_ptr<Params> params(Params::Create(*args_)); 562 const scoped_ptr<Params> params(Params::Create(*args_));
563 EXTENSION_FUNCTION_VALIDATE(params); 563 EXTENSION_FUNCTION_VALIDATE(params);
564 564
565 drive::FileSystemInterface* const file_system = 565 drive::FileSystemInterface* const file_system =
566 drive::util::GetFileSystemByProfile(GetProfile()); 566 drive::util::GetFileSystemByProfile(GetProfile());
567 if (!file_system) { 567 if (!file_system) {
568 // |file_system| is NULL if Drive is disabled. 568 // |file_system| is NULL if Drive is disabled.
569 return false; 569 return false;
570 } 570 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 } 619 }
620 620
621 base::DictionaryValue* result = new base::DictionaryValue(); 621 base::DictionaryValue* result = new base::DictionaryValue();
622 result->Set("entries", entries); 622 result->Set("entries", entries);
623 result->SetString("nextFeed", next_link.spec()); 623 result->SetString("nextFeed", next_link.spec());
624 624
625 SetResult(result); 625 SetResult(result);
626 SendResponse(true); 626 SendResponse(true);
627 } 627 }
628 628
629 bool FileBrowserPrivateSearchDriveMetadataFunction::RunImpl() { 629 bool FileBrowserPrivateSearchDriveMetadataFunction::RunAsync() {
630 using api::file_browser_private::SearchDriveMetadata::Params; 630 using api::file_browser_private::SearchDriveMetadata::Params;
631 const scoped_ptr<Params> params(Params::Create(*args_)); 631 const scoped_ptr<Params> params(Params::Create(*args_));
632 EXTENSION_FUNCTION_VALIDATE(params); 632 EXTENSION_FUNCTION_VALIDATE(params);
633 633
634 drive::EventLogger* logger = file_manager::util::GetLogger(GetProfile()); 634 drive::EventLogger* logger = file_manager::util::GetLogger(GetProfile());
635 if (logger) { 635 if (logger) {
636 logger->Log(logging::LOG_INFO, 636 logger->Log(logging::LOG_INFO,
637 "%s[%d] called. (types: '%s', maxResults: '%d')", 637 "%s[%d] called. (types: '%s', maxResults: '%d')",
638 name().c_str(), 638 name().c_str(),
639 request_id(), 639 request_id(),
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 763
764 results_ = api::file_browser_private::GetDriveConnectionState::Results:: 764 results_ = api::file_browser_private::GetDriveConnectionState::Results::
765 Create(result); 765 Create(result);
766 766
767 drive::EventLogger* logger = file_manager::util::GetLogger(GetProfile()); 767 drive::EventLogger* logger = file_manager::util::GetLogger(GetProfile());
768 if (logger) 768 if (logger)
769 logger->Log(logging::LOG_INFO, "%s succeeded.", name().c_str()); 769 logger->Log(logging::LOG_INFO, "%s succeeded.", name().c_str());
770 return true; 770 return true;
771 } 771 }
772 772
773 bool FileBrowserPrivateRequestAccessTokenFunction::RunImpl() { 773 bool FileBrowserPrivateRequestAccessTokenFunction::RunAsync() {
774 using extensions::api::file_browser_private::RequestAccessToken::Params; 774 using extensions::api::file_browser_private::RequestAccessToken::Params;
775 const scoped_ptr<Params> params(Params::Create(*args_)); 775 const scoped_ptr<Params> params(Params::Create(*args_));
776 EXTENSION_FUNCTION_VALIDATE(params); 776 EXTENSION_FUNCTION_VALIDATE(params);
777 777
778 drive::DriveServiceInterface* const drive_service = 778 drive::DriveServiceInterface* const drive_service =
779 drive::util::GetDriveServiceByProfile(GetProfile()); 779 drive::util::GetDriveServiceByProfile(GetProfile());
780 780
781 if (!drive_service) { 781 if (!drive_service) {
782 // DriveService is not available. 782 // DriveService is not available.
783 SetResult(new base::StringValue("")); 783 SetResult(new base::StringValue(""));
(...skipping 13 matching lines...) Expand all
797 return true; 797 return true;
798 } 798 }
799 799
800 void FileBrowserPrivateRequestAccessTokenFunction::OnAccessTokenFetched( 800 void FileBrowserPrivateRequestAccessTokenFunction::OnAccessTokenFetched(
801 google_apis::GDataErrorCode code, 801 google_apis::GDataErrorCode code,
802 const std::string& access_token) { 802 const std::string& access_token) {
803 SetResult(new base::StringValue(access_token)); 803 SetResult(new base::StringValue(access_token));
804 SendResponse(true); 804 SendResponse(true);
805 } 805 }
806 806
807 bool FileBrowserPrivateGetShareUrlFunction::RunImpl() { 807 bool FileBrowserPrivateGetShareUrlFunction::RunAsync() {
808 using extensions::api::file_browser_private::GetShareUrl::Params; 808 using extensions::api::file_browser_private::GetShareUrl::Params;
809 const scoped_ptr<Params> params(Params::Create(*args_)); 809 const scoped_ptr<Params> params(Params::Create(*args_));
810 EXTENSION_FUNCTION_VALIDATE(params); 810 EXTENSION_FUNCTION_VALIDATE(params);
811 811
812 const base::FilePath path = file_manager::util::GetLocalPathFromURL( 812 const base::FilePath path = file_manager::util::GetLocalPathFromURL(
813 render_view_host(), GetProfile(), GURL(params->url)); 813 render_view_host(), GetProfile(), GURL(params->url));
814 DCHECK(drive::util::IsUnderDriveMountPoint(path)); 814 DCHECK(drive::util::IsUnderDriveMountPoint(path));
815 815
816 const base::FilePath drive_path = drive::util::ExtractDrivePath(path); 816 const base::FilePath drive_path = drive::util::ExtractDrivePath(path);
817 817
(...skipping 17 matching lines...) Expand all
835 if (error != drive::FILE_ERROR_OK) { 835 if (error != drive::FILE_ERROR_OK) {
836 SetError("Share Url for this item is not available."); 836 SetError("Share Url for this item is not available.");
837 SendResponse(false); 837 SendResponse(false);
838 return; 838 return;
839 } 839 }
840 840
841 SetResult(new base::StringValue(share_url.spec())); 841 SetResult(new base::StringValue(share_url.spec()));
842 SendResponse(true); 842 SendResponse(true);
843 } 843 }
844 844
845 bool FileBrowserPrivateRequestDriveShareFunction::RunImpl() { 845 bool FileBrowserPrivateRequestDriveShareFunction::RunAsync() {
846 using extensions::api::file_browser_private::RequestDriveShare::Params; 846 using extensions::api::file_browser_private::RequestDriveShare::Params;
847 const scoped_ptr<Params> params(Params::Create(*args_)); 847 const scoped_ptr<Params> params(Params::Create(*args_));
848 EXTENSION_FUNCTION_VALIDATE(params); 848 EXTENSION_FUNCTION_VALIDATE(params);
849 849
850 const base::FilePath path = file_manager::util::GetLocalPathFromURL( 850 const base::FilePath path = file_manager::util::GetLocalPathFromURL(
851 render_view_host(), GetProfile(), GURL(params->url)); 851 render_view_host(), GetProfile(), GURL(params->url));
852 const base::FilePath drive_path = drive::util::ExtractDrivePath(path); 852 const base::FilePath drive_path = drive::util::ExtractDrivePath(path);
853 Profile* const owner_profile = drive::util::ExtractProfileFromPath(path); 853 Profile* const owner_profile = drive::util::ExtractProfileFromPath(path);
854 854
855 if (!owner_profile) 855 if (!owner_profile)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 this)); 891 this));
892 return true; 892 return true;
893 } 893 }
894 894
895 void FileBrowserPrivateRequestDriveShareFunction::OnAddPermission( 895 void FileBrowserPrivateRequestDriveShareFunction::OnAddPermission(
896 drive::FileError error) { 896 drive::FileError error) {
897 SendResponse(error == drive::FILE_ERROR_OK); 897 SendResponse(error == drive::FILE_ERROR_OK);
898 } 898 }
899 899
900 } // namespace extensions 900 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698