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

Side by Side Diff: chrome/browser/chromeos/login/authenticator.cc

Issue 6089004: [Chrome OS] Respect periods in google apps account names (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address avayvod comments Created 9 years, 11 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) 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 // static
18 const char Authenticator::kSpecialCaseDomain[] = "gmail.com";
19
17 Authenticator::Authenticator(LoginStatusConsumer* consumer) 20 Authenticator::Authenticator(LoginStatusConsumer* consumer)
18 : consumer_(consumer) { 21 : consumer_(consumer) {
19 } 22 }
20 23
21 Authenticator::~Authenticator() {} 24 Authenticator::~Authenticator() {}
22 25
23 // static 26 // static
24 std::string Authenticator::Canonicalize(const std::string& email_address) { 27 std::string Authenticator::Canonicalize(const std::string& email_address) {
25 std::vector<std::string> parts; 28 std::vector<std::string> parts;
26 char at = '@'; 29 char at = '@';
27 base::SplitString(email_address, at, &parts); 30 base::SplitString(email_address, at, &parts);
28 DCHECK_EQ(parts.size(), 2U) << "email_address should have only one @"; 31 DCHECK_EQ(parts.size(), 2U) << "email_address should have only one @";
29 RemoveChars(parts[0], ".", &parts[0]); 32 if (parts[1] == kSpecialCaseDomain) // only strip '.' for gmail accounts.
33 RemoveChars(parts[0], ".", &parts[0]);
34 // Technically the '+' handling here could be removed, as the google
35 // account servers do not tolerate them, so we don't need to either.
36 // TODO(cmasone): remove this, unless this code becomes obsolete altogether.
30 if (parts[0].find('+') != std::string::npos) 37 if (parts[0].find('+') != std::string::npos)
31 parts[0].erase(parts[0].find('+')); 38 parts[0].erase(parts[0].find('+'));
32 std::string new_email = StringToLowerASCII(JoinString(parts, at)); 39 std::string new_email = StringToLowerASCII(JoinString(parts, at));
33 VLOG(1) << "Canonicalized " << email_address << " to " << new_email; 40 VLOG(1) << "Canonicalized " << email_address << " to " << new_email;
34 return new_email; 41 return new_email;
35 } 42 }
36 43
37 } // namespace chromeos 44 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/authenticator.h ('k') | chrome/browser/chromeos/login/authenticator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698