| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/name_field.h" | 5 #include "chrome/browser/autofill/name_field.h" |
| 6 | 6 |
| 7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/autofill/autofill_type.h" | 10 #include "chrome/browser/autofill/autofill_type.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 // A fair number of pages use the names "fname" and "lname" for naming | 71 // A fair number of pages use the names "fname" and "lname" for naming |
| 72 // first and last name fields (examples from the test suite: | 72 // first and last name fields (examples from the test suite: |
| 73 // BESTBUY_COM - Sign In2.html; Crate and Barrel Check Out.html; | 73 // BESTBUY_COM - Sign In2.html; Crate and Barrel Check Out.html; |
| 74 // dell_checkout1.html). At least one UK page (The China Shop2.html) | 74 // dell_checkout1.html). At least one UK page (The China Shop2.html) |
| 75 // asks, in stuffy English style, for just initials and a surname, | 75 // asks, in stuffy English style, for just initials and a surname, |
| 76 // so we match "initials" here (and just fill in a first name there, | 76 // so we match "initials" here (and just fill in a first name there, |
| 77 // American-style). | 77 // American-style). |
| 78 // The ".*first$" matches fields ending in "first" (example in sample8.html). | 78 // The ".*first$" matches fields ending in "first" (example in sample8.html). |
| 79 string16 match = | 79 string16 match = |
| 80 ASCIIToUTF16("first *name|first_name|initials|fname|.*first$"); | 80 ASCIIToUTF16("first *name|first_name|initials|fname|first$"); |
| 81 if (!ParseText(&q, match, &v->first_name_)) | 81 if (!ParseText(&q, match, &v->first_name_)) |
| 82 return NULL; | 82 return NULL; |
| 83 | 83 |
| 84 // We check for a middle initial before checking for a middle name | 84 // We check for a middle initial before checking for a middle name |
| 85 // because at least one page (PC Connection.html) has a field marked | 85 // because at least one page (PC Connection.html) has a field marked |
| 86 // as both (the label text is "MI" and the element name is | 86 // as both (the label text is "MI" and the element name is |
| 87 // "txtmiddlename"); such a field probably actually represents a | 87 // "txtmiddlename"); such a field probably actually represents a |
| 88 // middle initial. | 88 // middle initial. |
| 89 match = ASCIIToUTF16("^mi$|middle initial|middleinitial|m.i."); | 89 match = ASCIIToUTF16("middle *initial|middle_initial|m\\.i\\.|mi$"); |
| 90 if (ParseText(&q, match, &v->middle_name_)) { | 90 if (ParseText(&q, match, &v->middle_name_)) { |
| 91 v->middle_initial_ = true; | 91 v->middle_initial_ = true; |
| 92 } else { | 92 } else { |
| 93 match = ASCIIToUTF16("middle *name|mname"); | 93 match = ASCIIToUTF16("middle *name|middle_name|mname|middle$"); |
| 94 ParseText(&q, match, &v->middle_name_); | 94 ParseText(&q, match, &v->middle_name_); |
| 95 } | 95 } |
| 96 | 96 |
| 97 // The ".*last$" matches fields ending in "last" (example in sample8.html). | 97 // The ".*last$" matches fields ending in "last" (example in sample8.html). |
| 98 match = ASCIIToUTF16("last *name|last_name|lname|surname|.*last$"); | 98 match = ASCIIToUTF16("last *name|last_name|lname|surname|last$"); |
| 99 if (!ParseText(&q, match, &v->last_name_)) | 99 if (!ParseText(&q, match, &v->last_name_)) |
| 100 return NULL; | 100 return NULL; |
| 101 | 101 |
| 102 *iter = q; | 102 *iter = q; |
| 103 return v.release(); | 103 return v.release(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 FirstLastNameField* FirstLastNameField::ParseEcmlName( | 106 FirstLastNameField* FirstLastNameField::ParseEcmlName( |
| 107 std::vector<AutoFillField*>::const_iterator* iter) { | 107 std::vector<AutoFillField*>::const_iterator* iter) { |
| 108 scoped_ptr<FirstLastNameField> field(new FirstLastNameField); | 108 scoped_ptr<FirstLastNameField> field(new FirstLastNameField); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 return ok; | 152 return ok; |
| 153 } | 153 } |
| 154 | 154 |
| 155 FirstLastNameField::FirstLastNameField() | 155 FirstLastNameField::FirstLastNameField() |
| 156 : first_name_(NULL), | 156 : first_name_(NULL), |
| 157 middle_name_(NULL), | 157 middle_name_(NULL), |
| 158 last_name_(NULL), | 158 last_name_(NULL), |
| 159 middle_initial_(false) { | 159 middle_initial_(false) { |
| 160 } | 160 } |
| 161 | 161 |
| OLD | NEW |