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

Side by Side Diff: chrome/browser/autofill/phone_number_i18n.cc

Issue 6930052: Revert 84320 - Autofill DOMUI Prefs should work with i18n phone numbers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 7 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
(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
OLDNEW
« no previous file with comments | « chrome/browser/autofill/phone_number_i18n.h ('k') | chrome/browser/autofill/phone_number_i18n_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698