1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/autofill/core/browser/form_parsing/email_field.h"
6
7 #include "base/strings/utf_string_conversions.h"
8 #include "components/autofill/core/browser/autofill_regex_constants.h"
9 #include "components/autofill/core/browser/form_parsing/autofill_scanner.h"
10
11 namespace autofill {
12
13 // static
Parse(AutofillScanner * scanner,const std::string & page_language,LogManager * log_manager)14 std::unique_ptr<FormField> EmailField::Parse(AutofillScanner* scanner,
15 const std::string& page_language,
16 LogManager* log_manager) {
17 AutofillField* field;
18 auto& patterns = PatternProvider::GetInstance().GetMatchPatterns(
19 "EMAIL_ADDRESS", page_language);
20 if (ParseFieldSpecifics(scanner, base::UTF8ToUTF16(kEmailRe),
21 MATCH_DEFAULT | MATCH_EMAIL, patterns, &field,
22 {log_manager, "kEmailRe"})) {
23 return std::make_unique<EmailField>(field);
24 }
25
26 return nullptr;
27 }
28
EmailField(const AutofillField * field)29 EmailField::EmailField(const AutofillField* field) : field_(field) {}
30
AddClassifications(FieldCandidatesMap * field_candidates) const31 void EmailField::AddClassifications(
32 FieldCandidatesMap* field_candidates) const {
33 AddClassification(field_, EMAIL_ADDRESS, kBaseEmailParserScore,
34 field_candidates);
35 }
36
37 } // namespace autofill
38