| 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/form_field.h" | 5 #include "chrome/browser/autofill/form_field.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/autofill/address_field.h" | 9 #include "chrome/browser/autofill/address_field.h" |
| 10 #include "chrome/browser/autofill/autofill_field.h" | 10 #include "chrome/browser/autofill/autofill_field.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 return false; | 117 return false; |
| 118 } | 118 } |
| 119 | 119 |
| 120 // static | 120 // static |
| 121 bool FormField::MatchName(AutofillField* field, const string16& pattern) { | 121 bool FormField::MatchName(AutofillField* field, const string16& pattern) { |
| 122 // TODO(jhawkins): Remove StringToLowerASCII. WebRegularExpression needs to | 122 // TODO(jhawkins): Remove StringToLowerASCII. WebRegularExpression needs to |
| 123 // be fixed to take WebTextCaseInsensitive into account. | 123 // be fixed to take WebTextCaseInsensitive into account. |
| 124 WebKit::WebRegularExpression re(WebKit::WebString(pattern), | 124 WebKit::WebRegularExpression re(WebKit::WebString(pattern), |
| 125 WebKit::WebTextCaseInsensitive); | 125 WebKit::WebTextCaseInsensitive); |
| 126 bool match = re.match( | 126 bool match = re.match( |
| 127 WebKit::WebString(StringToLowerASCII(field->name()))) != -1; | 127 WebKit::WebString(StringToLowerASCII(field->name))) != -1; |
| 128 return match; | 128 return match; |
| 129 } | 129 } |
| 130 | 130 |
| 131 // static | 131 // static |
| 132 bool FormField::MatchLabel(AutofillField* field, const string16& pattern) { | 132 bool FormField::MatchLabel(AutofillField* field, const string16& pattern) { |
| 133 // TODO(jhawkins): Remove StringToLowerASCII. WebRegularExpression needs to | 133 // TODO(jhawkins): Remove StringToLowerASCII. WebRegularExpression needs to |
| 134 // be fixed to take WebTextCaseInsensitive into account. | 134 // be fixed to take WebTextCaseInsensitive into account. |
| 135 WebKit::WebRegularExpression re(WebKit::WebString(pattern), | 135 WebKit::WebRegularExpression re(WebKit::WebString(pattern), |
| 136 WebKit::WebTextCaseInsensitive); | 136 WebKit::WebTextCaseInsensitive); |
| 137 bool match = re.match( | 137 bool match = re.match( |
| 138 WebKit::WebString(StringToLowerASCII(field->label()))) != -1; | 138 WebKit::WebString(StringToLowerASCII(field->label))) != -1; |
| 139 return match; | 139 return match; |
| 140 } | 140 } |
| 141 | 141 |
| 142 // static | 142 // static |
| 143 FormField* FormField::ParseFormField( | 143 FormField* FormField::ParseFormField( |
| 144 std::vector<AutofillField*>::const_iterator* iter, | 144 std::vector<AutofillField*>::const_iterator* iter, |
| 145 bool is_ecml) { | 145 bool is_ecml) { |
| 146 FormField *field; | 146 FormField *field; |
| 147 field = EmailField::Parse(iter, is_ecml); | 147 field = EmailField::Parse(iter, is_ecml); |
| 148 if (field != NULL) | 148 if (field != NULL) |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 ECML_STRING_ENTRY(kEcmlCardType) | 343 ECML_STRING_ENTRY(kEcmlCardType) |
| 344 ECML_STRING_ENTRY(kEcmlCardNumber) | 344 ECML_STRING_ENTRY(kEcmlCardNumber) |
| 345 ECML_STRING_ENTRY(kEcmlCardVerification) | 345 ECML_STRING_ENTRY(kEcmlCardVerification) |
| 346 ECML_STRING_ENTRY(kEcmlCardExpireMonth) | 346 ECML_STRING_ENTRY(kEcmlCardExpireMonth) |
| 347 ECML_STRING_ENTRY(kEcmlCardExpireYear) | 347 ECML_STRING_ENTRY(kEcmlCardExpireYear) |
| 348 #undef ECML_STRING_ENTRY | 348 #undef ECML_STRING_ENTRY |
| 349 }; | 349 }; |
| 350 | 350 |
| 351 const string16 ecom(ASCIIToUTF16("ecom")); | 351 const string16 ecom(ASCIIToUTF16("ecom")); |
| 352 for (size_t index = 0; index < num_fields; ++index) { | 352 for (size_t index = 0; index < num_fields; ++index) { |
| 353 const string16& utf16_name = fields->field(index)->name(); | 353 const string16& utf16_name = fields->field(index)->name; |
| 354 if (StartsWith(utf16_name, ecom, true)) { | 354 if (StartsWith(utf16_name, ecom, true)) { |
| 355 std::string name(UTF16ToASCII(utf16_name)); | 355 std::string name(UTF16ToASCII(utf16_name)); |
| 356 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(form_fields); ++i) { | 356 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(form_fields); ++i) { |
| 357 if (base::strncasecmp(name.c_str(), form_fields[i].name_, | 357 if (base::strncasecmp(name.c_str(), form_fields[i].name_, |
| 358 form_fields[i].length_) == 0) { | 358 form_fields[i].length_) == 0) { |
| 359 return true; | 359 return true; |
| 360 } | 360 } |
| 361 } | 361 } |
| 362 } | 362 } |
| 363 } | 363 } |
| 364 | 364 |
| 365 return false; | 365 return false; |
| 366 } | 366 } |
| OLD | NEW |