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