Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: google_apis/drive/drive_api_url_generator.cc

Issue 2885323002: Add URL generator / json parser for getting start_page_token of changes. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "google_apis/drive/drive_switches.h" 11 #include "google_apis/drive/drive_switches.h"
12 #include "google_apis/google_api_keys.h" 12 #include "google_apis/google_api_keys.h"
13 #include "net/base/escape.h" 13 #include "net/base/escape.h"
14 #include "net/base/url_util.h" 14 #include "net/base/url_util.h"
15 15
16 namespace google_apis { 16 namespace google_apis {
17 17
18 namespace { 18 namespace {
19 19
20 // Hard coded URLs for communication with a google drive server. 20 // Hard coded URLs for communication with a google drive server.
21 // TODO(yamaguchi): Make a utility function to compose some of these URLs by a 21 // TODO(yamaguchi): Make a utility function to compose some of these URLs by a
22 // version and a resource name. 22 // version and a resource name.
23 const char kDriveV2AboutUrl[] = "drive/v2/about"; 23 const char kDriveV2AboutUrl[] = "drive/v2/about";
24 const char kDriveV2AppsUrl[] = "drive/v2/apps"; 24 const char kDriveV2AppsUrl[] = "drive/v2/apps";
25 const char kDriveV2ChangelistUrl[] = "drive/v2/changes"; 25 const char kDriveV2ChangelistUrl[] = "drive/v2/changes";
26 const char kDriveV2ChangesGetStartPageTokenUrl[] =
27 "drive/v2/changes/startPageToken";
26 const char kDriveV2FilesUrl[] = "drive/v2/files"; 28 const char kDriveV2FilesUrl[] = "drive/v2/files";
27 const char kDriveV2FileUrlPrefix[] = "drive/v2/files/"; 29 const char kDriveV2FileUrlPrefix[] = "drive/v2/files/";
28 const char kDriveV2ChildrenUrlFormat[] = "drive/v2/files/%s/children"; 30 const char kDriveV2ChildrenUrlFormat[] = "drive/v2/files/%s/children";
29 const char kDriveV2ChildrenUrlForRemovalFormat[] = 31 const char kDriveV2ChildrenUrlForRemovalFormat[] =
30 "drive/v2/files/%s/children/%s"; 32 "drive/v2/files/%s/children/%s";
31 const char kDriveV2FileCopyUrlFormat[] = "drive/v2/files/%s/copy"; 33 const char kDriveV2FileCopyUrlFormat[] = "drive/v2/files/%s/copy";
32 const char kDriveV2FileDeleteUrlFormat[] = "drive/v2/files/%s"; 34 const char kDriveV2FileDeleteUrlFormat[] = "drive/v2/files/%s";
33 const char kDriveV2FileTrashUrlFormat[] = "drive/v2/files/%s/trash"; 35 const char kDriveV2FileTrashUrlFormat[] = "drive/v2/files/%s/trash";
34 const char kDriveV2UploadNewFileUrl[] = "upload/drive/v2/files"; 36 const char kDriveV2UploadNewFileUrl[] = "upload/drive/v2/files";
35 const char kDriveV2UploadExistingFileUrlPrefix[] = "upload/drive/v2/files/"; 37 const char kDriveV2UploadExistingFileUrlPrefix[] = "upload/drive/v2/files/";
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } 218 }
217 219
218 GURL DriveApiUrlGenerator::GetFilesTrashUrl(const std::string& file_id) const { 220 GURL DriveApiUrlGenerator::GetFilesTrashUrl(const std::string& file_id) const {
219 GURL url = base_url_.Resolve(base::StringPrintf( 221 GURL url = base_url_.Resolve(base::StringPrintf(
220 kDriveV2FileTrashUrlFormat, net::EscapePath(file_id).c_str())); 222 kDriveV2FileTrashUrlFormat, net::EscapePath(file_id).c_str()));
221 if (enable_team_drives_) 223 if (enable_team_drives_)
222 url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true"); 224 url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true");
223 return url; 225 return url;
224 } 226 }
225 227
228 GURL DriveApiUrlGenerator::GetChangesGetStartPageTokenUrl(
229 const std::string& team_drive_id) const {
230 GURL url = base_url_.Resolve(kDriveV2ChangesGetStartPageTokenUrl);
231 if (enable_team_drives_) {
232 url = net::AppendOrReplaceQueryParameter(url, kSupportsTeamDrives, "true");
233 if (!team_drive_id.empty()) {
234 url =
235 net::AppendOrReplaceQueryParameter(url, "teamDriveId", team_drive_id);
236 }
237 }
238 return url;
239 }
240
226 GURL DriveApiUrlGenerator::GetChangesListUrl( 241 GURL DriveApiUrlGenerator::GetChangesListUrl(
227 bool include_deleted, 242 bool include_deleted,
228 int max_results, 243 int max_results,
229 const std::string& page_token, 244 const std::string& page_token,
230 int64_t start_change_id, 245 int64_t start_change_id,
231 const std::string& team_drive_id) const { 246 const std::string& team_drive_id) const {
232 DCHECK_GE(start_change_id, 0); 247 DCHECK_GE(start_change_id, 0);
233 248
234 GURL url = base_url_.Resolve(kDriveV2ChangelistUrl); 249 GURL url = base_url_.Resolve(kDriveV2ChangelistUrl);
235 if (enable_team_drives_) { 250 if (enable_team_drives_) {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 url = net::AppendOrReplaceQueryParameter(url, "maxResults", 400 url = net::AppendOrReplaceQueryParameter(url, "maxResults",
386 base::IntToString(max_results)); 401 base::IntToString(max_results));
387 } 402 }
388 if (!page_token.empty()) 403 if (!page_token.empty())
389 url = net::AppendOrReplaceQueryParameter(url, "pageToken", page_token); 404 url = net::AppendOrReplaceQueryParameter(url, "pageToken", page_token);
390 405
391 return url; 406 return url;
392 } 407 }
393 408
394 } // namespace google_apis 409 } // namespace google_apis
OLDNEW
« no previous file with comments | « google_apis/drive/drive_api_url_generator.h ('k') | google_apis/drive/drive_api_url_generator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698