OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/chromeos/login/authenticator.h" |
| 6 |
| 7 #include <string> |
| 8 #include <vector> |
| 9 |
| 10 #include "base/logging.h" |
| 11 #include "base/string_split.h" |
| 12 #include "base/string_util.h" |
| 13 |
| 14 namespace chromeos { |
| 15 class LoginStatusConsumer; |
| 16 |
| 17 Authenticator::Authenticator(LoginStatusConsumer* consumer) |
| 18 : consumer_(consumer) { |
| 19 } |
| 20 |
| 21 Authenticator::~Authenticator() {} |
| 22 |
| 23 // static |
| 24 std::string Authenticator::Canonicalize(const std::string& email_address) { |
| 25 std::vector<std::string> parts; |
| 26 char at = '@'; |
| 27 SplitString(email_address, at, &parts); |
| 28 DCHECK_EQ(parts.size(), 2U) << "email_address should have only one @"; |
| 29 RemoveChars(parts[0], ".", &parts[0]); |
| 30 if (parts[0].find('+') != std::string::npos) |
| 31 parts[0].erase(parts[0].find('+')); |
| 32 std::string new_email = StringToLowerASCII(JoinString(parts, at)); |
| 33 LOG(INFO) << "Canonicalized " << email_address << " to " << new_email; |
| 34 return new_email; |
| 35 } |
| 36 |
| 37 } // namespace chromeos |
OLD | NEW |