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 #include "chrome/browser/ui/autofill/autofill_dialog_common.h" | 5 #include "chrome/browser/ui/autofill/autofill_dialog_common.h" |
6 | 6 |
| 7 #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h" |
7 #include "components/autofill/core/browser/autofill_field.h" | 8 #include "components/autofill/core/browser/autofill_field.h" |
8 #include "components/autofill/core/browser/autofill_type.h" | 9 #include "components/autofill/core/browser/autofill_type.h" |
9 #include "grit/chromium_strings.h" | 10 #include "grit/chromium_strings.h" |
10 #include "grit/component_strings.h" | 11 #include "grit/component_strings.h" |
11 #include "grit/generated_resources.h" | 12 #include "grit/generated_resources.h" |
12 #include "grit/theme_resources.h" | 13 #include "grit/theme_resources.h" |
13 #include "grit/webkit_resources.h" | 14 #include "grit/webkit_resources.h" |
14 | 15 |
15 namespace autofill { | 16 namespace autofill { |
16 namespace common { | 17 namespace common { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 DetailInputs* inputs) { | 66 DetailInputs* inputs) { |
66 for (size_t i = 0; i < template_size; ++i) { | 67 for (size_t i = 0; i < template_size; ++i) { |
67 const DetailInput* input = &input_template[i]; | 68 const DetailInput* input = &input_template[i]; |
68 inputs->push_back(*input); | 69 inputs->push_back(*input); |
69 } | 70 } |
70 } | 71 } |
71 | 72 |
72 // Constructs |inputs| from template data for a given |dialog_section|. | 73 // Constructs |inputs| from template data for a given |dialog_section|. |
73 void BuildInputsForSection(DialogSection dialog_section, | 74 void BuildInputsForSection(DialogSection dialog_section, |
74 DetailInputs* inputs) { | 75 DetailInputs* inputs) { |
| 76 BuildInputsForSection(dialog_section, inputs, i18ninput::GuessCountry()); |
| 77 } |
| 78 |
| 79 void BuildInputsForSection(DialogSection dialog_section, |
| 80 DetailInputs* inputs, |
| 81 const std::string& country_region) { |
75 const DetailInput kCCInputs[] = { | 82 const DetailInput kCCInputs[] = { |
76 { 1, CREDIT_CARD_NUMBER, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CARD_NUMBER }, | 83 { 1, CREDIT_CARD_NUMBER, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CARD_NUMBER }, |
77 { 2, CREDIT_CARD_EXP_MONTH, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EXPIRY_MONTH }, | 84 { 2, CREDIT_CARD_EXP_MONTH, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EXPIRY_MONTH }, |
78 { 2, CREDIT_CARD_EXP_4_DIGIT_YEAR, | 85 { 2, CREDIT_CARD_EXP_4_DIGIT_YEAR, |
79 IDS_AUTOFILL_DIALOG_PLACEHOLDER_EXPIRY_YEAR }, | 86 IDS_AUTOFILL_DIALOG_PLACEHOLDER_EXPIRY_YEAR }, |
80 { 2, CREDIT_CARD_VERIFICATION_CODE, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CVC, | 87 { 2, CREDIT_CARD_VERIFICATION_CODE, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CVC, |
81 1.5 }, | 88 1.5 }, |
82 }; | 89 }; |
83 | 90 |
| 91 const int kBillingInputsStartRow = 3; |
84 const DetailInput kBillingInputs[] = { | 92 const DetailInput kBillingInputs[] = { |
85 { 3, NAME_BILLING_FULL, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CARDHOLDER_NAME }, | 93 { 3, NAME_BILLING_FULL, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CARDHOLDER_NAME }, |
86 { 4, ADDRESS_BILLING_LINE1, | 94 { 4, ADDRESS_BILLING_LINE1, |
87 IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_1 }, | 95 IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_1 }, |
88 { 5, ADDRESS_BILLING_LINE2, | 96 { 5, ADDRESS_BILLING_LINE2, |
89 IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_2 }, | 97 IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_2 }, |
90 { 6, ADDRESS_BILLING_CITY, | 98 { 6, ADDRESS_BILLING_CITY, |
91 IDS_AUTOFILL_DIALOG_PLACEHOLDER_LOCALITY }, | 99 IDS_AUTOFILL_DIALOG_PLACEHOLDER_LOCALITY }, |
92 // TODO(estade): state placeholder should depend on locale. | |
93 { 7, ADDRESS_BILLING_STATE, IDS_AUTOFILL_FIELD_LABEL_STATE }, | 100 { 7, ADDRESS_BILLING_STATE, IDS_AUTOFILL_FIELD_LABEL_STATE }, |
94 { 7, ADDRESS_BILLING_ZIP, | 101 { 7, ADDRESS_BILLING_ZIP, |
95 IDS_AUTOFILL_DIALOG_PLACEHOLDER_POSTAL_CODE }, | 102 IDS_AUTOFILL_DIALOG_PLACEHOLDER_POSTAL_CODE }, |
96 // We don't allow the user to change the country: http://crbug.com/247518 | 103 }; |
97 { -1, ADDRESS_BILLING_COUNTRY, 0 }, | 104 |
98 { 9, PHONE_BILLING_WHOLE_NUMBER, | 105 const DetailInput kBillingPhoneInputs[] = { |
| 106 { 19, PHONE_BILLING_WHOLE_NUMBER, |
99 IDS_AUTOFILL_DIALOG_PLACEHOLDER_PHONE_NUMBER }, | 107 IDS_AUTOFILL_DIALOG_PLACEHOLDER_PHONE_NUMBER }, |
100 }; | 108 }; |
101 | 109 |
102 const DetailInput kEmailInputs[] = { | 110 const DetailInput kEmailInputs[] = { |
103 { 10, EMAIL_ADDRESS, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL }, | 111 { 20, EMAIL_ADDRESS, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL }, |
104 }; | 112 }; |
105 | 113 |
| 114 const int kShippingInputsStartRow = 21; |
106 const DetailInput kShippingInputs[] = { | 115 const DetailInput kShippingInputs[] = { |
107 { 11, NAME_FULL, IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESSEE_NAME }, | 116 { 21, NAME_FULL, IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESSEE_NAME }, |
108 { 12, ADDRESS_HOME_LINE1, IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_1 }, | 117 { 22, ADDRESS_HOME_LINE1, IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_1 }, |
109 { 13, ADDRESS_HOME_LINE2, IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_2 }, | 118 { 23, ADDRESS_HOME_LINE2, IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_2 }, |
110 { 14, ADDRESS_HOME_CITY, IDS_AUTOFILL_DIALOG_PLACEHOLDER_LOCALITY }, | 119 { 24, ADDRESS_HOME_CITY, IDS_AUTOFILL_DIALOG_PLACEHOLDER_LOCALITY }, |
111 { 15, ADDRESS_HOME_STATE, IDS_AUTOFILL_FIELD_LABEL_STATE }, | 120 { 25, ADDRESS_HOME_STATE, IDS_AUTOFILL_FIELD_LABEL_STATE }, |
112 { 15, ADDRESS_HOME_ZIP, IDS_AUTOFILL_DIALOG_PLACEHOLDER_POSTAL_CODE }, | 121 { 25, ADDRESS_HOME_ZIP, IDS_AUTOFILL_DIALOG_PLACEHOLDER_POSTAL_CODE }, |
113 { -1, ADDRESS_HOME_COUNTRY, 0 }, | 122 }; |
114 { 17, PHONE_HOME_WHOLE_NUMBER, | 123 |
| 124 const DetailInput kShippingPhoneInputs[] = { |
| 125 { 37, PHONE_HOME_WHOLE_NUMBER, |
115 IDS_AUTOFILL_DIALOG_PLACEHOLDER_PHONE_NUMBER }, | 126 IDS_AUTOFILL_DIALOG_PLACEHOLDER_PHONE_NUMBER }, |
116 }; | 127 }; |
117 | 128 |
118 switch (dialog_section) { | 129 switch (dialog_section) { |
119 case SECTION_CC: | 130 case SECTION_CC: |
120 BuildInputs(kCCInputs, arraysize(kCCInputs), inputs); | 131 BuildInputs(kCCInputs, arraysize(kCCInputs), inputs); |
121 break; | 132 break; |
122 | 133 |
123 case SECTION_BILLING: | 134 case SECTION_BILLING: |
124 BuildInputs(kBillingInputs, arraysize(kBillingInputs), inputs); | 135 if (i18ninput::IsI18nAddressInputEnabled()) { |
| 136 i18ninput::BuildI18nInputs(i18ninput::ADDRESS_TYPE_BILLING, |
| 137 country_region, |
| 138 kBillingInputsStartRow, |
| 139 inputs); |
| 140 } else { |
| 141 BuildInputs(kBillingInputs, arraysize(kBillingInputs), inputs); |
| 142 } |
| 143 BuildInputs(kBillingPhoneInputs, arraysize(kBillingPhoneInputs), inputs); |
125 BuildInputs(kEmailInputs, arraysize(kEmailInputs), inputs); | 144 BuildInputs(kEmailInputs, arraysize(kEmailInputs), inputs); |
126 break; | 145 break; |
127 | 146 |
128 case SECTION_CC_BILLING: | 147 case SECTION_CC_BILLING: |
129 BuildInputs(kCCInputs, arraysize(kCCInputs), inputs); | 148 BuildInputs(kCCInputs, arraysize(kCCInputs), inputs); |
130 BuildInputs(kBillingInputs, arraysize(kBillingInputs), inputs); | 149 if (i18ninput::IsI18nAddressInputEnabled()) { |
| 150 i18ninput::BuildI18nInputs(i18ninput::ADDRESS_TYPE_BILLING, |
| 151 country_region, |
| 152 kBillingInputsStartRow, |
| 153 inputs); |
| 154 } else { |
| 155 BuildInputs(kBillingInputs, arraysize(kBillingInputs), inputs); |
| 156 } |
| 157 BuildInputs(kBillingPhoneInputs, arraysize(kBillingPhoneInputs), inputs); |
131 break; | 158 break; |
132 | 159 |
133 case SECTION_SHIPPING: | 160 case SECTION_SHIPPING: |
134 BuildInputs(kShippingInputs, arraysize(kShippingInputs), inputs); | 161 if (i18ninput::IsI18nAddressInputEnabled()) { |
| 162 i18ninput::BuildI18nInputs(i18ninput::ADDRESS_TYPE_SHIPPING, |
| 163 country_region, |
| 164 kShippingInputsStartRow, |
| 165 inputs); |
| 166 } else { |
| 167 BuildInputs(kShippingInputs, arraysize(kShippingInputs), inputs); |
| 168 } |
| 169 BuildInputs( |
| 170 kShippingPhoneInputs, arraysize(kShippingPhoneInputs), inputs); |
135 break; | 171 break; |
136 } | 172 } |
137 } | 173 } |
138 | 174 |
139 AutofillMetrics::DialogUiEvent DialogSectionToUiItemAddedEvent( | 175 AutofillMetrics::DialogUiEvent DialogSectionToUiItemAddedEvent( |
140 DialogSection section) { | 176 DialogSection section) { |
141 switch (section) { | 177 switch (section) { |
142 case SECTION_BILLING: | 178 case SECTION_BILLING: |
143 return AutofillMetrics::DIALOG_UI_BILLING_ITEM_ADDED; | 179 return AutofillMetrics::DIALOG_UI_BILLING_ITEM_ADDED; |
144 | 180 |
(...skipping 26 matching lines...) Expand all Loading... |
171 case SECTION_CC: | 207 case SECTION_CC: |
172 return AutofillMetrics::DIALOG_UI_CC_SELECTED_SUGGESTION_CHANGED; | 208 return AutofillMetrics::DIALOG_UI_CC_SELECTED_SUGGESTION_CHANGED; |
173 } | 209 } |
174 | 210 |
175 NOTREACHED(); | 211 NOTREACHED(); |
176 return AutofillMetrics::NUM_DIALOG_UI_EVENTS; | 212 return AutofillMetrics::NUM_DIALOG_UI_EVENTS; |
177 } | 213 } |
178 | 214 |
179 } // namespace common | 215 } // namespace common |
180 } // namespace autofill | 216 } // namespace autofill |
OLD | NEW |