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

Unified Diff: chrome/browser/google_apis/drive_api_url_generator.cc

Issue 11804004: Add base_url to DriveApiUrlGenerator. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Introduce kBaseUrlForProduction in DriveApiUrlGenerator Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/google_apis/drive_api_url_generator.cc
diff --git a/chrome/browser/google_apis/drive_api_url_generator.cc b/chrome/browser/google_apis/drive_api_url_generator.cc
index 52c4b2aaef26aeaa5cf7f4ce8684a655287b1063..1c2c9f09dc35d9e4875452341af7a1dd25c7bd7e 100644
--- a/chrome/browser/google_apis/drive_api_url_generator.cc
+++ b/chrome/browser/google_apis/drive_api_url_generator.cc
@@ -13,18 +13,16 @@ namespace google_apis {
namespace {
// Hard coded URLs for communication with a google drive server.
-const char kDriveV2AboutUrl[] = "https://www.googleapis.com/drive/v2/about";
-const char kDriveV2ApplistUrl[] = "https://www.googleapis.com/drive/v2/apps";
-const char kDriveV2ChangelistUrl[] =
- "https://www.googleapis.com/drive/v2/changes";
-
-const char kDriveV2FilelistUrl[] = "https://www.googleapis.com/drive/v2/files";
-const char kDriveV2FileUrlFormat[] =
- "https://www.googleapis.com/drive/v2/files/%s";
+const char kDriveV2AboutUrl[] = "/drive/v2/about";
+const char kDriveV2ApplistUrl[] = "/drive/v2/apps";
+const char kDriveV2ChangelistUrl[] = "/drive/v2/changes";
+const char kDriveV2FilelistUrl[] = "/drive/v2/files";
+const char kDriveV2FileUrlFormat[] = "/drive/v2/files/%s";
} // namespace
-DriveApiUrlGenerator::DriveApiUrlGenerator() {
+DriveApiUrlGenerator::DriveApiUrlGenerator(const GURL& base_url)
+ : base_url_(base_url) {
// Do nothing.
}
@@ -32,20 +30,24 @@ DriveApiUrlGenerator::~DriveApiUrlGenerator() {
// Do nothing.
}
+const char DriveApiUrlGenerator::kBaseUrlForProduction[] =
+ "https://www.googleapis.com";
+
GURL DriveApiUrlGenerator::GetAboutUrl() const {
- return GURL(kDriveV2AboutUrl);
+ return base_url_.Resolve(kDriveV2AboutUrl);
}
GURL DriveApiUrlGenerator::GetApplistUrl() const {
- return GURL(kDriveV2ApplistUrl);
+ return base_url_.Resolve(kDriveV2ApplistUrl);
}
GURL DriveApiUrlGenerator::GetChangelistUrl(
const GURL& override_url, int64 start_changestamp) const {
// Use override_url if not empty,
- // otherwise use the default url (kDriveV2Changelisturl).
- const GURL& url =
- override_url.is_empty() ? GURL(kDriveV2ChangelistUrl) : override_url;
+ // otherwise use the default url (kDriveV2Changelisturl based on base_url_).
+ const GURL& url = override_url.is_empty() ?
+ base_url_.Resolve(kDriveV2ChangelistUrl) :
+ override_url;
return start_changestamp ?
chrome_common_net::AppendOrReplaceQueryParameter(
url, "startChangeId", base::Int64ToString(start_changestamp)) :
@@ -55,10 +57,10 @@ GURL DriveApiUrlGenerator::GetChangelistUrl(
GURL DriveApiUrlGenerator::GetFilelistUrl(
const GURL& override_url, const std::string& search_string) const {
// Use override_url if not empty,
- // otherwise use the default url (kDriveV2FilelistUrl).
- const GURL& url =
- override_url.is_empty() ? GURL(kDriveV2FilelistUrl) : override_url;
-
+ // otherwise use the default url (kDriveV2FilelistUrl based on base_url_).
+ const GURL& url = override_url.is_empty() ?
+ base_url_.Resolve(kDriveV2FilelistUrl) :
+ override_url;
return search_string.empty() ?
url :
chrome_common_net::AppendOrReplaceQueryParameter(
@@ -66,7 +68,8 @@ GURL DriveApiUrlGenerator::GetFilelistUrl(
}
GURL DriveApiUrlGenerator::GetFileUrl(const std::string& file_id) const {
- return GURL(base::StringPrintf(kDriveV2FileUrlFormat, file_id.c_str()));
+ return base_url_.Resolve(
+ base::StringPrintf(kDriveV2FileUrlFormat, file_id.c_str()));
}
} // namespace google_apis
« no previous file with comments | « chrome/browser/google_apis/drive_api_url_generator.h ('k') | chrome/browser/google_apis/drive_api_url_generator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698