| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_COMMON_H_ | 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_COMMON_H_ |
| 6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_COMMON_H_ | 6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_COMMON_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" | 8 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" |
| 9 #include "components/autofill/core/browser/autofill_metrics.h" | 9 #include "components/autofill/core/browser/autofill_metrics.h" |
| 10 #include "components/autofill/core/browser/autofill_type.h" | 10 #include "components/autofill/core/browser/dialog_section.h" |
| 11 #include "components/autofill/core/browser/field_types.h" | |
| 12 | 11 |
| 13 namespace autofill { | 12 namespace autofill { |
| 14 class AutofillProfile; | 13 class AutofillProfile; |
| 15 } | 14 } |
| 16 | 15 |
| 17 namespace wallet { | 16 namespace wallet { |
| 18 class Address; | 17 class Address; |
| 19 } | 18 } |
| 20 | 19 |
| 21 namespace autofill { | 20 namespace autofill { |
| 22 namespace common { | 21 namespace common { |
| 23 | 22 |
| 24 // The types of addresses this class supports building. | 23 // The types of addresses this class supports building. |
| 25 enum AddressType { | 24 enum AddressType { |
| 26 ADDRESS_TYPE_BILLING, | 25 ADDRESS_TYPE_BILLING, |
| 27 ADDRESS_TYPE_SHIPPING, | 26 ADDRESS_TYPE_SHIPPING, |
| 28 }; | 27 }; |
| 29 | 28 |
| 30 // Returns true if |type| should be shown when |field_type| has been requested. | |
| 31 // This filters the types that we fill into the page to match the ones the | |
| 32 // dialog actually cares about, preventing rAc from giving away data that an | |
| 33 // AutofillProfile or other data source might know about the user which isn't | |
| 34 // represented in the dialog. | |
| 35 bool ServerTypeEncompassesFieldType(ServerFieldType type, | |
| 36 const AutofillType& field_type); | |
| 37 | |
| 38 // Returns true if |type| in the given |section| should be used for a | |
| 39 // site-requested |field|. | |
| 40 bool ServerTypeMatchesField(DialogSection section, | |
| 41 ServerFieldType type, | |
| 42 const AutofillField& field); | |
| 43 | |
| 44 // Returns true if the |type| belongs to the CREDIT_CARD field type group. | |
| 45 bool IsCreditCardType(ServerFieldType type); | |
| 46 | |
| 47 // Constructs |inputs| from the array of inputs in |input_template|. | |
| 48 void BuildInputs(const DetailInput input_template[], | |
| 49 size_t template_size, | |
| 50 DetailInputs* inputs); | |
| 51 | |
| 52 // Returns the AutofillMetrics::DIALOG_UI_*_ITEM_ADDED metric corresponding | 29 // Returns the AutofillMetrics::DIALOG_UI_*_ITEM_ADDED metric corresponding |
| 53 // to the |section|. | 30 // to the |section|. |
| 54 AutofillMetrics::DialogUiEvent DialogSectionToUiItemAddedEvent( | 31 AutofillMetrics::DialogUiEvent DialogSectionToUiItemAddedEvent( |
| 55 DialogSection section); | 32 DialogSection section); |
| 56 | 33 |
| 57 // Returns the AutofillMetrics::DIALOG_UI_*_ITEM_ADDED metric corresponding | 34 // Returns the AutofillMetrics::DIALOG_UI_*_ITEM_ADDED metric corresponding |
| 58 // to the |section|. | 35 // to the |section|. |
| 59 AutofillMetrics::DialogUiEvent DialogSectionToUiSelectionChangedEvent( | 36 AutofillMetrics::DialogUiEvent DialogSectionToUiSelectionChangedEvent( |
| 60 DialogSection section); | 37 DialogSection section); |
| 61 | 38 |
| 62 // Gets just the |type| attributes from each DetailInput. | |
| 63 std::vector<ServerFieldType> TypesFromInputs(const DetailInputs& inputs); | |
| 64 | |
| 65 } // namespace common | 39 } // namespace common |
| 66 } // namespace autofill | 40 } // namespace autofill |
| 67 | 41 |
| 68 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_COMMON_H_ | 42 #endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_COMMON_H_ |
| OLD | NEW |