Add unit test for the Settings API Bubble.
[chromium-blink-merge.git] / chrome / browser / ui / autofill / autofill_dialog_common.h
blobf4195f84cfb8d4236739fe4de2a6752442b59eda
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.
5 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_COMMON_H_
6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_COMMON_H_
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"
12 namespace autofill {
13 class AutofillProfile;
16 namespace wallet {
17 class Address;
20 namespace autofill {
21 namespace common {
23 // The types of addresses this class supports building.
24 enum AddressType {
25 ADDRESS_TYPE_BILLING,
26 ADDRESS_TYPE_SHIPPING,
29 // Returns true if |type| should be shown when |field_type| has been requested.
30 // This filters the types that we fill into the page to match the ones the
31 // dialog actually cares about, preventing rAc from giving away data that an
32 // AutofillProfile or other data source might know about the user which isn't
33 // represented in the dialog.
34 bool ServerTypeEncompassesFieldType(ServerFieldType type,
35 const AutofillType& field_type);
37 // Returns true if |type| in the given |section| should be used for a
38 // site-requested |field|.
39 bool ServerTypeMatchesField(DialogSection section,
40 ServerFieldType type,
41 const AutofillField& field);
43 // Returns true if the |type| belongs to the CREDIT_CARD field type group.
44 bool IsCreditCardType(ServerFieldType type);
46 // Constructs |inputs| from template data for a given |dialog_section|.
47 // |country_country| specifies the country code that the inputs should be built
48 // for.
49 void BuildInputsForSection(DialogSection dialog_section,
50 const std::string& country_code,
51 DetailInputs* inputs);
53 // Returns the AutofillMetrics::DIALOG_UI_*_ITEM_ADDED metric corresponding
54 // to the |section|.
55 AutofillMetrics::DialogUiEvent DialogSectionToUiItemAddedEvent(
56 DialogSection section);
58 // Returns the AutofillMetrics::DIALOG_UI_*_ITEM_ADDED metric corresponding
59 // to the |section|.
60 AutofillMetrics::DialogUiEvent DialogSectionToUiSelectionChangedEvent(
61 DialogSection section);
63 // Gets just the |type| attributes from each DetailInput.
64 std::vector<ServerFieldType> TypesFromInputs(const DetailInputs& inputs);
66 } // namespace common
67 } // namespace autofill
69 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_COMMON_H_