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/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "net/base/escape.h" | 10 #include "net/base/escape.h" |
11 #include "net/base/url_util.h" | 11 #include "net/base/url_util.h" |
12 | 12 |
13 namespace google_apis { | 13 namespace google_apis { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 // Hard coded URLs for communication with a google drive server. | 17 // Hard coded URLs for communication with a google drive server. |
18 const char kDriveV2AboutUrl[] = "/drive/v2/about"; | 18 const char kDriveV2AboutUrl[] = "/drive/v2/about"; |
19 const char kDriveV2AppsUrl[] = "/drive/v2/apps"; | 19 const char kDriveV2AppsUrl[] = "/drive/v2/apps"; |
20 // apps.delete API is exposed through a special endpoing v2internal that | |
hashimoto
2014/01/08 09:06:32
nit: s/endpoing/endpoint/?
kinaba
2014/01/08 09:09:13
Thanks. I'm sleepy today...
| |
21 // is accessible only by the official API key for Chrome. | |
22 const char kDriveV2AppsDeleteUrlFormat[] = "/drive/v2internal/apps/%s"; | |
20 const char kDriveV2ChangelistUrl[] = "/drive/v2/changes"; | 23 const char kDriveV2ChangelistUrl[] = "/drive/v2/changes"; |
21 const char kDriveV2FilesUrl[] = "/drive/v2/files"; | 24 const char kDriveV2FilesUrl[] = "/drive/v2/files"; |
22 const char kDriveV2FileUrlPrefix[] = "/drive/v2/files/"; | 25 const char kDriveV2FileUrlPrefix[] = "/drive/v2/files/"; |
23 const char kDriveV2ChildrenUrlFormat[] = "/drive/v2/files/%s/children"; | 26 const char kDriveV2ChildrenUrlFormat[] = "/drive/v2/files/%s/children"; |
24 const char kDriveV2ChildrenUrlForRemovalFormat[] = | 27 const char kDriveV2ChildrenUrlForRemovalFormat[] = |
25 "/drive/v2/files/%s/children/%s"; | 28 "/drive/v2/files/%s/children/%s"; |
26 const char kDriveV2FileCopyUrlFormat[] = "/drive/v2/files/%s/copy"; | 29 const char kDriveV2FileCopyUrlFormat[] = "/drive/v2/files/%s/copy"; |
27 const char kDriveV2FileDeleteUrlFormat[] = "/drive/v2/files/%s"; | 30 const char kDriveV2FileDeleteUrlFormat[] = "/drive/v2/files/%s"; |
28 const char kDriveV2FileTrashUrlFormat[] = "/drive/v2/files/%s/trash"; | 31 const char kDriveV2FileTrashUrlFormat[] = "/drive/v2/files/%s/trash"; |
29 const char kDriveV2InitiateUploadNewFileUrl[] = "/upload/drive/v2/files"; | 32 const char kDriveV2InitiateUploadNewFileUrl[] = "/upload/drive/v2/files"; |
(...skipping 23 matching lines...) Expand all Loading... | |
53 "https://www.googledrive.com/host/"; | 56 "https://www.googledrive.com/host/"; |
54 | 57 |
55 GURL DriveApiUrlGenerator::GetAboutGetUrl() const { | 58 GURL DriveApiUrlGenerator::GetAboutGetUrl() const { |
56 return base_url_.Resolve(kDriveV2AboutUrl); | 59 return base_url_.Resolve(kDriveV2AboutUrl); |
57 } | 60 } |
58 | 61 |
59 GURL DriveApiUrlGenerator::GetAppsListUrl() const { | 62 GURL DriveApiUrlGenerator::GetAppsListUrl() const { |
60 return base_url_.Resolve(kDriveV2AppsUrl); | 63 return base_url_.Resolve(kDriveV2AppsUrl); |
61 } | 64 } |
62 | 65 |
66 GURL DriveApiUrlGenerator::GetAppsDeleteUrl(const std::string& app_id) const { | |
67 return base_url_.Resolve(base::StringPrintf( | |
68 kDriveV2AppsDeleteUrlFormat, net::EscapePath(app_id).c_str())); | |
69 } | |
70 | |
63 GURL DriveApiUrlGenerator::GetFilesGetUrl(const std::string& file_id) const { | 71 GURL DriveApiUrlGenerator::GetFilesGetUrl(const std::string& file_id) const { |
64 return base_url_.Resolve(kDriveV2FileUrlPrefix + net::EscapePath(file_id)); | 72 return base_url_.Resolve(kDriveV2FileUrlPrefix + net::EscapePath(file_id)); |
65 } | 73 } |
66 | 74 |
67 GURL DriveApiUrlGenerator::GetFilesInsertUrl() const { | 75 GURL DriveApiUrlGenerator::GetFilesInsertUrl() const { |
68 return base_url_.Resolve(kDriveV2FilesUrl); | 76 return base_url_.Resolve(kDriveV2FilesUrl); |
69 } | 77 } |
70 | 78 |
71 GURL DriveApiUrlGenerator::GetFilesPatchUrl(const std::string& file_id, | 79 GURL DriveApiUrlGenerator::GetFilesPatchUrl(const std::string& file_id, |
72 bool set_modified_date, | 80 bool set_modified_date, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 net::EscapePath(resource_id)); | 182 net::EscapePath(resource_id)); |
175 return AddResumableUploadParam(url); | 183 return AddResumableUploadParam(url); |
176 } | 184 } |
177 | 185 |
178 GURL DriveApiUrlGenerator::GenerateDownloadFileUrl( | 186 GURL DriveApiUrlGenerator::GenerateDownloadFileUrl( |
179 const std::string& resource_id) const { | 187 const std::string& resource_id) const { |
180 return base_download_url_.Resolve(net::EscapePath(resource_id)); | 188 return base_download_url_.Resolve(net::EscapePath(resource_id)); |
181 } | 189 } |
182 | 190 |
183 } // namespace google_apis | 191 } // namespace google_apis |
OLD | NEW |