Chromium Code Reviews| Index: google_apis/drive/drive_api_url_generator.cc |
| diff --git a/google_apis/drive/drive_api_url_generator.cc b/google_apis/drive/drive_api_url_generator.cc |
| index e79bf0decca7285d8673d9767bc6f870ba3c6c7d..8e57d14b8b379a47aed17046938e596804b1266d 100644 |
| --- a/google_apis/drive/drive_api_url_generator.cc |
| +++ b/google_apis/drive/drive_api_url_generator.cc |
| @@ -42,6 +42,8 @@ const char kDriveV2TeamDrivesUrl[] = "drive/v2/teamdrives"; |
| const char kIncludeTeamDriveItems[] = "includeTeamDriveItems"; |
| const char kSupportsTeamDrives[] = "supportsTeamDrives"; |
| +const char kCorpora[] = "corpora"; |
| +const char kTeamDriveId[] = "teamDriveId"; |
| // apps.delete and file.authorize API is exposed through a special endpoint |
| // v2internal that is accessible only by the official API key for Chrome. |
| @@ -185,12 +187,18 @@ GURL DriveApiUrlGenerator::GetFilesCopyUrl( |
| GURL DriveApiUrlGenerator::GetFilesListUrl(int max_results, |
| const std::string& page_token, |
| + const FilesListScope& scope, |
| const std::string& q) const { |
| GURL url = base_url_.Resolve(kDriveV2FilesUrl); |
| if (enable_team_drives_) { |
| url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true"); |
| - url = net::AppendOrReplaceQueryParameter(url, kIncludeTeamDriveItems, |
| - "true"); |
| + url = |
| + net::AppendOrReplaceQueryParameter(url, kIncludeTeamDriveItems, "true"); |
| + url = net::AppendOrReplaceQueryParameter(url, kCorpora, |
| + scope.GetCorpusParam()); |
| + if (!scope.GetTeamDriveId().empty()) |
| + url = net::AppendOrReplaceQueryParameter(url, kTeamDriveId, |
| + scope.GetTeamDriveId()); |
| } |
| // maxResults is 100 by default. |
| if (max_results != 100) { |
| @@ -238,7 +246,7 @@ GURL DriveApiUrlGenerator::GetChangesListUrl( |
| "true"); |
| if (!team_drive_id.empty()) { |
| url = |
| - net::AppendOrReplaceQueryParameter(url, "teamDriveId", team_drive_id); |
| + net::AppendOrReplaceQueryParameter(url, kTeamDriveId, team_drive_id); |
| } |
| } |
| // includeDeleted is "true" by default. |
| @@ -391,4 +399,30 @@ GURL DriveApiUrlGenerator::GetTeamDriveListUrl( |
| return url; |
| } |
| +// static |
| +std::string FilesListScope::kDefaultAndAllTeamDrivesCorpus_ = |
|
hashimoto
2017/05/26 09:09:19
Variables of class type with static storage durati
yamaguchi
2017/05/31 08:21:30
Done.
|
| + "default,allTeamDrives"; |
| +// static |
| +std::string FilesListScope::kTeamDriveCorpus_ = "teamDrive"; |
| +// static |
| +std::string FilesListScope::kDefaultCorpus_ = "default"; |
| +// static |
| +FilesListScope FilesListScope::kAllTeamDrives = FilesListScope(true, ""); |
| +// static |
| +FilesListScope FilesListScope::kDefault = FilesListScope(false, ""); |
| +// static |
| +FilesListScope FilesListScope::CreateForTeamDrive( |
| + const std::string& team_drive_id) { |
| + return FilesListScope(false, team_drive_id); |
| +} |
| + |
| +const std::string& FilesListScope::GetCorpusParam() const { |
| + if (all_team_drives_) { |
| + return kDefaultAndAllTeamDrivesCorpus_; |
| + } else if (!team_drive_id_.empty()) { |
| + return kTeamDriveCorpus_; |
| + } |
| + return kDefaultCorpus_; |
| +} |
| + |
| } // namespace google_apis |