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

Side by Side Diff: chrome/browser/signin/signin_manager.cc

Issue 120983002: Update some uses of UTF conversions in chrome/browser to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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/signin/signin_manager.h" 5 #include "chrome/browser/signin/signin_manager.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 // static 400 // static
401 bool SigninManager::IsUsernameAllowedByPolicy(const std::string& username, 401 bool SigninManager::IsUsernameAllowedByPolicy(const std::string& username,
402 const std::string& policy) { 402 const std::string& policy) {
403 if (policy.empty()) 403 if (policy.empty())
404 return true; 404 return true;
405 405
406 // Patterns like "*@foo.com" are not accepted by our regex engine (since they 406 // Patterns like "*@foo.com" are not accepted by our regex engine (since they
407 // are not valid regular expressions - they should instead be ".*@foo.com"). 407 // are not valid regular expressions - they should instead be ".*@foo.com").
408 // For convenience, detect these patterns and insert a "." character at the 408 // For convenience, detect these patterns and insert a "." character at the
409 // front. 409 // front.
410 base::string16 pattern = UTF8ToUTF16(policy); 410 base::string16 pattern = base::UTF8ToUTF16(policy);
411 if (pattern[0] == L'*') 411 if (pattern[0] == L'*')
412 pattern.insert(pattern.begin(), L'.'); 412 pattern.insert(pattern.begin(), L'.');
413 413
414 // See if the username matches the policy-provided pattern. 414 // See if the username matches the policy-provided pattern.
415 UErrorCode status = U_ZERO_ERROR; 415 UErrorCode status = U_ZERO_ERROR;
416 const icu::UnicodeString icu_pattern(pattern.data(), pattern.length()); 416 const icu::UnicodeString icu_pattern(pattern.data(), pattern.length());
417 icu::RegexMatcher matcher(icu_pattern, UREGEX_CASE_INSENSITIVE, status); 417 icu::RegexMatcher matcher(icu_pattern, UREGEX_CASE_INSENSITIVE, status);
418 if (!U_SUCCESS(status)) { 418 if (!U_SUCCESS(status)) {
419 LOG(ERROR) << "Invalid login regex: " << pattern << ", status: " << status; 419 LOG(ERROR) << "Invalid login regex: " << pattern << ", status: " << status;
420 // If an invalid pattern is provided, then prohibit *all* logins (better to 420 // If an invalid pattern is provided, then prohibit *all* logins (better to
421 // break signin than to quietly allow users to sign in). 421 // break signin than to quietly allow users to sign in).
422 return false; 422 return false;
423 } 423 }
424 base::string16 username16 = UTF8ToUTF16(username); 424 base::string16 username16 = base::UTF8ToUTF16(username);
425 icu::UnicodeString icu_input(username16.data(), username16.length()); 425 icu::UnicodeString icu_input(username16.data(), username16.length());
426 matcher.reset(icu_input); 426 matcher.reset(icu_input);
427 status = U_ZERO_ERROR; 427 status = U_ZERO_ERROR;
428 UBool match = matcher.matches(status); 428 UBool match = matcher.matches(status);
429 DCHECK(U_SUCCESS(status)); 429 DCHECK(U_SUCCESS(status));
430 return !!match; // !! == convert from UBool to bool. 430 return !!match; // !! == convert from UBool to bool.
431 } 431 }
432 432
433 bool SigninManager::IsAllowedUsername(const std::string& username) const { 433 bool SigninManager::IsAllowedUsername(const std::string& username) const {
434 const PrefService* local_state = local_state_pref_registrar_.prefs(); 434 const PrefService* local_state = local_state_pref_registrar_.prefs();
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 } 617 }
618 } 618 }
619 619
620 void SigninManager::ProhibitSignout(bool prohibit_signout) { 620 void SigninManager::ProhibitSignout(bool prohibit_signout) {
621 prohibit_signout_ = prohibit_signout; 621 prohibit_signout_ = prohibit_signout;
622 } 622 }
623 623
624 bool SigninManager::IsSignoutProhibited() const { 624 bool SigninManager::IsSignoutProhibited() const {
625 return prohibit_signout_; 625 return prohibit_signout_;
626 } 626 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/about_signin_internals.cc ('k') | chrome/browser/signin/signin_names_io_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698