| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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/autofill/phone_number_i18n.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "base/utf_string_conversions.h" | |
| 9 #include "third_party/libphonenumber/cpp/src/phonenumberutil.h" | |
| 10 | |
| 11 using namespace i18n::phonenumbers; | |
| 12 | |
| 13 namespace autofill_i18n { | |
| 14 | |
| 15 bool PhoneNumbersMatch(const string16& number_a, | |
| 16 const string16& number_b, | |
| 17 const std::string& country_code) { | |
| 18 DCHECK(country_code.size() == 0 || country_code.size() == 2); | |
| 19 std::string safe_country_code(country_code); | |
| 20 if (safe_country_code.size() == 0) | |
| 21 safe_country_code = "US"; | |
| 22 | |
| 23 PhoneNumberUtil *phone_util = PhoneNumberUtil::GetInstance(); | |
| 24 PhoneNumber phone_number_a; | |
| 25 phone_util->Parse(UTF16ToUTF8(number_a), safe_country_code, &phone_number_a); | |
| 26 PhoneNumber phone_number_b; | |
| 27 phone_util->Parse(UTF16ToUTF8(number_b), safe_country_code, &phone_number_b); | |
| 28 | |
| 29 PhoneNumberUtil::MatchType match = phone_util->IsNumberMatch(phone_number_a, | |
| 30 phone_number_b); | |
| 31 // Allow |NSN_MATCH| for implied country code if one is not set. | |
| 32 return match == PhoneNumberUtil::NSN_MATCH || | |
| 33 match == PhoneNumberUtil::EXACT_MATCH; | |
| 34 } | |
| 35 | |
| 36 } // namespace autofill_i18n | |
| OLD | NEW |