| 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 "google_apis/gaia/gaia_auth_util.h" | 5 #include "google_apis/gaia/gaia_auth_util.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 << (parts.empty() ? 0 : parts.size() - 1) | 28 << (parts.empty() ? 0 : parts.size() - 1) |
| 29 << " : " << email_address; | 29 << " : " << email_address; |
| 30 } else { | 30 } else { |
| 31 if (change_googlemail_to_gmail && parts[1] == kGooglemailDomain) | 31 if (change_googlemail_to_gmail && parts[1] == kGooglemailDomain) |
| 32 parts[1] = kGmailDomain; | 32 parts[1] = kGmailDomain; |
| 33 | 33 |
| 34 if (parts[1] == kGmailDomain) // only strip '.' for gmail accounts. | 34 if (parts[1] == kGmailDomain) // only strip '.' for gmail accounts. |
| 35 base::RemoveChars(parts[0], ".", &parts[0]); | 35 base::RemoveChars(parts[0], ".", &parts[0]); |
| 36 } | 36 } |
| 37 | 37 |
| 38 std::string new_email = base::StringToLowerASCII( | 38 std::string new_email = base::ToLowerASCII(base::JoinString(parts, "@")); |
| 39 base::JoinString(parts, "@")); | |
| 40 VLOG(1) << "Canonicalized " << email_address << " to " << new_email; | 39 VLOG(1) << "Canonicalized " << email_address << " to " << new_email; |
| 41 return new_email; | 40 return new_email; |
| 42 } | 41 } |
| 43 | 42 |
| 44 } // namespace | 43 } // namespace |
| 45 | 44 |
| 46 | 45 |
| 47 ListedAccount::ListedAccount() {} | 46 ListedAccount::ListedAccount() {} |
| 48 | 47 |
| 49 ListedAccount::~ListedAccount() {} | 48 ListedAccount::~ListedAccount() {} |
| (...skipping 15 matching lines...) Expand all Loading... |
| 65 // CanonicalizeEmail() is called to process email strings that are eventually | 64 // CanonicalizeEmail() is called to process email strings that are eventually |
| 66 // shown to the user, and may also be used in persisting email strings. To | 65 // shown to the user, and may also be used in persisting email strings. To |
| 67 // avoid breaking this existing behavior, this function will not try to | 66 // avoid breaking this existing behavior, this function will not try to |
| 68 // change googlemail to gmail. | 67 // change googlemail to gmail. |
| 69 return CanonicalizeEmailImpl(email_address, false); | 68 return CanonicalizeEmailImpl(email_address, false); |
| 70 } | 69 } |
| 71 | 70 |
| 72 std::string CanonicalizeDomain(const std::string& domain) { | 71 std::string CanonicalizeDomain(const std::string& domain) { |
| 73 // Canonicalization of domain names means lower-casing them. Make sure to | 72 // Canonicalization of domain names means lower-casing them. Make sure to |
| 74 // update this function in sync with Canonicalize if this ever changes. | 73 // update this function in sync with Canonicalize if this ever changes. |
| 75 return base::StringToLowerASCII(domain); | 74 return base::ToLowerASCII(domain); |
| 76 } | 75 } |
| 77 | 76 |
| 78 std::string SanitizeEmail(const std::string& email_address) { | 77 std::string SanitizeEmail(const std::string& email_address) { |
| 79 std::string sanitized(email_address); | 78 std::string sanitized(email_address); |
| 80 | 79 |
| 81 // Apply a default domain if necessary. | 80 // Apply a default domain if necessary. |
| 82 if (sanitized.find('@') == std::string::npos) { | 81 if (sanitized.find('@') == std::string::npos) { |
| 83 sanitized += '@'; | 82 sanitized += '@'; |
| 84 sanitized += kGmailDomain; | 83 sanitized += kGmailDomain; |
| 85 } | 84 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 accounts->push_back(listed_account); | 155 accounts->push_back(listed_account); |
| 157 } | 156 } |
| 158 } | 157 } |
| 159 } | 158 } |
| 160 } | 159 } |
| 161 | 160 |
| 162 return true; | 161 return true; |
| 163 } | 162 } |
| 164 | 163 |
| 165 } // namespace gaia | 164 } // namespace gaia |
| OLD | NEW |