autofill_dialog_common.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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#ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_COMMON_H_
6#define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_COMMON_H_
7
8#include "chrome/browser/ui/autofill/autofill_dialog_types.h"
9#include "components/autofill/core/browser/autofill_type.h"
10#include "components/autofill/core/browser/field_types.h"
11
12namespace autofill {
13class AutofillProfile;
14}
15
16namespace wallet {
17class Address;
18}
19
20namespace autofill {
21namespace common {
22
23// The types of addresses this class supports building.
24enum AddressType {
25  ADDRESS_TYPE_BILLING,
26  ADDRESS_TYPE_SHIPPING,
27};
28
29// Returns true if |type| should be shown when |field_type| has been requested.
30bool ServerTypeMatchesFieldType(ServerFieldType type,
31                                const AutofillType& field_type);
32
33// Returns true if |type| in the given |section| should be used for a
34// site-requested |field|.
35bool ServerTypeMatchesField(DialogSection section,
36                            ServerFieldType type,
37                            const AutofillField& field);
38
39// Returns true if the |type| belongs to the CREDIT_CARD field type group.
40bool IsCreditCardType(ServerFieldType type);
41
42// Constructs |inputs| from template data for a given |dialog_section|.
43// |country_country| specifies the country code that the inputs should be built
44// for.
45void BuildInputsForSection(DialogSection dialog_section,
46                           const std::string& country_code,
47                           DetailInputs* inputs);
48
49// Returns the AutofillMetrics::DIALOG_UI_*_ITEM_ADDED metric corresponding
50// to the |section|.
51AutofillMetrics::DialogUiEvent DialogSectionToUiItemAddedEvent(
52    DialogSection section);
53
54// Returns the AutofillMetrics::DIALOG_UI_*_ITEM_ADDED metric corresponding
55// to the |section|.
56AutofillMetrics::DialogUiEvent DialogSectionToUiSelectionChangedEvent(
57    DialogSection section);
58
59// We hardcode some values. In particular, we don't yet allow the user to change
60// the country: http://crbug.com/247518
61base::string16 GetHardcodedValueForType(ServerFieldType type);
62
63// Gets just the |type| attributes from each DetailInput.
64std::vector<ServerFieldType> TypesFromInputs(const DetailInputs& inputs);
65
66}  // namespace common
67}  // namespace autofill
68
69#endif  // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_COMMON_H_
70