| OLD | NEW |
| 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/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" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 // Apply a default domain if necessary. | 46 // Apply a default domain if necessary. |
| 47 if (sanitized.find('@') == std::string::npos) { | 47 if (sanitized.find('@') == std::string::npos) { |
| 48 sanitized += '@'; | 48 sanitized += '@'; |
| 49 sanitized += kGmailDomain; | 49 sanitized += kGmailDomain; |
| 50 } | 50 } |
| 51 | 51 |
| 52 return sanitized; | 52 return sanitized; |
| 53 } | 53 } |
| 54 | 54 |
| 55 // static |
| 56 std::string Authenticator::ExtractDomainName(const std::string& email_address) { |
| 57 // First canonicalize which will also verify we have proper domain part. |
| 58 std::string email = Canonicalize(email_address); |
| 59 size_t separator_pos = email.find('@'); |
| 60 if (separator_pos != email.npos && separator_pos < email.length() - 1) |
| 61 return email.substr(separator_pos + 1); |
| 62 else |
| 63 NOTREACHED() << "Not a proper email address: " << email; |
| 64 return std::string(); |
| 65 } |
| 66 |
| 55 } // namespace chromeos | 67 } // namespace chromeos |
| OLD | NEW |