OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/autofill/core/browser/phone_number_i18n.h" | 5 #include "components/autofill/core/browser/phone_number_i18n.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 *country_code = base::string16(); | 134 *country_code = base::string16(); |
135 | 135 |
136 phone_util->NormalizeDigitsOnly(&number_text); | 136 phone_util->NormalizeDigitsOnly(&number_text); |
137 base::string16 normalized_number(base::UTF8ToUTF16(number_text)); | 137 base::string16 normalized_number(base::UTF8ToUTF16(number_text)); |
138 | 138 |
139 // Check if parsed number has a country code that was not inferred from the | 139 // Check if parsed number has a country code that was not inferred from the |
140 // region. | 140 // region. |
141 if (i18n_number->has_country_code()) { | 141 if (i18n_number->has_country_code()) { |
142 *country_code = base::UTF8ToUTF16( | 142 *country_code = base::UTF8ToUTF16( |
143 base::StringPrintf("%d", i18n_number->country_code())); | 143 base::StringPrintf("%d", i18n_number->country_code())); |
144 if (normalized_number.length() <= national_significant_number.length() && | 144 if (!StartsWith( |
Evan Stade
2014/07/10 23:22:48
I don't know what the purpose of this check was. T
Ilya Sherman
2014/07/11 01:11:01
I'm also not sure. I guess if no tests fail, then
Evan Stade
2014/07/11 18:08:13
well, tests did fail, which caused me to look into
| |
145 !StartsWith(normalized_number, *country_code, | 145 normalized_number, *country_code, true /* case_sensitive */)) { |
146 true /* case_sensitive */)) { | |
147 country_code->clear(); | 146 country_code->clear(); |
148 } | 147 } |
149 } | 148 } |
150 | 149 |
151 // The region might be different from what we started with. | 150 // The region might be different from what we started with. |
152 phone_util->GetRegionCodeForNumber(*i18n_number, inferred_region); | 151 phone_util->GetRegionCodeForNumber(*i18n_number, inferred_region); |
153 | 152 |
154 return true; | 153 return true; |
155 } | 154 } |
156 | 155 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
300 number_ = other.number_; | 299 number_ = other.number_; |
301 | 300 |
302 formatted_number_ = other.formatted_number_; | 301 formatted_number_ = other.formatted_number_; |
303 whole_number_ = other.whole_number_; | 302 whole_number_ = other.whole_number_; |
304 | 303 |
305 return *this; | 304 return *this; |
306 } | 305 } |
307 | 306 |
308 } // namespace i18n | 307 } // namespace i18n |
309 } // namespace autofill | 308 } // namespace autofill |
OLD | NEW |