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

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

Issue 1200053004: Move more string_util functions to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « extensions/common/permissions/socket_permission_entry.cc ('k') | media/base/mime_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 ++cursor; 315 ++cursor;
316 if (cursor == limit) 316 if (cursor == limit)
317 return false; 317 return false;
318 char* second = strchr(kHexDigits, *cursor); 318 char* second = strchr(kHexDigits, *cursor);
319 if (!second) 319 if (!second)
320 return false; 320 return false;
321 int low = second - kHexDigits; 321 int low = second - kHexDigits;
322 DCHECK(low >= 0 || low < kHexBase); 322 DCHECK(low >= 0 || low < kHexBase);
323 323
324 char decoded = static_cast<char>(high * kHexBase + low); 324 char decoded = static_cast<char>(high * kHexBase + low);
325 DCHECK(!(IsAsciiAlpha(decoded) || IsAsciiDigit(decoded))); 325 DCHECK(!(base::IsAsciiAlpha(decoded) || base::IsAsciiDigit(decoded)));
326 DCHECK(!(decoded && strchr("-._~", decoded))); 326 DCHECK(!(decoded && strchr("-._~", decoded)));
327 accumulator += decoded; 327 accumulator += decoded;
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 (base::IsAsciiAlpha(character) || base::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 '.':
349 case '_': 349 case '_':
350 case '~': 350 case '~':
351 result += character; 351 result += character;
352 break; 352 break;
353 default: 353 default:
(...skipping 96 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 | « extensions/common/permissions/socket_permission_entry.cc ('k') | media/base/mime_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698