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

Side by Side Diff: chrome/browser/internal_auth.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
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/internal_auth.h" 5 #include "chrome/browser/internal_auth.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <deque> 8 #include <deque>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // We must not allow kItemSeparator in anything used as an input to construct 105 // We must not allow kItemSeparator in anything used as an input to construct
106 // message to sign. 106 // message to sign.
107 DCHECK(std::find(kAllowedChars, kAllowedChars + arraysize(kAllowedChars), 107 DCHECK(std::find(kAllowedChars, kAllowedChars + arraysize(kAllowedChars),
108 kItemSeparator) == kAllowedChars + arraysize(kAllowedChars)); 108 kItemSeparator) == kAllowedChars + arraysize(kAllowedChars));
109 DCHECK(std::find(kAllowedChars, kAllowedChars + arraysize(kAllowedChars), 109 DCHECK(std::find(kAllowedChars, kAllowedChars + arraysize(kAllowedChars),
110 kVarValueSeparator) == kAllowedChars + arraysize(kAllowedChars)); 110 kVarValueSeparator) == kAllowedChars + arraysize(kAllowedChars));
111 return !var.empty() && 111 return !var.empty() &&
112 var.size() <= kStringLengthLimit && 112 var.size() <= kStringLengthLimit &&
113 base::IsStringASCII(var) && 113 base::IsStringASCII(var) &&
114 var.find_first_not_of(kAllowedChars) == std::string::npos && 114 var.find_first_not_of(kAllowedChars) == std::string::npos &&
115 !IsAsciiDigit(var[0]); 115 !base::IsAsciiDigit(var[0]);
116 } 116 }
117 117
118 bool IsValueSane(const std::string& value) { 118 bool IsValueSane(const std::string& value) {
119 return value.size() <= kStringLengthLimit && 119 return value.size() <= kStringLengthLimit &&
120 base::IsStringUTF8(value) && 120 base::IsStringUTF8(value) &&
121 value.find_first_of(kItemSeparator) == std::string::npos; 121 value.find_first_of(kItemSeparator) == std::string::npos;
122 } 122 }
123 123
124 bool IsVarValueMapSane(const VarValueMap& map) { 124 bool IsVarValueMapSane(const VarValueMap& map) {
125 if (map.size() > kVarsLimit) 125 if (map.size() > kVarsLimit)
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 const VarValueMap& var_value_map) { 441 const VarValueMap& var_value_map) {
442 base::AutoLock alk(g_verification_service_lock.Get()); 442 base::AutoLock alk(g_verification_service_lock.Get());
443 return g_verification_service.Get().VerifyPassport( 443 return g_verification_service.Get().VerifyPassport(
444 passport, domain, var_value_map); 444 passport, domain, var_value_map);
445 } 445 }
446 446
447 // static 447 // static
448 void InternalAuthVerification::ChangeKey(const std::string& key) { 448 void InternalAuthVerification::ChangeKey(const std::string& key) {
449 base::AutoLock alk(g_verification_service_lock.Get()); 449 base::AutoLock alk(g_verification_service_lock.Get());
450 g_verification_service.Get().ChangeKey(key); 450 g_verification_service.Get().ChangeKey(key);
451 }; 451 }
452 452
453 // static 453 // static
454 int InternalAuthVerification::get_verification_window_ticks() { 454 int InternalAuthVerification::get_verification_window_ticks() {
455 int candidate = kVerificationWindowTicks; 455 int candidate = kVerificationWindowTicks;
456 if (verification_window_seconds_ > 0) 456 if (verification_window_seconds_ > 0)
457 candidate = verification_window_seconds_ * 457 candidate = verification_window_seconds_ *
458 base::Time::kMicrosecondsPerSecond / kTickUs; 458 base::Time::kMicrosecondsPerSecond / kTickUs;
459 return std::max(1, std::min(candidate, kVerificationWindowTicks)); 459 return std::max(1, std::min(candidate, kVerificationWindowTicks));
460 } 460 }
461 461
462 int InternalAuthVerification::verification_window_seconds_ = 0; 462 int InternalAuthVerification::verification_window_seconds_ = 0;
463 463
464 // static 464 // static
465 std::string InternalAuthGeneration::GeneratePassport( 465 std::string InternalAuthGeneration::GeneratePassport(
466 const std::string& domain, const VarValueMap& var_value_map) { 466 const std::string& domain, const VarValueMap& var_value_map) {
467 return g_generation_service.Get().GeneratePassport(domain, var_value_map, 0); 467 return g_generation_service.Get().GeneratePassport(domain, var_value_map, 0);
468 } 468 }
469 469
470 // static 470 // static
471 void InternalAuthGeneration::GenerateNewKey() { 471 void InternalAuthGeneration::GenerateNewKey() {
472 g_generation_service.Get().GenerateNewKey(); 472 g_generation_service.Get().GenerateNewKey();
473 } 473 }
474 474
475 } // namespace chrome 475 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/install_verification/win/module_ids.cc ('k') | chrome/browser/profile_resetter/jtl_foundation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698