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

Side by Side Diff: chrome/common/net/gaia/gaia_authenticator.cc

Issue 7046077: Revert 88510 - Escaping file names correctly. Also fixed a crush in chromeos debug build while sa... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 6 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/common/net/gaia/gaia_authenticator.h" 5 #include "chrome/common/net/gaia/gaia_authenticator.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 151
152 return PerformGaiaRequest(params, results); 152 return PerformGaiaRequest(params, results);
153 } 153 }
154 154
155 bool GaiaAuthenticator::PerformGaiaRequest(const AuthParams& params, 155 bool GaiaAuthenticator::PerformGaiaRequest(const AuthParams& params,
156 AuthResults* results) { 156 AuthResults* results) {
157 DCHECK_EQ(MessageLoop::current(), message_loop_); 157 DCHECK_EQ(MessageLoop::current(), message_loop_);
158 GURL gaia_auth_url(gaia_url_); 158 GURL gaia_auth_url(gaia_url_);
159 159
160 string post_body; 160 string post_body;
161 post_body += "Email=" + EscapeUrlEncodedData(params.email, true); 161 post_body += "Email=" + EscapeUrlEncodedData(params.email);
162 post_body += "&Passwd=" + EscapeUrlEncodedData(params.password, true); 162 post_body += "&Passwd=" + EscapeUrlEncodedData(params.password);
163 post_body += "&source=" + EscapeUrlEncodedData(user_agent_, true); 163 post_body += "&source=" + EscapeUrlEncodedData(user_agent_);
164 post_body += "&service=" + service_id_; 164 post_body += "&service=" + service_id_;
165 if (!params.captcha_token.empty() && !params.captcha_value.empty()) { 165 if (!params.captcha_token.empty() && !params.captcha_value.empty()) {
166 post_body += "&logintoken=" + 166 post_body += "&logintoken=" + EscapeUrlEncodedData(params.captcha_token);
167 EscapeUrlEncodedData(params.captcha_token, true); 167 post_body += "&logincaptcha=" + EscapeUrlEncodedData(params.captcha_value);
168 post_body += "&logincaptcha=" +
169 EscapeUrlEncodedData(params.captcha_value, true);
170 } 168 }
171 post_body += "&PersistentCookie=true"; 169 post_body += "&PersistentCookie=true";
172 // We set it to GOOGLE (and not HOSTED or HOSTED_OR_GOOGLE) because we only 170 // We set it to GOOGLE (and not HOSTED or HOSTED_OR_GOOGLE) because we only
173 // allow consumer logins. 171 // allow consumer logins.
174 post_body += "&accountType=GOOGLE"; 172 post_body += "&accountType=GOOGLE";
175 173
176 string message_text; 174 string message_text;
177 unsigned long server_response_code; 175 unsigned long server_response_code;
178 if (!Post(gaia_auth_url, post_body, &server_response_code, &message_text)) { 176 if (!Post(gaia_auth_url, post_body, &server_response_code, &message_text)) {
179 results->auth_error = ConnectionUnavailable; 177 results->auth_error = ConnectionUnavailable;
(...skipping 30 matching lines...) Expand all
210 // Use the provided Gaia server, but change the path to what V1 expects. 208 // Use the provided Gaia server, but change the path to what V1 expects.
211 GURL url(gaia_url_); // Gaia server. 209 GURL url(gaia_url_); // Gaia server.
212 GURL::Replacements repl; 210 GURL::Replacements repl;
213 // Needs to stay in scope till GURL is out of scope. 211 // Needs to stay in scope till GURL is out of scope.
214 string path(kGetUserInfoPath); 212 string path(kGetUserInfoPath);
215 repl.SetPathStr(path); 213 repl.SetPathStr(path);
216 url = url.ReplaceComponents(repl); 214 url = url.ReplaceComponents(repl);
217 215
218 string post_body; 216 string post_body;
219 post_body += "LSID="; 217 post_body += "LSID=";
220 post_body += EscapeUrlEncodedData(results->lsid, true); 218 post_body += EscapeUrlEncodedData(results->lsid);
221 219
222 unsigned long server_response_code; 220 unsigned long server_response_code;
223 string message_text; 221 string message_text;
224 if (!Post(url, post_body, &server_response_code, &message_text)) { 222 if (!Post(url, post_body, &server_response_code, &message_text)) {
225 return false; 223 return false;
226 } 224 }
227 225
228 // Check if we received a valid AuthToken; if not, ignore it. 226 // Check if we received a valid AuthToken; if not, ignore it.
229 if (RC_FORBIDDEN == server_response_code) { 227 if (RC_FORBIDDEN == server_response_code) {
230 // Server says we're not authenticated. 228 // Server says we're not authenticated.
(...skipping 29 matching lines...) Expand all
260 // Use the provided Gaia server, but change the path to what V1 expects. 258 // Use the provided Gaia server, but change the path to what V1 expects.
261 GURL url(gaia_url_); // Gaia server. 259 GURL url(gaia_url_); // Gaia server.
262 GURL::Replacements repl; 260 GURL::Replacements repl;
263 // Needs to stay in scope till GURL is out of scope. 261 // Needs to stay in scope till GURL is out of scope.
264 string path(kGaiaV1IssueAuthTokenPath); 262 string path(kGaiaV1IssueAuthTokenPath);
265 repl.SetPathStr(path); 263 repl.SetPathStr(path);
266 url = url.ReplaceComponents(repl); 264 url = url.ReplaceComponents(repl);
267 265
268 string post_body; 266 string post_body;
269 post_body += "LSID="; 267 post_body += "LSID=";
270 post_body += EscapeUrlEncodedData(results->lsid, true); 268 post_body += EscapeUrlEncodedData(results->lsid);
271 post_body += "&service=" + service_id; 269 post_body += "&service=" + service_id;
272 post_body += "&Session=true"; 270 post_body += "&Session=true";
273 271
274 unsigned long server_response_code; 272 unsigned long server_response_code;
275 string message_text; 273 string message_text;
276 if (!Post(url, post_body, &server_response_code, &message_text)) { 274 if (!Post(url, post_body, &server_response_code, &message_text)) {
277 return false; 275 return false;
278 } 276 }
279 277
280 // Check if we received a valid AuthToken; if not, ignore it. 278 // Check if we received a valid AuthToken; if not, ignore it.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 bool GaiaAuthenticator::Authenticate(const string& user_name, 388 bool GaiaAuthenticator::Authenticate(const string& user_name,
391 const string& password) { 389 const string& password) {
392 DCHECK_EQ(MessageLoop::current(), message_loop_); 390 DCHECK_EQ(MessageLoop::current(), message_loop_);
393 const string empty; 391 const string empty;
394 return Authenticate(user_name, password, empty, 392 return Authenticate(user_name, password, empty,
395 empty); 393 empty);
396 } 394 }
397 395
398 } // namepace gaia 396 } // namepace gaia
399 397
OLDNEW
« no previous file with comments | « chrome/common/net/gaia/gaia_auth_fetcher.cc ('k') | chrome/common/net/gaia/gaia_oauth_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698