| 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/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "chrome/common/net/url_util.h" | 9 #include "net/base/url_util.h" |
| 10 | 10 |
| 11 namespace google_apis { | 11 namespace google_apis { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 // Hard coded URLs for communication with a google drive server. | 15 // Hard coded URLs for communication with a google drive server. |
| 16 const char kDriveV2AboutUrl[] = "/drive/v2/about"; | 16 const char kDriveV2AboutUrl[] = "/drive/v2/about"; |
| 17 const char kDriveV2ApplistUrl[] = "/drive/v2/apps"; | 17 const char kDriveV2ApplistUrl[] = "/drive/v2/apps"; |
| 18 const char kDriveV2ChangelistUrl[] = "/drive/v2/changes"; | 18 const char kDriveV2ChangelistUrl[] = "/drive/v2/changes"; |
| 19 const char kDriveV2FilelistUrl[] = "/drive/v2/files"; | 19 const char kDriveV2FilelistUrl[] = "/drive/v2/files"; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 42 } | 42 } |
| 43 | 43 |
| 44 GURL DriveApiUrlGenerator::GetChangelistUrl( | 44 GURL DriveApiUrlGenerator::GetChangelistUrl( |
| 45 const GURL& override_url, int64 start_changestamp) const { | 45 const GURL& override_url, int64 start_changestamp) const { |
| 46 // Use override_url if not empty, | 46 // Use override_url if not empty, |
| 47 // otherwise use the default url (kDriveV2Changelisturl based on base_url_). | 47 // otherwise use the default url (kDriveV2Changelisturl based on base_url_). |
| 48 const GURL& url = override_url.is_empty() ? | 48 const GURL& url = override_url.is_empty() ? |
| 49 base_url_.Resolve(kDriveV2ChangelistUrl) : | 49 base_url_.Resolve(kDriveV2ChangelistUrl) : |
| 50 override_url; | 50 override_url; |
| 51 return start_changestamp ? | 51 return start_changestamp ? |
| 52 chrome_common_net::AppendOrReplaceQueryParameter( | 52 net::AppendOrReplaceQueryParameter( |
| 53 url, "startChangeId", base::Int64ToString(start_changestamp)) : | 53 url, "startChangeId", base::Int64ToString(start_changestamp)) : |
| 54 url; | 54 url; |
| 55 } | 55 } |
| 56 | 56 |
| 57 GURL DriveApiUrlGenerator::GetFilelistUrl( | 57 GURL DriveApiUrlGenerator::GetFilelistUrl( |
| 58 const GURL& override_url, const std::string& search_string) const { | 58 const GURL& override_url, const std::string& search_string) const { |
| 59 // Use override_url if not empty, | 59 // Use override_url if not empty, |
| 60 // otherwise use the default url (kDriveV2FilelistUrl based on base_url_). | 60 // otherwise use the default url (kDriveV2FilelistUrl based on base_url_). |
| 61 const GURL& url = override_url.is_empty() ? | 61 const GURL& url = override_url.is_empty() ? |
| 62 base_url_.Resolve(kDriveV2FilelistUrl) : | 62 base_url_.Resolve(kDriveV2FilelistUrl) : |
| 63 override_url; | 63 override_url; |
| 64 return search_string.empty() ? | 64 return search_string.empty() ? |
| 65 url : | 65 url : |
| 66 chrome_common_net::AppendOrReplaceQueryParameter( | 66 net::AppendOrReplaceQueryParameter(url, "q", search_string); |
| 67 url, "q", search_string); | |
| 68 } | 67 } |
| 69 | 68 |
| 70 GURL DriveApiUrlGenerator::GetFileUrl(const std::string& file_id) const { | 69 GURL DriveApiUrlGenerator::GetFileUrl(const std::string& file_id) const { |
| 71 return base_url_.Resolve( | 70 return base_url_.Resolve( |
| 72 base::StringPrintf(kDriveV2FileUrlFormat, file_id.c_str())); | 71 base::StringPrintf(kDriveV2FileUrlFormat, file_id.c_str())); |
| 73 } | 72 } |
| 74 | 73 |
| 75 } // namespace google_apis | 74 } // namespace google_apis |
| OLD | NEW |