summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill/email_field.cc
diff options
context:
space:
mode:
authorisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-05 04:01:21 +0000
committerisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-05 04:01:21 +0000
commit2a958550ec25aeb2da7fa893015133f2aae32f41 (patch)
treedafc82496cf0b1f14d39183b5e9860a8ca255e70 /chrome/browser/autofill/email_field.cc
parentbed98da0c1e62387a477903910781f1b54916039 (diff)
downloadchromium_src-2a958550ec25aeb2da7fa893015133f2aae32f41.zip
chromium_src-2a958550ec25aeb2da7fa893015133f2aae32f41.tar.gz
chromium_src-2a958550ec25aeb2da7fa893015133f2aae32f41.tar.bz2
Refactor Autofill parsing code. Most notably, add a helper class for parsing with lookahead.
* Adds an AutofillScanner class to help with lookahead parsing. * Remove the NULL-termination from FormStructure's fields vector * Remove some redundant DCHECKs * Refactor PersonalDataManager::ImportFormData() to take a single form, not a vector of forms. * Move EmailField class to its own file * Remove some obsolete billing/shipping address distinguishing code * Refactor the code to remove the really wonky FormFieldSet() class * Refactor some interfaces to take |size_t| rather than |int| * Remove some unused fields from FormStructure * Const-correctness BUG=none TEST=none Review URL: http://codereview.chromium.org/6910018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84211 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill/email_field.cc')
-rw-r--r--chrome/browser/autofill/email_field.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/chrome/browser/autofill/email_field.cc b/chrome/browser/autofill/email_field.cc
new file mode 100644
index 0000000..0f7a666
--- /dev/null
+++ b/chrome/browser/autofill/email_field.cc
@@ -0,0 +1,31 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/autofill/email_field.h"
+
+#include "chrome/browser/autofill/autofill_scanner.h"
+#include "grit/autofill_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+
+// static
+EmailField* EmailField::Parse(AutofillScanner* scanner, bool is_ecml) {
+ string16 pattern;
+ if (is_ecml)
+ pattern = GetEcmlPattern(kEcmlShipToEmail, kEcmlBillToEmail, '|');
+ else
+ pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_EMAIL_RE);
+
+ const AutofillField* field;
+ if (ParseText(scanner, pattern, &field))
+ return new EmailField(field);
+
+ return NULL;
+}
+
+bool EmailField::GetFieldInfo(FieldTypeMap* field_type_map) const {
+ return Add(field_type_map, field_, EMAIL_ADDRESS);
+}
+
+EmailField::EmailField(const AutofillField* field) : field_(field) {
+}