OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/google_apis/drive_api_url_generator.h" |
| 6 |
| 7 #include "base/string_number_conversions.h" |
| 8 #include "base/stringprintf.h" |
| 9 #include "chrome/common/net/url_util.h" |
| 10 |
| 11 namespace google_apis { |
| 12 |
| 13 namespace { |
| 14 |
| 15 // Hard coded URLs for communication with a google drive server. |
| 16 const char kDriveV2AboutUrl[] = "https://www.googleapis.com/drive/v2/about"; |
| 17 const char kDriveV2ApplistUrl[] = "https://www.googleapis.com/drive/v2/apps"; |
| 18 const char kDriveV2ChangelistUrl[] = |
| 19 "https://www.googleapis.com/drive/v2/changes"; |
| 20 |
| 21 const char kDriveV2FilelistUrl[] = "https://www.googleapis.com/drive/v2/files"; |
| 22 const char kDriveV2FileUrlFormat[] = |
| 23 "https://www.googleapis.com/drive/v2/files/%s"; |
| 24 |
| 25 } // namespace |
| 26 |
| 27 DriveApiUrlGenerator::DriveApiUrlGenerator() { |
| 28 // Do nothing. |
| 29 } |
| 30 |
| 31 DriveApiUrlGenerator::~DriveApiUrlGenerator() { |
| 32 // Do nothing. |
| 33 } |
| 34 |
| 35 GURL DriveApiUrlGenerator::GetAboutUrl() const { |
| 36 return GURL(kDriveV2AboutUrl); |
| 37 } |
| 38 |
| 39 GURL DriveApiUrlGenerator::GetApplistUrl() const { |
| 40 return GURL(kDriveV2ApplistUrl); |
| 41 } |
| 42 |
| 43 GURL DriveApiUrlGenerator::GetChangelistUrl( |
| 44 const GURL& override_url, int64 start_changestamp) const { |
| 45 // Use override_url if not empty, |
| 46 // otherwise use the default url (kDriveV2Changelisturl). |
| 47 const GURL& url = |
| 48 override_url.is_empty() ? GURL(kDriveV2ChangelistUrl) : override_url; |
| 49 return start_changestamp ? |
| 50 chrome_common_net::AppendOrReplaceQueryParameter( |
| 51 url, "startChangeId", base::Int64ToString(start_changestamp)) : |
| 52 url; |
| 53 } |
| 54 |
| 55 GURL DriveApiUrlGenerator::GetFilelistUrl( |
| 56 const GURL& override_url, const std::string& search_string) const { |
| 57 // Use override_url if not empty, |
| 58 // otherwise use the default url (kDriveV2FilelistUrl). |
| 59 const GURL& url = |
| 60 override_url.is_empty() ? GURL(kDriveV2FilelistUrl) : override_url; |
| 61 |
| 62 return search_string.empty() ? |
| 63 url : |
| 64 chrome_common_net::AppendOrReplaceQueryParameter( |
| 65 url, "q", search_string); |
| 66 } |
| 67 |
| 68 GURL DriveApiUrlGenerator::GetFileUrl(const std::string& file_id) const { |
| 69 return GURL(base::StringPrintf(kDriveV2FileUrlFormat, file_id.c_str())); |
| 70 } |
| 71 |
| 72 } // namespace google_apis |
OLD | NEW |