Chromium Code Reviews| 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 const char kDriveV2AppsDeleteUrlFormat[] = "/drive/v2internal/apps/%s"; | |
|
hashimoto
2014/01/08 07:20:47
Can we have some comment about this "v2internal"?
kinaba
2014/01/08 09:03:46
Done.
| |
| 20 const char kDriveV2ChangelistUrl[] = "/drive/v2/changes"; | 21 const char kDriveV2ChangelistUrl[] = "/drive/v2/changes"; |
| 21 const char kDriveV2FilesUrl[] = "/drive/v2/files"; | 22 const char kDriveV2FilesUrl[] = "/drive/v2/files"; |
| 22 const char kDriveV2FileUrlPrefix[] = "/drive/v2/files/"; | 23 const char kDriveV2FileUrlPrefix[] = "/drive/v2/files/"; |
| 23 const char kDriveV2ChildrenUrlFormat[] = "/drive/v2/files/%s/children"; | 24 const char kDriveV2ChildrenUrlFormat[] = "/drive/v2/files/%s/children"; |
| 24 const char kDriveV2ChildrenUrlForRemovalFormat[] = | 25 const char kDriveV2ChildrenUrlForRemovalFormat[] = |
| 25 "/drive/v2/files/%s/children/%s"; | 26 "/drive/v2/files/%s/children/%s"; |
| 26 const char kDriveV2FileCopyUrlFormat[] = "/drive/v2/files/%s/copy"; | 27 const char kDriveV2FileCopyUrlFormat[] = "/drive/v2/files/%s/copy"; |
| 27 const char kDriveV2FileDeleteUrlFormat[] = "/drive/v2/files/%s"; | 28 const char kDriveV2FileDeleteUrlFormat[] = "/drive/v2/files/%s"; |
| 28 const char kDriveV2FileTrashUrlFormat[] = "/drive/v2/files/%s/trash"; | 29 const char kDriveV2FileTrashUrlFormat[] = "/drive/v2/files/%s/trash"; |
| 29 const char kDriveV2InitiateUploadNewFileUrl[] = "/upload/drive/v2/files"; | 30 const char kDriveV2InitiateUploadNewFileUrl[] = "/upload/drive/v2/files"; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 53 "https://www.googledrive.com/host/"; | 54 "https://www.googledrive.com/host/"; |
| 54 | 55 |
| 55 GURL DriveApiUrlGenerator::GetAboutGetUrl() const { | 56 GURL DriveApiUrlGenerator::GetAboutGetUrl() const { |
| 56 return base_url_.Resolve(kDriveV2AboutUrl); | 57 return base_url_.Resolve(kDriveV2AboutUrl); |
| 57 } | 58 } |
| 58 | 59 |
| 59 GURL DriveApiUrlGenerator::GetAppsListUrl() const { | 60 GURL DriveApiUrlGenerator::GetAppsListUrl() const { |
| 60 return base_url_.Resolve(kDriveV2AppsUrl); | 61 return base_url_.Resolve(kDriveV2AppsUrl); |
| 61 } | 62 } |
| 62 | 63 |
| 64 GURL DriveApiUrlGenerator::GetAppsDeleteUrl(const std::string& app_id) const { | |
| 65 return base_url_.Resolve(base::StringPrintf( | |
| 66 kDriveV2AppsDeleteUrlFormat, net::EscapePath(app_id).c_str())); | |
| 67 } | |
| 68 | |
| 63 GURL DriveApiUrlGenerator::GetFilesGetUrl(const std::string& file_id) const { | 69 GURL DriveApiUrlGenerator::GetFilesGetUrl(const std::string& file_id) const { |
| 64 return base_url_.Resolve(kDriveV2FileUrlPrefix + net::EscapePath(file_id)); | 70 return base_url_.Resolve(kDriveV2FileUrlPrefix + net::EscapePath(file_id)); |
| 65 } | 71 } |
| 66 | 72 |
| 67 GURL DriveApiUrlGenerator::GetFilesInsertUrl() const { | 73 GURL DriveApiUrlGenerator::GetFilesInsertUrl() const { |
| 68 return base_url_.Resolve(kDriveV2FilesUrl); | 74 return base_url_.Resolve(kDriveV2FilesUrl); |
| 69 } | 75 } |
| 70 | 76 |
| 71 GURL DriveApiUrlGenerator::GetFilesPatchUrl(const std::string& file_id, | 77 GURL DriveApiUrlGenerator::GetFilesPatchUrl(const std::string& file_id, |
| 72 bool set_modified_date, | 78 bool set_modified_date, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 net::EscapePath(resource_id)); | 180 net::EscapePath(resource_id)); |
| 175 return AddResumableUploadParam(url); | 181 return AddResumableUploadParam(url); |
| 176 } | 182 } |
| 177 | 183 |
| 178 GURL DriveApiUrlGenerator::GenerateDownloadFileUrl( | 184 GURL DriveApiUrlGenerator::GenerateDownloadFileUrl( |
| 179 const std::string& resource_id) const { | 185 const std::string& resource_id) const { |
| 180 return base_download_url_.Resolve(net::EscapePath(resource_id)); | 186 return base_download_url_.Resolve(net::EscapePath(resource_id)); |
| 181 } | 187 } |
| 182 | 188 |
| 183 } // namespace google_apis | 189 } // namespace google_apis |
| OLD | NEW |