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

Side by Side Diff: google_apis/gaia/oauth_request_signer.cc

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 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 "google_apis/gaia/oauth_request_signer.h" 5 #include "google_apis/gaia/oauth_request_signer.h"
6 6
7 #include <cctype> 7 #include <cctype>
8 #include <cstddef> 8 #include <cstddef>
9 #include <cstdlib> 9 #include <cstdlib>
10 #include <cstring> 10 #include <cstring>
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 return base::StringPrintf("%s&%s&%s", 82 return base::StringPrintf("%s&%s&%s",
83 HttpMethodName(http_method).c_str(), 83 HttpMethodName(http_method).c_str(),
84 OAuthRequestSigner::Encode( 84 OAuthRequestSigner::Encode(
85 request_base_url.spec()).c_str(), 85 request_base_url.spec()).c_str(),
86 OAuthRequestSigner::Encode( 86 OAuthRequestSigner::Encode(
87 base_parameters).c_str()); 87 base_parameters).c_str());
88 } 88 }
89 89
90 std::string BuildBaseStringParameters( 90 std::string BuildBaseStringParameters(
91 const OAuthRequestSigner::Parameters& parameters) { 91 const OAuthRequestSigner::Parameters& parameters) {
92 std::string result = ""; 92 std::string result;
93 OAuthRequestSigner::Parameters::const_iterator cursor; 93 OAuthRequestSigner::Parameters::const_iterator cursor;
94 OAuthRequestSigner::Parameters::const_iterator limit; 94 OAuthRequestSigner::Parameters::const_iterator limit;
95 bool first = true; 95 bool first = true;
96 for (cursor = parameters.begin(), limit = parameters.end(); 96 for (cursor = parameters.begin(), limit = parameters.end();
97 cursor != limit; 97 cursor != limit;
98 ++cursor) { 98 ++cursor) {
99 if (first) 99 if (first)
100 first = false; 100 first = false;
101 else 101 else
102 result += '&'; 102 result += '&';
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 (*parameters)[kOAuthSignatureLabel] = signature; 290 (*parameters)[kOAuthSignatureLabel] = signature;
291 return is_signed; 291 return is_signed;
292 } 292 }
293 293
294 294
295 } // namespace 295 } // namespace
296 296
297 // static 297 // static
298 bool OAuthRequestSigner::Decode(const std::string& text, 298 bool OAuthRequestSigner::Decode(const std::string& text,
299 std::string* decoded_text) { 299 std::string* decoded_text) {
300 std::string accumulator = ""; 300 std::string accumulator;
301 std::string::const_iterator cursor; 301 std::string::const_iterator cursor;
302 std::string::const_iterator limit; 302 std::string::const_iterator limit;
303 for (limit = text.end(), cursor = text.begin(); cursor != limit; ++cursor) { 303 for (limit = text.end(), cursor = text.begin(); cursor != limit; ++cursor) {
304 char character = *cursor; 304 char character = *cursor;
305 if (character == '%') { 305 if (character == '%') {
306 ++cursor; 306 ++cursor;
307 if (cursor == limit) 307 if (cursor == limit)
308 return false; 308 return false;
309 char* first = strchr(kHexDigits, *cursor); 309 char* first = strchr(kHexDigits, *cursor);
310 if (!first) 310 if (!first)
(...skipping 17 matching lines...) Expand all
328 } else { 328 } else {
329 accumulator += character; 329 accumulator += character;
330 } 330 }
331 } 331 }
332 *decoded_text = accumulator; 332 *decoded_text = accumulator;
333 return true; 333 return true;
334 } 334 }
335 335
336 // static 336 // static
337 std::string OAuthRequestSigner::Encode(const std::string& text) { 337 std::string OAuthRequestSigner::Encode(const std::string& text) {
338 std::string result = ""; 338 std::string result;
339 std::string::const_iterator cursor; 339 std::string::const_iterator cursor;
340 std::string::const_iterator limit; 340 std::string::const_iterator limit;
341 for (limit = text.end(), cursor = text.begin(); cursor != limit; ++cursor) { 341 for (limit = text.end(), cursor = text.begin(); cursor != limit; ++cursor) {
342 char character = *cursor; 342 char character = *cursor;
343 if (IsAsciiAlpha(character) || IsAsciiDigit(character)) { 343 if (IsAsciiAlpha(character) || IsAsciiDigit(character)) {
344 result += character; 344 result += character;
345 } else { 345 } else {
346 switch (character) { 346 switch (character) {
347 case '-': 347 case '-':
348 case '.': 348 case '.':
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 signed_text += 450 signed_text +=
451 base::StringPrintf( 451 base::StringPrintf(
452 "%s=\"%s\"", 452 "%s=\"%s\"",
453 OAuthRequestSigner::Encode(param->first).c_str(), 453 OAuthRequestSigner::Encode(param->first).c_str(),
454 OAuthRequestSigner::Encode(param->second).c_str()); 454 OAuthRequestSigner::Encode(param->second).c_str());
455 } 455 }
456 *signed_text_return = signed_text; 456 *signed_text_return = signed_text;
457 } 457 }
458 return is_signed; 458 return is_signed;
459 } 459 }
OLDNEW
« no previous file with comments | « google_apis/gaia/oauth2_mint_token_flow_unittest.cc ('k') | google_apis/gaia/oauth_request_signer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698