Chromium Code Reviews| Index: components/drive/service/drive_api_service.cc |
| diff --git a/components/drive/service/drive_api_service.cc b/components/drive/service/drive_api_service.cc |
| index 89672e6c0c491e595d97ebeb54b43f31c986971a..da7577c32185046c29030b56292a617158b8a3c3 100644 |
| --- a/components/drive/service/drive_api_service.cc |
| +++ b/components/drive/service/drive_api_service.cc |
| @@ -17,6 +17,7 @@ |
| #include "google_apis/drive/base_requests.h" |
| #include "google_apis/drive/drive_api_parser.h" |
| #include "google_apis/drive/drive_api_requests.h" |
| +#include "google_apis/drive/drive_switches.h" |
| #include "google_apis/drive/files_list_request_runner.h" |
| #include "google_apis/drive/request_sender.h" |
| #include "google_apis/google_api_keys.h" |
| @@ -39,6 +40,7 @@ using google_apis::FileList; |
| using google_apis::FileListCallback; |
| using google_apis::FileResource; |
| using google_apis::FileResourceCallback; |
| +using google_apis::FilesListCorpora; |
| using google_apis::FilesListRequestRunner; |
| using google_apis::GetContentCallback; |
| using google_apis::GetShareUrlCallback; |
| @@ -346,6 +348,10 @@ CancelCallback DriveAPIService::GetAllFileList( |
| request->set_max_results(kMaxNumFilesResourcePerRequest); |
| request->set_q("trashed = false"); // Exclude trashed files. |
| request->set_fields(kFileListFields); |
| + if (google_apis::GetTeamDrivesIntegrationSwitch() == |
| + google_apis::TEAM_DRIVES_INTEGRATION_ENABLED) { |
| + request->set_corpora(google_apis::CORPORA_ALL_TEAM_DRIVES); |
| + } |
| return sender_->StartRequestWithAuthRetry(std::move(request)); |
| } |
| @@ -356,6 +362,14 @@ CancelCallback DriveAPIService::GetFileListInDirectory( |
| DCHECK(!directory_resource_id.empty()); |
| DCHECK(!callback.is_null()); |
| + // TODO(yamaguchi): Use FileListScope::CreateForTeamDrive instead of |
| + // kAllTeamDrives for efficiency. It'll require to add a new parameter to tell |
| + // which team drive the directory resource belongs to. |
| + FilesListCorpora corpora = (google_apis::GetTeamDrivesIntegrationSwitch() == |
| + google_apis::TEAM_DRIVES_INTEGRATION_ENABLED) |
| + ? google_apis::CORPORA_ALL_TEAM_DRIVES |
| + : google_apis::CORPORA_DEFAULT; |
| + |
| // Because children.list method on Drive API v2 returns only the list of |
| // children's references, but we need all file resource list. |
| // So, here we use files.list method instead, with setting parents query. |
| @@ -364,7 +378,7 @@ CancelCallback DriveAPIService::GetFileListInDirectory( |
| // to client side. |
| // We aren't interested in files in trash in this context, neither. |
| return files_list_request_runner_->CreateAndStartWithSizeBackoff( |
| - kMaxNumFilesResourcePerRequest, |
| + kMaxNumFilesResourcePerRequest, corpora, "", |
|
hashimoto
2017/06/02 09:44:46
Use std::string() instead "" to avoid char*->std::
yamaguchi
2017/06/02 12:04:01
Done.
|
| base::StringPrintf( |
| "'%s' in parents and trashed = false", |
| util::EscapeQueryStringValue(directory_resource_id).c_str()), |
| @@ -378,8 +392,13 @@ CancelCallback DriveAPIService::Search( |
| DCHECK(!search_query.empty()); |
| DCHECK(!callback.is_null()); |
| + FilesListCorpora corpora = (google_apis::GetTeamDrivesIntegrationSwitch() == |
| + google_apis::TEAM_DRIVES_INTEGRATION_ENABLED) |
| + ? google_apis::CORPORA_ALL_TEAM_DRIVES |
| + : google_apis::CORPORA_DEFAULT; |
| + |
| return files_list_request_runner_->CreateAndStartWithSizeBackoff( |
| - kMaxNumFilesResourcePerRequestForSearch, |
| + kMaxNumFilesResourcePerRequestForSearch, corpora, "", |
| util::TranslateQuery(search_query), kFileListFields, callback); |
| } |