summaryrefslogtreecommitdiff
path: root/chromium/components/autofill/core/browser/price_field.cc
blob: 59cbca3b4930f52915a6364835df151d0be86b10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright 2019 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 "components/autofill/core/browser/price_field.h"

#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/autofill_field.h"
#include "components/autofill/core/browser/autofill_scanner.h"
#include "components/autofill/core/common/autofill_regex_constants.h"

namespace autofill {

// static
std::unique_ptr<FormField> PriceField::Parse(AutofillScanner* scanner) {
  AutofillField* field;
  if (ParseFieldSpecifics(
          scanner, base::UTF8ToUTF16(kPriceRe),
          MATCH_DEFAULT | MATCH_NUMBER | MATCH_SELECT | MATCH_TEXT_AREA,
          &field)) {
    return std::make_unique<PriceField>(field);
  }

  return nullptr;
}

PriceField::PriceField(const AutofillField* field) : field_(field) {}

void PriceField::AddClassifications(
    FieldCandidatesMap* field_candidates) const {
  AddClassification(field_, PRICE, kBasePriceParserScore, field_candidates);
}

}  // namespace autofill