 Chromium Code Reviews
 Chromium Code Reviews Issue 2894513003:
  Fetch files shared in Team Drives by specifying allTeamDrives corpora.  (Closed)
    
  
    Issue 2894513003:
  Fetch files shared in Team Drives by specifying allTeamDrives corpora.  (Closed) 
  | OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "google_apis/drive/drive_api_url_generator.h" | 5 #include "google_apis/drive/drive_api_url_generator.h" | 
| 6 | 6 | 
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" | 
| 8 #include "base/logging.h" | 8 #include "base/logging.h" | 
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" | 
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" | 
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 const char kDriveV2UploadExistingFileUrlPrefix[] = "upload/drive/v2/files/"; | 35 const char kDriveV2UploadExistingFileUrlPrefix[] = "upload/drive/v2/files/"; | 
| 36 const char kDriveV2BatchUploadUrl[] = "upload/drive"; | 36 const char kDriveV2BatchUploadUrl[] = "upload/drive"; | 
| 37 const char kDriveV2PermissionsUrlFormat[] = "drive/v2/files/%s/permissions"; | 37 const char kDriveV2PermissionsUrlFormat[] = "drive/v2/files/%s/permissions"; | 
| 38 const char kDriveV2DownloadUrlFormat[] = "drive/v2/files/%s?alt=media"; | 38 const char kDriveV2DownloadUrlFormat[] = "drive/v2/files/%s?alt=media"; | 
| 39 const char kDriveV2ThumbnailUrlFormat[] = "d/%s=w%d-h%d"; | 39 const char kDriveV2ThumbnailUrlFormat[] = "d/%s=w%d-h%d"; | 
| 40 const char kDriveV2ThumbnailUrlWithCropFormat[] = "d/%s=w%d-h%d-c"; | 40 const char kDriveV2ThumbnailUrlWithCropFormat[] = "d/%s=w%d-h%d-c"; | 
| 41 const char kDriveV2TeamDrivesUrl[] = "drive/v2/teamdrives"; | 41 const char kDriveV2TeamDrivesUrl[] = "drive/v2/teamdrives"; | 
| 42 | 42 | 
| 43 const char kIncludeTeamDriveItems[] = "includeTeamDriveItems"; | 43 const char kIncludeTeamDriveItems[] = "includeTeamDriveItems"; | 
| 44 const char kSupportsTeamDrives[] = "supportsTeamDrives"; | 44 const char kSupportsTeamDrives[] = "supportsTeamDrives"; | 
| 45 const char kCorpora[] = "corpora"; | |
| 46 const char kCorporaAllTeamDrives[] = "default,allTeamDrives"; | |
| 47 const char kCorporaDefault[] = "default"; | |
| 48 const char kCorporaTeamDrive[] = "teamDrive"; | |
| 49 const char kTeamDriveId[] = "teamDriveId"; | |
| 45 | 50 | 
| 46 // apps.delete and file.authorize API is exposed through a special endpoint | 51 // apps.delete and file.authorize API is exposed through a special endpoint | 
| 47 // v2internal that is accessible only by the official API key for Chrome. | 52 // v2internal that is accessible only by the official API key for Chrome. | 
| 48 const char kDriveV2InternalAppsUrl[] = "drive/v2internal/apps"; | 53 const char kDriveV2InternalAppsUrl[] = "drive/v2internal/apps"; | 
| 49 const char kDriveV2AppsDeleteUrlFormat[] = "drive/v2internal/apps/%s"; | 54 const char kDriveV2AppsDeleteUrlFormat[] = "drive/v2internal/apps/%s"; | 
| 50 const char kDriveV2FilesAuthorizeUrlFormat[] = | 55 const char kDriveV2FilesAuthorizeUrlFormat[] = | 
| 51 "drive/v2internal/files/%s/authorize?appId=%s"; | 56 "drive/v2internal/files/%s/authorize?appId=%s"; | 
| 52 const char kDriveV2InternalFileUrlPrefix[] = "drive/v2internal/files/"; | 57 const char kDriveV2InternalFileUrlPrefix[] = "drive/v2internal/files/"; | 
| 53 | 58 | 
| 54 GURL AddResumableUploadParam(const GURL& url) { | 59 GURL AddResumableUploadParam(const GURL& url) { | 
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 if (enable_team_drives_) | 183 if (enable_team_drives_) | 
| 179 url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true"); | 184 url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true"); | 
| 180 if (!visibility.empty()) | 185 if (!visibility.empty()) | 
| 181 url = net::AppendOrReplaceQueryParameter(url, "visibility", visibility); | 186 url = net::AppendOrReplaceQueryParameter(url, "visibility", visibility); | 
| 182 | 187 | 
| 183 return url; | 188 return url; | 
| 184 } | 189 } | 
| 185 | 190 | 
| 186 GURL DriveApiUrlGenerator::GetFilesListUrl(int max_results, | 191 GURL DriveApiUrlGenerator::GetFilesListUrl(int max_results, | 
| 187 const std::string& page_token, | 192 const std::string& page_token, | 
| 193 FilesListCorpora corpora, | |
| 194 const std::string& team_drive_id, | |
| 188 const std::string& q) const { | 195 const std::string& q) const { | 
| 189 GURL url = base_url_.Resolve(kDriveV2FilesUrl); | 196 GURL url = base_url_.Resolve(kDriveV2FilesUrl); | 
| 190 if (enable_team_drives_) { | 197 if (enable_team_drives_) { | 
| 191 url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true"); | 198 url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true"); | 
| 192 url = net::AppendOrReplaceQueryParameter(url, kIncludeTeamDriveItems, | 199 url = | 
| 193 "true"); | 200 net::AppendOrReplaceQueryParameter(url, kIncludeTeamDriveItems, "true"); | 
| 
hashimoto
2017/06/02 09:44:46
Are kSupportsTeamDrives and kIncludeTeamDriveItems
 
yamaguchi
2017/06/02 12:04:01
Changed to turn off includeTeamDriveItems for the
 | |
| 201 url = net::AppendOrReplaceQueryParameter(url, kCorpora, | |
| 202 GetCorporaString_(corpora)); | |
| 203 if (!team_drive_id.empty()) | |
| 204 url = | |
| 205 net::AppendOrReplaceQueryParameter(url, kTeamDriveId, team_drive_id); | |
| 194 } | 206 } | 
| 195 // maxResults is 100 by default. | 207 // maxResults is 100 by default. | 
| 196 if (max_results != 100) { | 208 if (max_results != 100) { | 
| 197 url = net::AppendOrReplaceQueryParameter( | 209 url = net::AppendOrReplaceQueryParameter( | 
| 198 url, "maxResults", base::IntToString(max_results)); | 210 url, "maxResults", base::IntToString(max_results)); | 
| 199 } | 211 } | 
| 200 | 212 | 
| 201 if (!page_token.empty()) | 213 if (!page_token.empty()) | 
| 202 url = net::AppendOrReplaceQueryParameter(url, "pageToken", page_token); | 214 url = net::AppendOrReplaceQueryParameter(url, "pageToken", page_token); | 
| 203 | 215 | 
| (...skipping 27 matching lines...) Expand all Loading... | |
| 231 const std::string& team_drive_id) const { | 243 const std::string& team_drive_id) const { | 
| 232 DCHECK_GE(start_change_id, 0); | 244 DCHECK_GE(start_change_id, 0); | 
| 233 | 245 | 
| 234 GURL url = base_url_.Resolve(kDriveV2ChangelistUrl); | 246 GURL url = base_url_.Resolve(kDriveV2ChangelistUrl); | 
| 235 if (enable_team_drives_) { | 247 if (enable_team_drives_) { | 
| 236 url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true"); | 248 url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true"); | 
| 237 url = net::AppendOrReplaceQueryParameter(url, kIncludeTeamDriveItems, | 249 url = net::AppendOrReplaceQueryParameter(url, kIncludeTeamDriveItems, | 
| 238 "true"); | 250 "true"); | 
| 239 if (!team_drive_id.empty()) { | 251 if (!team_drive_id.empty()) { | 
| 240 url = | 252 url = | 
| 241 net::AppendOrReplaceQueryParameter(url, "teamDriveId", team_drive_id); | 253 net::AppendOrReplaceQueryParameter(url, kTeamDriveId, team_drive_id); | 
| 242 } | 254 } | 
| 243 } | 255 } | 
| 244 // includeDeleted is "true" by default. | 256 // includeDeleted is "true" by default. | 
| 245 if (!include_deleted) | 257 if (!include_deleted) | 
| 246 url = net::AppendOrReplaceQueryParameter(url, "includeDeleted", "false"); | 258 url = net::AppendOrReplaceQueryParameter(url, "includeDeleted", "false"); | 
| 247 | 259 | 
| 248 // maxResults is "100" by default. | 260 // maxResults is "100" by default. | 
| 249 if (max_results != 100) { | 261 if (max_results != 100) { | 
| 250 url = net::AppendOrReplaceQueryParameter( | 262 url = net::AppendOrReplaceQueryParameter( | 
| 251 url, "maxResults", base::IntToString(max_results)); | 263 url, "maxResults", base::IntToString(max_results)); | 
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 384 if (max_results != 10) { | 396 if (max_results != 10) { | 
| 385 url = net::AppendOrReplaceQueryParameter(url, "maxResults", | 397 url = net::AppendOrReplaceQueryParameter(url, "maxResults", | 
| 386 base::IntToString(max_results)); | 398 base::IntToString(max_results)); | 
| 387 } | 399 } | 
| 388 if (!page_token.empty()) | 400 if (!page_token.empty()) | 
| 389 url = net::AppendOrReplaceQueryParameter(url, "pageToken", page_token); | 401 url = net::AppendOrReplaceQueryParameter(url, "pageToken", page_token); | 
| 390 | 402 | 
| 391 return url; | 403 return url; | 
| 392 } | 404 } | 
| 393 | 405 | 
| 406 // static | |
| 407 const char* DriveApiUrlGenerator::GetCorporaString_(FilesListCorpora corpora) { | |
| 408 switch (corpora) { | |
| 409 case CORPORA_TEAM_DRIVE: | |
| 410 return kCorporaTeamDrive; | |
| 411 case CORPORA_ALL_TEAM_DRIVES: | |
| 412 return kCorporaAllTeamDrives; | |
| 413 default: | |
| 
hashimoto
2017/06/02 09:44:46
Please have cases for all possible enums.
Instead
 
yamaguchi
2017/06/02 12:04:01
Done.
 | |
| 414 DCHECK(corpora == CORPORA_DEFAULT); | |
| 415 return kCorporaDefault; | |
| 416 } | |
| 417 } | |
| 418 | |
| 394 } // namespace google_apis | 419 } // namespace google_apis | 
| OLD | NEW |