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_field.h" | 5 #include "components/autofill/core/browser/phone_field.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 } | 189 } |
190 } | 190 } |
191 | 191 |
192 // Now look for an extension. | 192 // Now look for an extension. |
193 ParseField(scanner, UTF8ToUTF16(autofill::kPhoneExtensionRe), | 193 ParseField(scanner, UTF8ToUTF16(autofill::kPhoneExtensionRe), |
194 &phone_field->parsed_phone_fields_[FIELD_EXTENSION]); | 194 &phone_field->parsed_phone_fields_[FIELD_EXTENSION]); |
195 | 195 |
196 return phone_field.release(); | 196 return phone_field.release(); |
197 } | 197 } |
198 | 198 |
199 bool PhoneField::ClassifyField(FieldTypeMap* map) const { | 199 bool PhoneField::ClassifyField(ServerFieldTypeMap* map) const { |
200 bool ok = true; | 200 bool ok = true; |
201 | 201 |
202 DCHECK(parsed_phone_fields_[FIELD_PHONE]); // Phone was correctly parsed. | 202 DCHECK(parsed_phone_fields_[FIELD_PHONE]); // Phone was correctly parsed. |
203 | 203 |
204 if ((parsed_phone_fields_[FIELD_COUNTRY_CODE] != NULL) || | 204 if ((parsed_phone_fields_[FIELD_COUNTRY_CODE] != NULL) || |
205 (parsed_phone_fields_[FIELD_AREA_CODE] != NULL) || | 205 (parsed_phone_fields_[FIELD_AREA_CODE] != NULL) || |
206 (parsed_phone_fields_[FIELD_SUFFIX] != NULL)) { | 206 (parsed_phone_fields_[FIELD_SUFFIX] != NULL)) { |
207 if (parsed_phone_fields_[FIELD_COUNTRY_CODE] != NULL) { | 207 if (parsed_phone_fields_[FIELD_COUNTRY_CODE] != NULL) { |
208 ok = ok && AddClassification(parsed_phone_fields_[FIELD_COUNTRY_CODE], | 208 ok = ok && AddClassification(parsed_phone_fields_[FIELD_COUNTRY_CODE], |
209 PHONE_HOME_COUNTRY_CODE, | 209 PHONE_HOME_COUNTRY_CODE, |
210 map); | 210 map); |
211 } | 211 } |
212 | 212 |
213 AutofillFieldType field_number_type = PHONE_HOME_NUMBER; | 213 ServerFieldType field_number_type = PHONE_HOME_NUMBER; |
214 if (parsed_phone_fields_[FIELD_AREA_CODE] != NULL) { | 214 if (parsed_phone_fields_[FIELD_AREA_CODE] != NULL) { |
215 ok = ok && AddClassification(parsed_phone_fields_[FIELD_AREA_CODE], | 215 ok = ok && AddClassification(parsed_phone_fields_[FIELD_AREA_CODE], |
216 PHONE_HOME_CITY_CODE, | 216 PHONE_HOME_CITY_CODE, |
217 map); | 217 map); |
218 } else if (parsed_phone_fields_[FIELD_COUNTRY_CODE] != NULL) { | 218 } else if (parsed_phone_fields_[FIELD_COUNTRY_CODE] != NULL) { |
219 // Only if we can find country code without city code, it means the phone | 219 // Only if we can find country code without city code, it means the phone |
220 // number include city code. | 220 // number include city code. |
221 field_number_type = PHONE_HOME_CITY_AND_NUMBER; | 221 field_number_type = PHONE_HOME_CITY_AND_NUMBER; |
222 } | 222 } |
223 // We tag the prefix as PHONE_HOME_NUMBER, then when filling the form | 223 // We tag the prefix as PHONE_HOME_NUMBER, then when filling the form |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 case REGEX_EXTENSION: | 267 case REGEX_EXTENSION: |
268 return UTF8ToUTF16(autofill::kPhoneExtensionRe); | 268 return UTF8ToUTF16(autofill::kPhoneExtensionRe); |
269 default: | 269 default: |
270 NOTREACHED(); | 270 NOTREACHED(); |
271 break; | 271 break; |
272 } | 272 } |
273 return base::string16(); | 273 return base::string16(); |
274 } | 274 } |
275 | 275 |
276 } // namespace autofill | 276 } // namespace autofill |
OLD | NEW |