• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
12 namespace autofill {
13 class AutofillProfile;
14 }
15 
16 namespace wallet {
17 class Address;
18 }
19 
20 namespace autofill {
21 namespace common {
22 
23 // The types of addresses this class supports building.
24 enum 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.
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);
36 
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);
42 
43 // Returns true if the |type| belongs to the CREDIT_CARD field type group.
44 bool IsCreditCardType(ServerFieldType type);
45 
46 // Constructs |inputs| from the array of inputs in |input_template|.
47 void BuildInputs(const DetailInput input_template[],
48                  size_t template_size,
49                  DetailInputs* inputs);
50 
51 // Returns the AutofillMetrics::DIALOG_UI_*_ITEM_ADDED metric corresponding
52 // to the |section|.
53 AutofillMetrics::DialogUiEvent DialogSectionToUiItemAddedEvent(
54     DialogSection section);
55 
56 // Returns the AutofillMetrics::DIALOG_UI_*_ITEM_ADDED metric corresponding
57 // to the |section|.
58 AutofillMetrics::DialogUiEvent DialogSectionToUiSelectionChangedEvent(
59     DialogSection section);
60 
61 // Gets just the |type| attributes from each DetailInput.
62 std::vector<ServerFieldType> TypesFromInputs(const DetailInputs& inputs);
63 
64 }  // namespace common
65 }  // namespace autofill
66 
67 #endif  // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_COMMON_H_
68