| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/autofill/phone_field.h" | 5 #include "chrome/browser/autofill/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/string16.h" | 9 #include "base/string16.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 const AutofillField* parsed_fields[FIELD_MAX]; | 262 const AutofillField* parsed_fields[FIELD_MAX]; |
| 263 | 263 |
| 264 for (size_t i = 0; i < arraysize(phone_field_grammars_); ++i) { | 264 for (size_t i = 0; i < arraysize(phone_field_grammars_); ++i) { |
| 265 memset(parsed_fields, 0, sizeof(parsed_fields)); | 265 memset(parsed_fields, 0, sizeof(parsed_fields)); |
| 266 scanner->Rewind(); | 266 scanner->Rewind(); |
| 267 scanner->SaveCursor(); | 267 scanner->SaveCursor(); |
| 268 | 268 |
| 269 // Attempt to parse according to the next grammar. | 269 // Attempt to parse according to the next grammar. |
| 270 for (; i < arraysize(phone_field_grammars_) && | 270 for (; i < arraysize(phone_field_grammars_) && |
| 271 phone_field_grammars_[i].regex != REGEX_SEPARATOR; ++i) { | 271 phone_field_grammars_[i].regex != REGEX_SEPARATOR; ++i) { |
| 272 if (!ParseField(scanner, | 272 if (!ParseFieldSpecifics( |
| 273 phone_field->GetRegExp(phone_field_grammars_[i].regex), | 273 scanner, |
| 274 &parsed_fields[phone_field_grammars_[i].phone_part])) | 274 phone_field->GetRegExp(phone_field_grammars_[i].regex), |
| 275 MATCH_DEFAULT | MATCH_TELEPHONE, |
| 276 &parsed_fields[phone_field_grammars_[i].phone_part])) |
| 275 break; | 277 break; |
| 276 if (phone_field_grammars_[i].max_size && | 278 if (phone_field_grammars_[i].max_size && |
| 277 (!parsed_fields[phone_field_grammars_[i].phone_part]->max_length || | 279 (!parsed_fields[phone_field_grammars_[i].phone_part]->max_length || |
| 278 phone_field_grammars_[i].max_size < | 280 phone_field_grammars_[i].max_size < |
| 279 parsed_fields[phone_field_grammars_[i].phone_part]->max_length)) { | 281 parsed_fields[phone_field_grammars_[i].phone_part]->max_length)) { |
| 280 break; | 282 break; |
| 281 } | 283 } |
| 282 } | 284 } |
| 283 | 285 |
| 284 if (i >= arraysize(phone_field_grammars_)) { | 286 if (i >= arraysize(phone_field_grammars_)) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 void PhoneField::SetPhoneType(PhoneType phone_type) { | 331 void PhoneField::SetPhoneType(PhoneType phone_type) { |
| 330 // Field types are different as well, so we create a temporary phone number, | 332 // Field types are different as well, so we create a temporary phone number, |
| 331 // to get relevant field types. | 333 // to get relevant field types. |
| 332 if (phone_type == HOME_PHONE) | 334 if (phone_type == HOME_PHONE) |
| 333 number_.reset(new PhoneNumber(AutofillType::PHONE_HOME)); | 335 number_.reset(new PhoneNumber(AutofillType::PHONE_HOME)); |
| 334 else | 336 else |
| 335 number_.reset(new PhoneNumber(AutofillType::PHONE_FAX)); | 337 number_.reset(new PhoneNumber(AutofillType::PHONE_FAX)); |
| 336 phone_type_ = phone_type; | 338 phone_type_ = phone_type; |
| 337 } | 339 } |
| 338 | 340 |
| OLD | NEW |