diff options
author | mtomasz <mtomasz@chromium.org> | 2015-02-27 03:05:28 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-27 11:06:26 +0000 |
commit | 3315eb5fe7bcb9300995dae3326de2d2c5f3c44a (patch) | |
tree | aee3ef0271ad1fddc7436f7df2c30e829d04a8a3 /google_apis/drive/drive_api_url_generator.cc | |
parent | a0920dfe9bf0cbe0f1506a5294ee0900a7d0b5e9 (diff) | |
download | chromium_src-3315eb5fe7bcb9300995dae3326de2d2c5f3c44a.zip chromium_src-3315eb5fe7bcb9300995dae3326de2d2c5f3c44a.tar.gz chromium_src-3315eb5fe7bcb9300995dae3326de2d2c5f3c44a.tar.bz2 |
Update Styx URLs for thumbnails and downloads in Files app.
This patch updates the URLs for Drive files to match the recent requirements.
TBR=kinaba@chromium.org
TEST=unit_tests: *DriveApiUrlGeneratorTest*
BUG=None
Review URL: https://codereview.chromium.org/831663009
Cr-Commit-Position: refs/heads/master@{#318432}
Diffstat (limited to 'google_apis/drive/drive_api_url_generator.cc')
-rw-r--r-- | google_apis/drive/drive_api_url_generator.cc | 55 |
1 files changed, 35 insertions, 20 deletions
diff --git a/google_apis/drive/drive_api_url_generator.cc b/google_apis/drive/drive_api_url_generator.cc index e35a3e7..285e754 100644 --- a/google_apis/drive/drive_api_url_generator.cc +++ b/google_apis/drive/drive_api_url_generator.cc @@ -16,29 +16,30 @@ namespace google_apis { namespace { // Hard coded URLs for communication with a google drive server. -const char kDriveV2AboutUrl[] = "/drive/v2/about"; -const char kDriveV2AppsUrl[] = "/drive/v2/apps"; -const char kDriveV2ChangelistUrl[] = "/drive/v2/changes"; -const char kDriveV2FilesUrl[] = "/drive/v2/files"; -const char kDriveV2FileUrlPrefix[] = "/drive/v2/files/"; -const char kDriveV2ChildrenUrlFormat[] = "/drive/v2/files/%s/children"; +const char kDriveV2AboutUrl[] = "drive/v2/about"; +const char kDriveV2AppsUrl[] = "drive/v2/apps"; +const char kDriveV2ChangelistUrl[] = "drive/v2/changes"; +const char kDriveV2FilesUrl[] = "drive/v2/files"; +const char kDriveV2FileUrlPrefix[] = "drive/v2/files/"; +const char kDriveV2ChildrenUrlFormat[] = "drive/v2/files/%s/children"; const char kDriveV2ChildrenUrlForRemovalFormat[] = - "/drive/v2/files/%s/children/%s"; -const char kDriveV2FileCopyUrlFormat[] = "/drive/v2/files/%s/copy"; -const char kDriveV2FileDeleteUrlFormat[] = "/drive/v2/files/%s"; -const char kDriveV2FileTrashUrlFormat[] = "/drive/v2/files/%s/trash"; -const char kDriveV2UploadNewFileUrl[] = "/upload/drive/v2/files"; -const char kDriveV2UploadExistingFileUrlPrefix[] = - "/upload/drive/v2/files/"; -const char kDriveV2PermissionsUrlFormat[] = "/drive/v2/files/%s/permissions"; + "drive/v2/files/%s/children/%s"; +const char kDriveV2FileCopyUrlFormat[] = "drive/v2/files/%s/copy"; +const char kDriveV2FileDeleteUrlFormat[] = "drive/v2/files/%s"; +const char kDriveV2FileTrashUrlFormat[] = "drive/v2/files/%s/trash"; +const char kDriveV2UploadNewFileUrl[] = "upload/drive/v2/files"; +const char kDriveV2UploadExistingFileUrlPrefix[] = "upload/drive/v2/files/"; +const char kDriveV2PermissionsUrlFormat[] = "drive/v2/files/%s/permissions"; +const char kDriveV2DownloadUrlFormat[] = "host/%s"; +const char kDriveV2ThumbnailUrlFormat[] = "thumb/%s?width=%d&height=%d"; // apps.delete and file.authorize API is exposed through a special endpoint // v2internal that is accessible only by the official API key for Chrome. -const char kDriveV2InternalAppsUrl[] = "/drive/v2internal/apps"; -const char kDriveV2AppsDeleteUrlFormat[] = "/drive/v2internal/apps/%s"; +const char kDriveV2InternalAppsUrl[] = "drive/v2internal/apps"; +const char kDriveV2AppsDeleteUrlFormat[] = "drive/v2internal/apps/%s"; const char kDriveV2FilesAuthorizeUrlFormat[] = - "/drive/v2internal/files/%s/authorize?appId=%s"; -const char kDriveV2InternalFileUrlPrefix[] = "/drive/v2internal/files/"; + "drive/v2internal/files/%s/authorize?appId=%s"; +const char kDriveV2InternalFileUrlPrefix[] = "drive/v2internal/files/"; GURL AddResumableUploadParam(const GURL& url) { return net::AppendOrReplaceQueryParameter(url, "uploadType", "resumable"); @@ -63,8 +64,13 @@ DriveApiUrlGenerator::~DriveApiUrlGenerator() { const char DriveApiUrlGenerator::kBaseUrlForProduction[] = "https://www.googleapis.com"; + const char DriveApiUrlGenerator::kBaseDownloadUrlForProduction[] = - "https://www.googledrive.com/host/"; +#if defined(GOOGLE_CHROME_BUILD) || defined(USE_OFFICIAL_GOOGLE_API_KEYS) + "https://www.googledrive.com/p/"; +#else + "https://www.googledrive.com"; +#endif GURL DriveApiUrlGenerator::GetAboutGetUrl() const { return base_url_.Resolve(kDriveV2AboutUrl); @@ -263,7 +269,8 @@ GURL DriveApiUrlGenerator::GetMultipartUploadExistingFileUrl( GURL DriveApiUrlGenerator::GenerateDownloadFileUrl( const std::string& resource_id) const { - return base_download_url_.Resolve(net::EscapePath(resource_id)); + return base_download_url_.Resolve(base::StringPrintf( + kDriveV2DownloadUrlFormat, net::EscapePath(resource_id).c_str())); } GURL DriveApiUrlGenerator::GetPermissionsInsertUrl( @@ -273,4 +280,12 @@ GURL DriveApiUrlGenerator::GetPermissionsInsertUrl( net::EscapePath(resource_id).c_str())); } +GURL DriveApiUrlGenerator::GetThumbnailUrl(const std::string& resource_id, + int width, + int height) const { + return base_download_url_.Resolve( + base::StringPrintf(kDriveV2ThumbnailUrlFormat, + net::EscapePath(resource_id).c_str(), width, height)); +} + } // namespace google_apis |