| 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/gdata_wapi_url_generator.h" | 5 #include "chrome/browser/google_apis/gdata_wapi_url_generator.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "base/strings/string_number_conversions.h" |
| 9 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| 10 #include "net/base/escape.h" | 11 #include "net/base/escape.h" |
| 11 #include "net/base/url_util.h" | 12 #include "net/base/url_util.h" |
| 12 | 13 |
| 13 namespace google_apis { | 14 namespace google_apis { |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 // Content URL for modification or resource list retrieval in a particular | 17 // Content URL for modification or resource list retrieval in a particular |
| 17 // directory specified by "%s" which will be replaced with its resource id. | 18 // directory specified by "%s" which will be replaced with its resource id. |
| 18 const char kContentURLFormat[] = "/feeds/default/private/full/%s/contents"; | 19 const char kContentURLFormat[] = "/feeds/default/private/full/%s/contents"; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // static | 68 // static |
| 68 GURL GDataWapiUrlGenerator::AddInitiateUploadUrlParams(const GURL& url) { | 69 GURL GDataWapiUrlGenerator::AddInitiateUploadUrlParams(const GURL& url) { |
| 69 GURL result = net::AppendOrReplaceQueryParameter(url, "convert", "false"); | 70 GURL result = net::AppendOrReplaceQueryParameter(url, "convert", "false"); |
| 70 return AddStandardUrlParams(result); | 71 return AddStandardUrlParams(result); |
| 71 } | 72 } |
| 72 | 73 |
| 73 // static | 74 // static |
| 74 GURL GDataWapiUrlGenerator::AddFeedUrlParams( | 75 GURL GDataWapiUrlGenerator::AddFeedUrlParams( |
| 75 const GURL& url, | 76 const GURL& url, |
| 76 int num_items_to_fetch, | 77 int num_items_to_fetch, |
| 77 int changestamp, | 78 int64 changestamp, |
| 78 const std::string& search_string) { | 79 const std::string& search_string) { |
| 79 GURL result = AddStandardUrlParams(url); | 80 GURL result = AddStandardUrlParams(url); |
| 80 result = net::AppendOrReplaceQueryParameter(result, "showfolders", "true"); | 81 result = net::AppendOrReplaceQueryParameter(result, "showfolders", "true"); |
| 81 result = net::AppendOrReplaceQueryParameter(result, "include-shared", "true"); | 82 result = net::AppendOrReplaceQueryParameter(result, "include-shared", "true"); |
| 82 result = net::AppendOrReplaceQueryParameter( | 83 result = net::AppendOrReplaceQueryParameter( |
| 83 result, | 84 result, "max-results", base::IntToString(num_items_to_fetch)); |
| 84 "max-results", | |
| 85 base::StringPrintf("%d", num_items_to_fetch)); | |
| 86 result = net::AppendOrReplaceQueryParameter( | |
| 87 result, "include-installed-apps", "true"); | |
| 88 | 85 |
| 89 if (changestamp) { | 86 if (changestamp) { |
| 90 result = net::AppendQueryParameter(result, | 87 result = net::AppendQueryParameter( |
| 91 "start-index", | 88 result, "start-index", base::Int64ToString(changestamp)); |
| 92 base::StringPrintf("%d", changestamp)); | |
| 93 } | 89 } |
| 94 | 90 |
| 95 if (!search_string.empty()) { | 91 if (!search_string.empty()) { |
| 96 result = net::AppendOrReplaceQueryParameter(result, "q", search_string); | 92 result = net::AppendOrReplaceQueryParameter(result, "q", search_string); |
| 97 } | 93 } |
| 98 return result; | 94 return result; |
| 99 } | 95 } |
| 100 | 96 |
| 101 GDataWapiUrlGenerator::GDataWapiUrlGenerator(const GURL& base_url) | 97 GDataWapiUrlGenerator::GDataWapiUrlGenerator(const GURL& base_url) |
| 102 : base_url_(GURL(base_url)) { | 98 : base_url_(GURL(base_url)) { |
| 103 } | 99 } |
| 104 | 100 |
| 105 GDataWapiUrlGenerator::~GDataWapiUrlGenerator() { | 101 GDataWapiUrlGenerator::~GDataWapiUrlGenerator() { |
| 106 } | 102 } |
| 107 | 103 |
| 108 GURL GDataWapiUrlGenerator::GenerateResourceListUrl( | 104 GURL GDataWapiUrlGenerator::GenerateResourceListUrl( |
| 109 const GURL& override_url, | 105 const GURL& override_url, |
| 110 int start_changestamp, | 106 int64 start_changestamp, |
| 111 const std::string& search_string, | 107 const std::string& search_string, |
| 112 const std::string& directory_resource_id) const { | 108 const std::string& directory_resource_id) const { |
| 113 DCHECK_LE(0, start_changestamp); | 109 DCHECK_LE(0, start_changestamp); |
| 114 | 110 |
| 115 int max_docs = search_string.empty() ? kMaxDocumentsPerFeed : | 111 int max_docs = search_string.empty() ? kMaxDocumentsPerFeed : |
| 116 kMaxDocumentsPerSearchFeed; | 112 kMaxDocumentsPerSearchFeed; |
| 117 GURL url; | 113 GURL url; |
| 118 if (!override_url.is_empty()) { | 114 if (!override_url.is_empty()) { |
| 119 // |override_url| specifies the URL of the continuation feed when the feed | 115 // |override_url| specifies the URL of the continuation feed when the feed |
| 120 // is broken up to multiple chunks. In this case we must not add the | 116 // is broken up to multiple chunks. In this case we must not add the |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 bool include_installed_apps) const { | 194 bool include_installed_apps) const { |
| 199 GURL result = AddStandardUrlParams(base_url_.Resolve(kAccountMetadataURL)); | 195 GURL result = AddStandardUrlParams(base_url_.Resolve(kAccountMetadataURL)); |
| 200 if (include_installed_apps) { | 196 if (include_installed_apps) { |
| 201 result = net::AppendOrReplaceQueryParameter( | 197 result = net::AppendOrReplaceQueryParameter( |
| 202 result, "include-installed-apps", "true"); | 198 result, "include-installed-apps", "true"); |
| 203 } | 199 } |
| 204 return result; | 200 return result; |
| 205 } | 201 } |
| 206 | 202 |
| 207 } // namespace google_apis | 203 } // namespace google_apis |
| OLD | NEW |