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" |
(...skipping 15 matching lines...) Expand all Loading... |
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[] = |
30 "/upload/drive/v2/files/"; | 30 "/upload/drive/v2/files/"; |
31 | 31 |
32 GURL AddResumableUploadParam(const GURL& url) { | 32 GURL AddResumableUploadParam(const GURL& url) { |
33 return net::AppendOrReplaceQueryParameter(url, "uploadType", "resumable"); | 33 return net::AppendOrReplaceQueryParameter(url, "uploadType", "resumable"); |
34 } | 34 } |
35 | 35 |
36 GURL AddMaxResultParam(const GURL& url, int max_results) { | |
37 DCHECK_GT(max_results, 0); | |
38 return net::AppendOrReplaceQueryParameter( | |
39 url, "maxResults", base::IntToString(max_results)); | |
40 } | |
41 | |
42 } // namespace | 36 } // namespace |
43 | 37 |
44 DriveApiUrlGenerator::DriveApiUrlGenerator(const GURL& base_url, | 38 DriveApiUrlGenerator::DriveApiUrlGenerator(const GURL& base_url, |
45 const GURL& base_download_url) | 39 const GURL& base_download_url) |
46 : base_url_(base_url), | 40 : base_url_(base_url), |
47 base_download_url_(base_download_url) { | 41 base_download_url_(base_download_url) { |
48 // Do nothing. | 42 // Do nothing. |
49 } | 43 } |
50 | 44 |
51 DriveApiUrlGenerator::~DriveApiUrlGenerator() { | 45 DriveApiUrlGenerator::~DriveApiUrlGenerator() { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 net::EscapePath(resource_id)); | 168 net::EscapePath(resource_id)); |
175 return AddResumableUploadParam(url); | 169 return AddResumableUploadParam(url); |
176 } | 170 } |
177 | 171 |
178 GURL DriveApiUrlGenerator::GenerateDownloadFileUrl( | 172 GURL DriveApiUrlGenerator::GenerateDownloadFileUrl( |
179 const std::string& resource_id) const { | 173 const std::string& resource_id) const { |
180 return base_download_url_.Resolve(net::EscapePath(resource_id)); | 174 return base_download_url_.Resolve(net::EscapePath(resource_id)); |
181 } | 175 } |
182 | 176 |
183 } // namespace google_apis | 177 } // namespace google_apis |
OLD | NEW |