| 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 "chrome/browser/google_apis/drive_api_url_generator.h" | 5 #include "chrome/browser/google_apis/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 kDriveV2ApplistUrl[] = "/drive/v2/apps"; | 19 const char kDriveV2AppsUrl[] = "/drive/v2/apps"; |
| 20 const char kDriveV2ChangelistUrl[] = "/drive/v2/changes"; | 20 const char kDriveV2ChangelistUrl[] = "/drive/v2/changes"; |
| 21 const char kDriveV2FilesUrl[] = "/drive/v2/files"; | 21 const char kDriveV2FilesUrl[] = "/drive/v2/files"; |
| 22 const char kDriveV2FileUrlPrefix[] = "/drive/v2/files/"; | 22 const char kDriveV2FileUrlPrefix[] = "/drive/v2/files/"; |
| 23 const char kDriveV2ChildrenUrlFormat[] = "/drive/v2/files/%s/children"; | 23 const char kDriveV2ChildrenUrlFormat[] = "/drive/v2/files/%s/children"; |
| 24 const char kDriveV2ChildrenUrlForRemovalFormat[] = | 24 const char kDriveV2ChildrenUrlForRemovalFormat[] = |
| 25 "/drive/v2/files/%s/children/%s"; | 25 "/drive/v2/files/%s/children/%s"; |
| 26 const char kDriveV2FileCopyUrlFormat[] = "/drive/v2/files/%s/copy"; | 26 const char kDriveV2FileCopyUrlFormat[] = "/drive/v2/files/%s/copy"; |
| 27 const char kDriveV2FileTrashUrlFormat[] = "/drive/v2/files/%s/trash"; | 27 const char kDriveV2FileTrashUrlFormat[] = "/drive/v2/files/%s/trash"; |
| 28 const char kDriveV2InitiateUploadNewFileUrl[] = "/upload/drive/v2/files"; | 28 const char kDriveV2InitiateUploadNewFileUrl[] = "/upload/drive/v2/files"; |
| 29 const char kDriveV2InitiateUploadExistingFileUrlPrefix[] = | 29 const char kDriveV2InitiateUploadExistingFileUrlPrefix[] = |
| (...skipping 20 matching lines...) Expand all Loading... |
| 50 | 50 |
| 51 DriveApiUrlGenerator::~DriveApiUrlGenerator() { | 51 DriveApiUrlGenerator::~DriveApiUrlGenerator() { |
| 52 // Do nothing. | 52 // Do nothing. |
| 53 } | 53 } |
| 54 | 54 |
| 55 const char DriveApiUrlGenerator::kBaseUrlForProduction[] = | 55 const char DriveApiUrlGenerator::kBaseUrlForProduction[] = |
| 56 "https://www.googleapis.com"; | 56 "https://www.googleapis.com"; |
| 57 const char DriveApiUrlGenerator::kBaseDownloadUrlForProduction[] = | 57 const char DriveApiUrlGenerator::kBaseDownloadUrlForProduction[] = |
| 58 "https://www.googledrive.com/host/"; | 58 "https://www.googledrive.com/host/"; |
| 59 | 59 |
| 60 GURL DriveApiUrlGenerator::GetAboutUrl() const { | 60 GURL DriveApiUrlGenerator::GetAboutGetUrl() const { |
| 61 return base_url_.Resolve(kDriveV2AboutUrl); | 61 return base_url_.Resolve(kDriveV2AboutUrl); |
| 62 } | 62 } |
| 63 | 63 |
| 64 GURL DriveApiUrlGenerator::GetApplistUrl() const { | 64 GURL DriveApiUrlGenerator::GetAppsListUrl() const { |
| 65 return base_url_.Resolve(kDriveV2ApplistUrl); | 65 return base_url_.Resolve(kDriveV2AppsUrl); |
| 66 } | 66 } |
| 67 | 67 |
| 68 GURL DriveApiUrlGenerator::GetChangelistUrl( | 68 GURL DriveApiUrlGenerator::GetChangelistUrl( |
| 69 bool include_deleted, int64 start_changestamp, int max_results) const { | 69 bool include_deleted, int64 start_changestamp, int max_results) const { |
| 70 DCHECK_GE(start_changestamp, 0); | 70 DCHECK_GE(start_changestamp, 0); |
| 71 | 71 |
| 72 GURL url = base_url_.Resolve(kDriveV2ChangelistUrl); | 72 GURL url = base_url_.Resolve(kDriveV2ChangelistUrl); |
| 73 if (!include_deleted) { | 73 if (!include_deleted) { |
| 74 // If include_deleted is set to "false", set the query parameter, | 74 // If include_deleted is set to "false", set the query parameter, |
| 75 // because its default parameter is "true". | 75 // because its default parameter is "true". |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 net::EscapePath(resource_id)); | 156 net::EscapePath(resource_id)); |
| 157 return AddResumableUploadParam(url); | 157 return AddResumableUploadParam(url); |
| 158 } | 158 } |
| 159 | 159 |
| 160 GURL DriveApiUrlGenerator::GenerateDownloadFileUrl( | 160 GURL DriveApiUrlGenerator::GenerateDownloadFileUrl( |
| 161 const std::string& resource_id) const { | 161 const std::string& resource_id) const { |
| 162 return base_download_url_.Resolve(net::EscapePath(resource_id)); | 162 return base_download_url_.Resolve(net::EscapePath(resource_id)); |
| 163 } | 163 } |
| 164 | 164 |
| 165 } // namespace google_apis | 165 } // namespace google_apis |
| OLD | NEW |