| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 "https://www.googledrive.com/host/"; | 58 "https://www.googledrive.com/host/"; |
| 59 | 59 |
| 60 GURL DriveApiUrlGenerator::GetAboutGetUrl() 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::GetAppsListUrl() const { | 64 GURL DriveApiUrlGenerator::GetAppsListUrl() const { |
| 65 return base_url_.Resolve(kDriveV2AppsUrl); | 65 return base_url_.Resolve(kDriveV2AppsUrl); |
| 66 } | 66 } |
| 67 | 67 |
| 68 GURL DriveApiUrlGenerator::GetChangelistUrl( | |
| 69 bool include_deleted, int64 start_changestamp, int max_results) const { | |
| 70 DCHECK_GE(start_changestamp, 0); | |
| 71 | |
| 72 GURL url = base_url_.Resolve(kDriveV2ChangelistUrl); | |
| 73 if (!include_deleted) { | |
| 74 // If include_deleted is set to "false", set the query parameter, | |
| 75 // because its default parameter is "true". | |
| 76 url = net::AppendOrReplaceQueryParameter(url, "includeDeleted", "false"); | |
| 77 } | |
| 78 | |
| 79 if (start_changestamp > 0) { | |
| 80 url = net::AppendOrReplaceQueryParameter( | |
| 81 url, "startChangeId", base::Int64ToString(start_changestamp)); | |
| 82 } | |
| 83 | |
| 84 return AddMaxResultParam(url, max_results); | |
| 85 } | |
| 86 | |
| 87 GURL DriveApiUrlGenerator::GetFilesUrl() const { | 68 GURL DriveApiUrlGenerator::GetFilesUrl() const { |
| 88 return base_url_.Resolve(kDriveV2FilesUrl); | 69 return base_url_.Resolve(kDriveV2FilesUrl); |
| 89 } | 70 } |
| 90 | 71 |
| 91 GURL DriveApiUrlGenerator::GetFilesGetUrl(const std::string& file_id) const { | 72 GURL DriveApiUrlGenerator::GetFilesGetUrl(const std::string& file_id) const { |
| 92 return base_url_.Resolve(kDriveV2FileUrlPrefix + net::EscapePath(file_id)); | 73 return base_url_.Resolve(kDriveV2FileUrlPrefix + net::EscapePath(file_id)); |
| 93 } | 74 } |
| 94 | 75 |
| 95 GURL DriveApiUrlGenerator::GetFilesPatchUrl(const std::string& file_id, | 76 GURL DriveApiUrlGenerator::GetFilesPatchUrl(const std::string& file_id, |
| 96 bool set_modified_date, | 77 bool set_modified_date, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 131 |
| 151 return url; | 132 return url; |
| 152 } | 133 } |
| 153 | 134 |
| 154 GURL DriveApiUrlGenerator::GetFileTrashUrl(const std::string& file_id) const { | 135 GURL DriveApiUrlGenerator::GetFileTrashUrl(const std::string& file_id) const { |
| 155 return base_url_.Resolve( | 136 return base_url_.Resolve( |
| 156 base::StringPrintf(kDriveV2FileTrashUrlFormat, | 137 base::StringPrintf(kDriveV2FileTrashUrlFormat, |
| 157 net::EscapePath(file_id).c_str())); | 138 net::EscapePath(file_id).c_str())); |
| 158 } | 139 } |
| 159 | 140 |
| 141 GURL DriveApiUrlGenerator::GetChangesListUrl(bool include_deleted, |
| 142 int max_results, |
| 143 const std::string& page_token, |
| 144 int64 start_change_id) const { |
| 145 DCHECK_GE(start_change_id, 0); |
| 146 |
| 147 GURL url = base_url_.Resolve(kDriveV2ChangelistUrl); |
| 148 |
| 149 // includeDeleted is "true" by default. |
| 150 if (!include_deleted) |
| 151 url = net::AppendOrReplaceQueryParameter(url, "includeDeleted", "false"); |
| 152 |
| 153 // maxResults is "100" by default. |
| 154 if (max_results != 100) { |
| 155 url = net::AppendOrReplaceQueryParameter( |
| 156 url, "maxResults", base::IntToString(max_results)); |
| 157 } |
| 158 |
| 159 if (!page_token.empty()) |
| 160 url = net::AppendOrReplaceQueryParameter(url, "pageToken", page_token); |
| 161 |
| 162 if (start_change_id > 0) |
| 163 url = net::AppendOrReplaceQueryParameter( |
| 164 url, "startChangeId", base::Int64ToString(start_change_id)); |
| 165 |
| 166 return url; |
| 167 } |
| 168 |
| 160 GURL DriveApiUrlGenerator::GetChildrenUrl( | 169 GURL DriveApiUrlGenerator::GetChildrenUrl( |
| 161 const std::string& resource_id) const { | 170 const std::string& resource_id) const { |
| 162 return base_url_.Resolve( | 171 return base_url_.Resolve( |
| 163 base::StringPrintf(kDriveV2ChildrenUrlFormat, | 172 base::StringPrintf(kDriveV2ChildrenUrlFormat, |
| 164 net::EscapePath(resource_id).c_str())); | 173 net::EscapePath(resource_id).c_str())); |
| 165 } | 174 } |
| 166 | 175 |
| 167 GURL DriveApiUrlGenerator::GetChildrenUrlForRemoval( | 176 GURL DriveApiUrlGenerator::GetChildrenUrlForRemoval( |
| 168 const std::string& folder_id, const std::string& child_id) const { | 177 const std::string& folder_id, const std::string& child_id) const { |
| 169 return base_url_.Resolve( | 178 return base_url_.Resolve( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 184 net::EscapePath(resource_id)); | 193 net::EscapePath(resource_id)); |
| 185 return AddResumableUploadParam(url); | 194 return AddResumableUploadParam(url); |
| 186 } | 195 } |
| 187 | 196 |
| 188 GURL DriveApiUrlGenerator::GenerateDownloadFileUrl( | 197 GURL DriveApiUrlGenerator::GenerateDownloadFileUrl( |
| 189 const std::string& resource_id) const { | 198 const std::string& resource_id) const { |
| 190 return base_download_url_.Resolve(net::EscapePath(resource_id)); | 199 return base_download_url_.Resolve(net::EscapePath(resource_id)); |
| 191 } | 200 } |
| 192 | 201 |
| 193 } // namespace google_apis | 202 } // namespace google_apis |
| OLD | NEW |