Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: chrome/browser/autofill/form_field.cc

Issue 6026010: Autofill heuristics regular expressions should be stored in external data files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nits Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "app/l10n_util.h"
7 #include "base/string_util.h" 8 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/autofill/address_field.h" 10 #include "chrome/browser/autofill/address_field.h"
10 #include "chrome/browser/autofill/autofill_field.h" 11 #include "chrome/browser/autofill/autofill_field.h"
11 #include "chrome/browser/autofill/credit_card_field.h" 12 #include "chrome/browser/autofill/credit_card_field.h"
12 #include "chrome/browser/autofill/fax_field.h" 13 #include "chrome/browser/autofill/fax_field.h"
13 #include "chrome/browser/autofill/name_field.h" 14 #include "chrome/browser/autofill/name_field.h"
14 #include "chrome/browser/autofill/phone_field.h" 15 #include "chrome/browser/autofill/phone_field.h"
15 #include "third_party/WebKit/WebKit/chromium/public/WebRegularExpression.h" 16 #include "third_party/WebKit/WebKit/chromium/public/WebRegularExpression.h"
16 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" 17 #include "third_party/WebKit/WebKit/chromium/public/WebString.h"
18 #include "grit/autofill_resources.h"
17 19
18 // Field names from the ECML specification; see RFC 3106. We've 20 // Field names from the ECML specification; see RFC 3106. We've
19 // made these names lowercase since we convert labels and field names to 21 // made these names lowercase since we convert labels and field names to
20 // lowercase before searching. 22 // lowercase before searching.
21 23
22 // shipping name/address fields 24 // shipping name/address fields
23 const char kEcmlShipToTitle[] = "ecom_shipto_postal_name_prefix"; 25 const char kEcmlShipToTitle[] = "ecom_shipto_postal_name_prefix";
24 const char kEcmlShipToFirstName[] = "ecom_shipto_postal_name_first"; 26 const char kEcmlShipToFirstName[] = "ecom_shipto_postal_name_first";
25 const char kEcmlShipToMiddleName[] = "ecom_shipto_postal_name_middle"; 27 const char kEcmlShipToMiddleName[] = "ecom_shipto_postal_name_middle";
26 const char kEcmlShipToLastName[] = "ecom_shipto_postal_name_last"; 28 const char kEcmlShipToLastName[] = "ecom_shipto_postal_name_last";
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 DCHECK(ok); 84 DCHECK(ok);
83 return true; 85 return true;
84 } 86 }
85 87
86 static EmailField* Parse(std::vector<AutoFillField*>::const_iterator* iter, 88 static EmailField* Parse(std::vector<AutoFillField*>::const_iterator* iter,
87 bool is_ecml) { 89 bool is_ecml) {
88 string16 pattern; 90 string16 pattern;
89 if (is_ecml) { 91 if (is_ecml) {
90 pattern = GetEcmlPattern(kEcmlShipToEmail, kEcmlBillToEmail, '|'); 92 pattern = GetEcmlPattern(kEcmlShipToEmail, kEcmlBillToEmail, '|');
91 } else { 93 } else {
92 pattern = ASCIIToUTF16("email|e-mail"); 94 pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_EMAIL_RE);
93 } 95 }
94 96
95 AutoFillField* field; 97 AutoFillField* field;
96 if (ParseText(iter, pattern, &field)) 98 if (ParseText(iter, pattern, &field))
97 return new EmailField(field); 99 return new EmailField(field);
98 100
99 return NULL; 101 return NULL;
100 } 102 }
101 103
102 private: 104 private:
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 if (base::strncasecmp(name.c_str(), form_fields[i].name_, 390 if (base::strncasecmp(name.c_str(), form_fields[i].name_,
389 form_fields[i].length_) == 0) { 391 form_fields[i].length_) == 0) {
390 return true; 392 return true;
391 } 393 }
392 } 394 }
393 } 395 }
394 } 396 }
395 397
396 return false; 398 return false;
397 } 399 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/credit_card_field.cc ('k') | chrome/browser/autofill/form_structure_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698