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

Side by Side Diff: chrome/browser/google_apis/gdata_wapi_url_generator.cc

Issue 12069004: google_apis: Move AppendQueryParameter() etc. from common/net/url_util.h to net/base/url_util.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
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 "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 "chrome/common/net/url_util.h"
10 #include "googleurl/src/gurl.h" 9 #include "googleurl/src/gurl.h"
11 #include "net/base/escape.h" 10 #include "net/base/escape.h"
11 #include "net/base/url_util.h"
12 12
13 namespace google_apis { 13 namespace google_apis {
14 namespace { 14 namespace {
15 15
16 // URL requesting resource list that belong to the authenticated user only 16 // URL requesting resource list that belong to the authenticated user only
17 // (handled with '/-/mine' part). 17 // (handled with '/-/mine' part).
18 const char kGetResourceListURLForAllDocuments[] = 18 const char kGetResourceListURLForAllDocuments[] =
19 "/feeds/default/private/full/-/mine"; 19 "/feeds/default/private/full/-/mine";
20 20
21 // URL requesting resource list in a particular directory specified by "%s" 21 // URL requesting resource list in a particular directory specified by "%s"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // URL requesting documents list of changes to documents collections. 59 // URL requesting documents list of changes to documents collections.
60 const char kGetChangesListURL[] = "/feeds/default/private/changes"; 60 const char kGetChangesListURL[] = "/feeds/default/private/changes";
61 61
62 } // namespace 62 } // namespace
63 63
64 const char GDataWapiUrlGenerator::kBaseUrlForProduction[] = 64 const char GDataWapiUrlGenerator::kBaseUrlForProduction[] =
65 "https://docs.google.com/"; 65 "https://docs.google.com/";
66 66
67 // static 67 // static
68 GURL GDataWapiUrlGenerator::AddStandardUrlParams(const GURL& url) { 68 GURL GDataWapiUrlGenerator::AddStandardUrlParams(const GURL& url) {
69 GURL result = 69 GURL result = net::AppendOrReplaceQueryParameter(url, "v", "3");
70 chrome_common_net::AppendOrReplaceQueryParameter(url, "v", "3"); 70 result = net::AppendOrReplaceQueryParameter(result, "alt", "json");
71 result =
72 chrome_common_net::AppendOrReplaceQueryParameter(result, "alt", "json");
73 return result; 71 return result;
74 } 72 }
75 73
76 // static 74 // static
77 GURL GDataWapiUrlGenerator::AddMetadataUrlParams(const GURL& url) { 75 GURL GDataWapiUrlGenerator::AddMetadataUrlParams(const GURL& url) {
78 GURL result = AddStandardUrlParams(url); 76 GURL result = AddStandardUrlParams(url);
79 result = chrome_common_net::AppendOrReplaceQueryParameter( 77 result = net::AppendOrReplaceQueryParameter(
80 result, "include-installed-apps", "true"); 78 result, "include-installed-apps", "true");
81 return result; 79 return result;
82 } 80 }
83 81
84 // static 82 // static
85 GURL GDataWapiUrlGenerator::AddFeedUrlParams( 83 GURL GDataWapiUrlGenerator::AddFeedUrlParams(
86 const GURL& url, 84 const GURL& url,
87 int num_items_to_fetch, 85 int num_items_to_fetch,
88 int changestamp, 86 int changestamp,
89 const std::string& search_string) { 87 const std::string& search_string) {
90 GURL result = AddStandardUrlParams(url); 88 GURL result = AddStandardUrlParams(url);
91 result = chrome_common_net::AppendOrReplaceQueryParameter( 89 result = net::AppendOrReplaceQueryParameter(result, "showfolders", "true");
92 result, 90 result = net::AppendOrReplaceQueryParameter(
93 "showfolders",
94 "true");
95 result = chrome_common_net::AppendOrReplaceQueryParameter(
96 result, 91 result,
97 "max-results", 92 "max-results",
98 base::StringPrintf("%d", num_items_to_fetch)); 93 base::StringPrintf("%d", num_items_to_fetch));
99 result = chrome_common_net::AppendOrReplaceQueryParameter( 94 result = net::AppendOrReplaceQueryParameter(
100 result, "include-installed-apps", "true"); 95 result, "include-installed-apps", "true");
101 96
102 if (changestamp) { 97 if (changestamp) {
103 result = chrome_common_net::AppendQueryParameter( 98 result = net::AppendQueryParameter(result,
104 result, 99 "start-index",
105 "start-index", 100 base::StringPrintf("%d", changestamp));
106 base::StringPrintf("%d", changestamp));
107 } 101 }
108 102
109 if (!search_string.empty()) { 103 if (!search_string.empty()) {
110 result = chrome_common_net::AppendOrReplaceQueryParameter( 104 result = net::AppendOrReplaceQueryParameter(result, "q", search_string);
111 result, "q", search_string);
112 } 105 }
113 return result; 106 return result;
114 } 107 }
115 108
116 GDataWapiUrlGenerator::GDataWapiUrlGenerator(const GURL& base_url) 109 GDataWapiUrlGenerator::GDataWapiUrlGenerator(const GURL& base_url)
117 : base_url_(GURL(base_url)) { 110 : base_url_(GURL(base_url)) {
118 } 111 }
119 112
120 GDataWapiUrlGenerator::~GDataWapiUrlGenerator() { 113 GDataWapiUrlGenerator::~GDataWapiUrlGenerator() {
121 } 114 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 190
198 GURL GDataWapiUrlGenerator::GenerateResourceListRootUrl() const { 191 GURL GDataWapiUrlGenerator::GenerateResourceListRootUrl() const {
199 return AddStandardUrlParams(base_url_.Resolve(kResourceListRootURL)); 192 return AddStandardUrlParams(base_url_.Resolve(kResourceListRootURL));
200 } 193 }
201 194
202 GURL GDataWapiUrlGenerator::GenerateAccountMetadataUrl() const { 195 GURL GDataWapiUrlGenerator::GenerateAccountMetadataUrl() const {
203 return AddMetadataUrlParams(base_url_.Resolve(kAccountMetadataURL)); 196 return AddMetadataUrlParams(base_url_.Resolve(kAccountMetadataURL));
204 } 197 }
205 198
206 } // namespace google_apis 199 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/gdata_wapi_service.cc ('k') | chrome/browser/intents/cws_intents_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698