summaryrefslogtreecommitdiffstats
path: root/google_apis/drive/drive_api_url_generator.cc
diff options
context:
space:
mode:
authorfukino <fukino@chromium.org>2015-01-16 04:48:25 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-16 12:49:21 +0000
commit1760725ac3618fe5d5bd307008477e683377bb30 (patch)
treed448e8f7c5de819e9d419898ba6ddfcf1feec3b6 /google_apis/drive/drive_api_url_generator.cc
parent20bfd92d606d5f0d6efea04b8c384051f213fda4 (diff)
downloadchromium_src-1760725ac3618fe5d5bd307008477e683377bb30.zip
chromium_src-1760725ac3618fe5d5bd307008477e683377bb30.tar.gz
chromium_src-1760725ac3618fe5d5bd307008477e683377bb30.tar.bz2
Migrate from WAPI to Genoa to get the url to share dialog.
- As 'shareLink' is available only in v2internal, files.get is routed to v2internal now. If the running Chrome OS is not official build, files.get is routed to non-internal server and shareLink is not available. - If the shareLink is not available, an error log will be output and the dialog shows the message IDS_FILE_BROWSER_SHARE_ERROR ("Sharing failed. Check your connection and try again later." in English). BUG=357038 TEST=run google_apis_unittests Review URL: https://codereview.chromium.org/857543002 Cr-Commit-Position: refs/heads/master@{#311884}
Diffstat (limited to 'google_apis/drive/drive_api_url_generator.cc')
-rw-r--r--google_apis/drive/drive_api_url_generator.cc22
1 files changed, 20 insertions, 2 deletions
diff --git a/google_apis/drive/drive_api_url_generator.cc b/google_apis/drive/drive_api_url_generator.cc
index 310dfdb..e35a3e7 100644
--- a/google_apis/drive/drive_api_url_generator.cc
+++ b/google_apis/drive/drive_api_url_generator.cc
@@ -38,6 +38,7 @@ 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/";
GURL AddResumableUploadParam(const GURL& url) {
return net::AppendOrReplaceQueryParameter(url, "uploadType", "resumable");
@@ -79,8 +80,25 @@ GURL DriveApiUrlGenerator::GetAppsDeleteUrl(const std::string& app_id) const {
kDriveV2AppsDeleteUrlFormat, net::EscapePath(app_id).c_str()));
}
-GURL DriveApiUrlGenerator::GetFilesGetUrl(const std::string& file_id) const {
- return base_url_.Resolve(kDriveV2FileUrlPrefix + net::EscapePath(file_id));
+GURL DriveApiUrlGenerator::GetFilesGetUrl(const std::string& file_id,
+ bool use_internal_endpoint,
+ const GURL& embed_origin) const {
+ GURL url = base_url_.Resolve(use_internal_endpoint ?
+ kDriveV2InternalFileUrlPrefix + net::EscapePath(file_id) :
+ kDriveV2FileUrlPrefix + net::EscapePath(file_id));
+ if (!embed_origin.is_empty()) {
+ // Construct a valid serialized embed origin from an url, according to
+ // WD-html5-20110525. Such string has to be built manually, since
+ // GURL::spec() always adds the trailing slash. Moreover, ports are
+ // currently not supported.
+ DCHECK(!embed_origin.has_port());
+ DCHECK(!embed_origin.has_path() || embed_origin.path() == "/");
+ const std::string serialized_embed_origin =
+ embed_origin.scheme() + "://" + embed_origin.host();
+ url = net::AppendOrReplaceQueryParameter(
+ url, "embedOrigin", serialized_embed_origin);
+ }
+ return url;
}
GURL DriveApiUrlGenerator::GetFilesAuthorizeUrl(