| 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 i18n::phonenumbers::PhoneNumber; |
| 12 using i18n::phonenumbers::PhoneNumberUtil; |
| 13 |
| 14 namespace autofill_i18n { |
| 15 |
| 16 bool PhoneNumbersMatch(const string16& number_a, |
| 17 const string16& number_b, |
| 18 const std::string& country_code) { |
| 19 DCHECK(country_code.size() == 0 || country_code.size() == 2); |
| 20 std::string safe_country_code(country_code); |
| 21 if (safe_country_code.size() == 0) |
| 22 safe_country_code = "US"; |
| 23 |
| 24 PhoneNumberUtil *phone_util = PhoneNumberUtil::GetInstance(); |
| 25 PhoneNumber phone_number_a; |
| 26 phone_util->Parse(UTF16ToUTF8(number_a), safe_country_code, &phone_number_a); |
| 27 PhoneNumber phone_number_b; |
| 28 phone_util->Parse(UTF16ToUTF8(number_b), safe_country_code, &phone_number_b); |
| 29 |
| 30 PhoneNumberUtil::MatchType match = phone_util->IsNumberMatch(phone_number_a, |
| 31 phone_number_b); |
| 32 // Allow |NSN_MATCH| for implied country code if one is not set. |
| 33 return match == PhoneNumberUtil::NSN_MATCH || |
| 34 match == PhoneNumberUtil::EXACT_MATCH; |
| 35 } |
| 36 |
| 37 } // namespace autofill_i18n |
| OLD | NEW |