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 // static 18 const char Authenticator::kSpecialCaseDomain[] = "gmail.com"; 19 20 Authenticator::Authenticator(LoginStatusConsumer* consumer) 21 : consumer_(consumer) { 22 } 23 24 Authenticator::~Authenticator() {} 25 26 // static 27 std::string Authenticator::Canonicalize(const std::string& email_address) { 28 std::vector<std::string> parts; 29 char at = '@'; 30 base::SplitString(email_address, at, &parts); 31 DCHECK_EQ(parts.size(), 2U) << "email_address should have only one @"; 32 if (parts[1] == kSpecialCaseDomain) // only strip '.' for gmail accounts. 33 RemoveChars(parts[0], ".", &parts[0]); 34 std::string new_email = StringToLowerASCII(JoinString(parts, at)); 35 VLOG(1) << "Canonicalized " << email_address << " to " << new_email; 36 return new_email; 37 } 38 39 } // namespace chromeos 40