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 kTeamDriveId[] = "teamDriveId"; | |
45 | 47 |
46 // apps.delete and file.authorize API is exposed through a special endpoint | 48 // 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. | 49 // v2internal that is accessible only by the official API key for Chrome. |
48 const char kDriveV2InternalAppsUrl[] = "drive/v2internal/apps"; | 50 const char kDriveV2InternalAppsUrl[] = "drive/v2internal/apps"; |
49 const char kDriveV2AppsDeleteUrlFormat[] = "drive/v2internal/apps/%s"; | 51 const char kDriveV2AppsDeleteUrlFormat[] = "drive/v2internal/apps/%s"; |
50 const char kDriveV2FilesAuthorizeUrlFormat[] = | 52 const char kDriveV2FilesAuthorizeUrlFormat[] = |
51 "drive/v2internal/files/%s/authorize?appId=%s"; | 53 "drive/v2internal/files/%s/authorize?appId=%s"; |
52 const char kDriveV2InternalFileUrlPrefix[] = "drive/v2internal/files/"; | 54 const char kDriveV2InternalFileUrlPrefix[] = "drive/v2internal/files/"; |
53 | 55 |
54 GURL AddResumableUploadParam(const GURL& url) { | 56 GURL AddResumableUploadParam(const GURL& url) { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
178 if (enable_team_drives_) | 180 if (enable_team_drives_) |
179 url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true"); | 181 url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true"); |
180 if (!visibility.empty()) | 182 if (!visibility.empty()) |
181 url = net::AppendOrReplaceQueryParameter(url, "visibility", visibility); | 183 url = net::AppendOrReplaceQueryParameter(url, "visibility", visibility); |
182 | 184 |
183 return url; | 185 return url; |
184 } | 186 } |
185 | 187 |
186 GURL DriveApiUrlGenerator::GetFilesListUrl(int max_results, | 188 GURL DriveApiUrlGenerator::GetFilesListUrl(int max_results, |
187 const std::string& page_token, | 189 const std::string& page_token, |
190 const FilesListScope& scope, | |
188 const std::string& q) const { | 191 const std::string& q) const { |
189 GURL url = base_url_.Resolve(kDriveV2FilesUrl); | 192 GURL url = base_url_.Resolve(kDriveV2FilesUrl); |
190 if (enable_team_drives_) { | 193 if (enable_team_drives_) { |
191 url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true"); | 194 url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true"); |
192 url = net::AppendOrReplaceQueryParameter(url, kIncludeTeamDriveItems, | 195 url = |
193 "true"); | 196 net::AppendOrReplaceQueryParameter(url, kIncludeTeamDriveItems, "true"); |
197 url = net::AppendOrReplaceQueryParameter(url, kCorpora, | |
198 scope.GetCorpusParam()); | |
199 if (!scope.GetTeamDriveId().empty()) | |
200 url = net::AppendOrReplaceQueryParameter(url, kTeamDriveId, | |
201 scope.GetTeamDriveId()); | |
194 } | 202 } |
195 // maxResults is 100 by default. | 203 // maxResults is 100 by default. |
196 if (max_results != 100) { | 204 if (max_results != 100) { |
197 url = net::AppendOrReplaceQueryParameter( | 205 url = net::AppendOrReplaceQueryParameter( |
198 url, "maxResults", base::IntToString(max_results)); | 206 url, "maxResults", base::IntToString(max_results)); |
199 } | 207 } |
200 | 208 |
201 if (!page_token.empty()) | 209 if (!page_token.empty()) |
202 url = net::AppendOrReplaceQueryParameter(url, "pageToken", page_token); | 210 url = net::AppendOrReplaceQueryParameter(url, "pageToken", page_token); |
203 | 211 |
(...skipping 27 matching lines...) Expand all Loading... | |
231 const std::string& team_drive_id) const { | 239 const std::string& team_drive_id) const { |
232 DCHECK_GE(start_change_id, 0); | 240 DCHECK_GE(start_change_id, 0); |
233 | 241 |
234 GURL url = base_url_.Resolve(kDriveV2ChangelistUrl); | 242 GURL url = base_url_.Resolve(kDriveV2ChangelistUrl); |
235 if (enable_team_drives_) { | 243 if (enable_team_drives_) { |
236 url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true"); | 244 url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true"); |
237 url = net::AppendOrReplaceQueryParameter(url, kIncludeTeamDriveItems, | 245 url = net::AppendOrReplaceQueryParameter(url, kIncludeTeamDriveItems, |
238 "true"); | 246 "true"); |
239 if (!team_drive_id.empty()) { | 247 if (!team_drive_id.empty()) { |
240 url = | 248 url = |
241 net::AppendOrReplaceQueryParameter(url, "teamDriveId", team_drive_id); | 249 net::AppendOrReplaceQueryParameter(url, kTeamDriveId, team_drive_id); |
242 } | 250 } |
243 } | 251 } |
244 // includeDeleted is "true" by default. | 252 // includeDeleted is "true" by default. |
245 if (!include_deleted) | 253 if (!include_deleted) |
246 url = net::AppendOrReplaceQueryParameter(url, "includeDeleted", "false"); | 254 url = net::AppendOrReplaceQueryParameter(url, "includeDeleted", "false"); |
247 | 255 |
248 // maxResults is "100" by default. | 256 // maxResults is "100" by default. |
249 if (max_results != 100) { | 257 if (max_results != 100) { |
250 url = net::AppendOrReplaceQueryParameter( | 258 url = net::AppendOrReplaceQueryParameter( |
251 url, "maxResults", base::IntToString(max_results)); | 259 url, "maxResults", base::IntToString(max_results)); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
384 if (max_results != 10) { | 392 if (max_results != 10) { |
385 url = net::AppendOrReplaceQueryParameter(url, "maxResults", | 393 url = net::AppendOrReplaceQueryParameter(url, "maxResults", |
386 base::IntToString(max_results)); | 394 base::IntToString(max_results)); |
387 } | 395 } |
388 if (!page_token.empty()) | 396 if (!page_token.empty()) |
389 url = net::AppendOrReplaceQueryParameter(url, "pageToken", page_token); | 397 url = net::AppendOrReplaceQueryParameter(url, "pageToken", page_token); |
390 | 398 |
391 return url; | 399 return url; |
392 } | 400 } |
393 | 401 |
402 // static | |
403 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.
| |
404 "default,allTeamDrives"; | |
405 // static | |
406 std::string FilesListScope::kTeamDriveCorpus_ = "teamDrive"; | |
407 // static | |
408 std::string FilesListScope::kDefaultCorpus_ = "default"; | |
409 // static | |
410 FilesListScope FilesListScope::kAllTeamDrives = FilesListScope(true, ""); | |
411 // static | |
412 FilesListScope FilesListScope::kDefault = FilesListScope(false, ""); | |
413 // static | |
414 FilesListScope FilesListScope::CreateForTeamDrive( | |
415 const std::string& team_drive_id) { | |
416 return FilesListScope(false, team_drive_id); | |
417 } | |
418 | |
419 const std::string& FilesListScope::GetCorpusParam() const { | |
420 if (all_team_drives_) { | |
421 return kDefaultAndAllTeamDrivesCorpus_; | |
422 } else if (!team_drive_id_.empty()) { | |
423 return kTeamDriveCorpus_; | |
424 } | |
425 return kDefaultCorpus_; | |
426 } | |
427 | |
394 } // namespace google_apis | 428 } // namespace google_apis |
OLD | NEW |