Chromium Code Reviews| 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 "components/autofill/core/browser/autofill_field.h" | 7 #include "components/autofill/core/browser/autofill_field.h" |
| 8 #include "components/autofill/core/browser/autofill_type.h" | 8 #include "components/autofill/core/browser/autofill_type.h" |
| 9 #include "grit/chromium_strings.h" | 9 #include "grit/chromium_strings.h" |
| 10 #include "grit/component_strings.h" | 10 #include "grit/component_strings.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 DetailInputs* inputs) { | 65 DetailInputs* inputs) { |
| 66 for (size_t i = 0; i < template_size; ++i) { | 66 for (size_t i = 0; i < template_size; ++i) { |
| 67 const DetailInput* input = &input_template[i]; | 67 const DetailInput* input = &input_template[i]; |
| 68 inputs->push_back(*input); | 68 inputs->push_back(*input); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 // Constructs |inputs| from template data for a given |dialog_section|. | 72 // Constructs |inputs| from template data for a given |dialog_section|. |
| 73 void BuildInputsForSection(DialogSection dialog_section, | 73 void BuildInputsForSection(DialogSection dialog_section, |
| 74 DetailInputs* inputs) { | 74 DetailInputs* inputs) { |
| 75 const DetailInput kEmailInputs[] = { | |
| 76 { 1, EMAIL_ADDRESS, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL }, | |
| 77 }; | |
| 78 | |
| 79 const DetailInput kCCInputs[] = { | 75 const DetailInput kCCInputs[] = { |
| 80 { 2, CREDIT_CARD_NUMBER, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CARD_NUMBER }, | 76 { 1, CREDIT_CARD_NUMBER, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CARD_NUMBER }, |
| 81 { 3, CREDIT_CARD_EXP_MONTH, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EXPIRY_MONTH }, | 77 { 2, CREDIT_CARD_EXP_MONTH, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EXPIRY_MONTH }, |
| 82 { 3, CREDIT_CARD_EXP_4_DIGIT_YEAR, | 78 { 2, CREDIT_CARD_EXP_4_DIGIT_YEAR, |
| 83 IDS_AUTOFILL_DIALOG_PLACEHOLDER_EXPIRY_YEAR }, | 79 IDS_AUTOFILL_DIALOG_PLACEHOLDER_EXPIRY_YEAR }, |
| 84 { 3, CREDIT_CARD_VERIFICATION_CODE, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CVC, | 80 { 2, CREDIT_CARD_VERIFICATION_CODE, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CVC, |
| 85 1.5 }, | 81 1.5 }, |
| 86 }; | 82 }; |
| 87 | 83 |
| 88 const DetailInput kBillingInputs[] = { | 84 const DetailInput kBillingInputs[] = { |
| 89 { 4, NAME_BILLING_FULL, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CARDHOLDER_NAME }, | 85 { 3, NAME_BILLING_FULL, IDS_AUTOFILL_DIALOG_PLACEHOLDER_CARDHOLDER_NAME }, |
| 90 { 5, ADDRESS_BILLING_LINE1, | 86 { 4, ADDRESS_BILLING_LINE1, |
| 91 IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_1 }, | 87 IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_1 }, |
| 92 { 6, ADDRESS_BILLING_LINE2, | 88 { 5, ADDRESS_BILLING_LINE2, |
| 93 IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_2 }, | 89 IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_2 }, |
| 94 { 7, ADDRESS_BILLING_CITY, | 90 { 6, ADDRESS_BILLING_CITY, |
| 95 IDS_AUTOFILL_DIALOG_PLACEHOLDER_LOCALITY }, | 91 IDS_AUTOFILL_DIALOG_PLACEHOLDER_LOCALITY }, |
| 96 // TODO(estade): state placeholder should depend on locale. | 92 // TODO(estade): state placeholder should depend on locale. |
| 97 { 8, ADDRESS_BILLING_STATE, IDS_AUTOFILL_FIELD_LABEL_STATE }, | 93 { 7, ADDRESS_BILLING_STATE, IDS_AUTOFILL_FIELD_LABEL_STATE }, |
| 98 { 8, ADDRESS_BILLING_ZIP, | 94 { 7, ADDRESS_BILLING_ZIP, |
| 99 IDS_AUTOFILL_DIALOG_PLACEHOLDER_POSTAL_CODE }, | 95 IDS_AUTOFILL_DIALOG_PLACEHOLDER_POSTAL_CODE }, |
| 100 // We don't allow the user to change the country: http://crbug.com/247518 | 96 // We don't allow the user to change the country: http://crbug.com/247518 |
| 101 { -1, ADDRESS_BILLING_COUNTRY, 0 }, | 97 { -1, ADDRESS_BILLING_COUNTRY, 0 }, |
| 102 { 10, PHONE_BILLING_WHOLE_NUMBER, | 98 { 9, PHONE_BILLING_WHOLE_NUMBER, |
| 103 IDS_AUTOFILL_DIALOG_PLACEHOLDER_PHONE_NUMBER }, | 99 IDS_AUTOFILL_DIALOG_PLACEHOLDER_PHONE_NUMBER }, |
| 100 { 10, EMAIL_ADDRESS, IDS_AUTOFILL_DIALOG_PLACEHOLDER_EMAIL }, | |
| 104 }; | 101 }; |
| 105 | 102 |
| 106 const DetailInput kShippingInputs[] = { | 103 const DetailInput kShippingInputs[] = { |
| 107 { 11, NAME_FULL, IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESSEE_NAME }, | 104 { 11, NAME_FULL, IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESSEE_NAME }, |
| 108 { 12, ADDRESS_HOME_LINE1, IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_1 }, | 105 { 12, ADDRESS_HOME_LINE1, IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_1 }, |
| 109 { 13, ADDRESS_HOME_LINE2, IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_2 }, | 106 { 13, ADDRESS_HOME_LINE2, IDS_AUTOFILL_DIALOG_PLACEHOLDER_ADDRESS_LINE_2 }, |
| 110 { 14, ADDRESS_HOME_CITY, IDS_AUTOFILL_DIALOG_PLACEHOLDER_LOCALITY }, | 107 { 14, ADDRESS_HOME_CITY, IDS_AUTOFILL_DIALOG_PLACEHOLDER_LOCALITY }, |
| 111 { 15, ADDRESS_HOME_STATE, IDS_AUTOFILL_FIELD_LABEL_STATE }, | 108 { 15, ADDRESS_HOME_STATE, IDS_AUTOFILL_FIELD_LABEL_STATE }, |
| 112 { 15, ADDRESS_HOME_ZIP, IDS_AUTOFILL_DIALOG_PLACEHOLDER_POSTAL_CODE }, | 109 { 15, ADDRESS_HOME_ZIP, IDS_AUTOFILL_DIALOG_PLACEHOLDER_POSTAL_CODE }, |
| 113 { -1, ADDRESS_HOME_COUNTRY, 0 }, | 110 { -1, ADDRESS_HOME_COUNTRY, 0 }, |
| 114 { 17, PHONE_HOME_WHOLE_NUMBER, | 111 { 17, PHONE_HOME_WHOLE_NUMBER, |
| 115 IDS_AUTOFILL_DIALOG_PLACEHOLDER_PHONE_NUMBER }, | 112 IDS_AUTOFILL_DIALOG_PLACEHOLDER_PHONE_NUMBER }, |
| 116 }; | 113 }; |
| 117 | 114 |
| 118 switch (dialog_section) { | 115 switch (dialog_section) { |
| 119 case SECTION_EMAIL: | |
| 120 BuildInputs(kEmailInputs, | |
| 121 arraysize(kEmailInputs), | |
| 122 inputs); | |
| 123 break; | |
| 124 | |
| 125 case SECTION_CC: | 116 case SECTION_CC: |
| 126 BuildInputs(kCCInputs, | 117 BuildInputs(kCCInputs, |
| 127 arraysize(kCCInputs), | 118 arraysize(kCCInputs), |
| 128 inputs); | 119 inputs); |
| 129 break; | 120 break; |
| 130 | 121 |
| 131 case SECTION_BILLING: | 122 case SECTION_BILLING: |
| 132 BuildInputs(kBillingInputs, | 123 BuildInputs(kBillingInputs, |
| 133 arraysize(kBillingInputs), | 124 arraysize(kBillingInputs), |
| 134 inputs); | 125 inputs); |
| 135 break; | 126 break; |
| 136 | 127 |
| 137 case SECTION_CC_BILLING: | 128 case SECTION_CC_BILLING: |
| 138 BuildInputs(kCCInputs, | 129 BuildInputs(kCCInputs, |
| 139 arraysize(kCCInputs), | 130 arraysize(kCCInputs), |
| 140 inputs); | 131 inputs); |
| 141 BuildInputs(kBillingInputs, | 132 BuildInputs(kBillingInputs, |
| 142 arraysize(kBillingInputs), | 133 arraysize(kBillingInputs) - 1, // Skip the email field. |
|
Evan Stade
2013/09/05 16:54:09
hmmm, maybe it would be cleaner to add the email i
Ilya Sherman
2013/09/06 04:16:05
Done.
| |
| 143 inputs); | 134 inputs); |
| 144 break; | 135 break; |
| 145 | 136 |
| 146 case SECTION_SHIPPING: | 137 case SECTION_SHIPPING: |
| 147 BuildInputs(kShippingInputs, | 138 BuildInputs(kShippingInputs, |
| 148 arraysize(kShippingInputs), | 139 arraysize(kShippingInputs), |
| 149 inputs); | 140 inputs); |
| 150 break; | 141 break; |
| 151 } | 142 } |
| 152 } | 143 } |
| 153 | 144 |
| 154 AutofillMetrics::DialogUiEvent DialogSectionToUiEditEvent( | 145 AutofillMetrics::DialogUiEvent DialogSectionToUiEditEvent( |
| 155 DialogSection section) { | 146 DialogSection section) { |
| 156 switch (section) { | 147 switch (section) { |
| 157 case SECTION_EMAIL: | |
| 158 return AutofillMetrics::DIALOG_UI_EMAIL_EDIT_UI_SHOWN; | |
| 159 | |
| 160 case SECTION_BILLING: | 148 case SECTION_BILLING: |
| 161 return AutofillMetrics::DIALOG_UI_BILLING_EDIT_UI_SHOWN; | 149 return AutofillMetrics::DIALOG_UI_BILLING_EDIT_UI_SHOWN; |
| 162 | 150 |
| 163 case SECTION_CC_BILLING: | 151 case SECTION_CC_BILLING: |
| 164 return AutofillMetrics::DIALOG_UI_CC_BILLING_EDIT_UI_SHOWN; | 152 return AutofillMetrics::DIALOG_UI_CC_BILLING_EDIT_UI_SHOWN; |
| 165 | 153 |
| 166 case SECTION_SHIPPING: | 154 case SECTION_SHIPPING: |
| 167 return AutofillMetrics::DIALOG_UI_SHIPPING_EDIT_UI_SHOWN; | 155 return AutofillMetrics::DIALOG_UI_SHIPPING_EDIT_UI_SHOWN; |
| 168 | 156 |
| 169 case SECTION_CC: | 157 case SECTION_CC: |
| 170 return AutofillMetrics::DIALOG_UI_CC_EDIT_UI_SHOWN; | 158 return AutofillMetrics::DIALOG_UI_CC_EDIT_UI_SHOWN; |
| 171 } | 159 } |
| 172 | 160 |
| 173 NOTREACHED(); | 161 NOTREACHED(); |
| 174 return AutofillMetrics::NUM_DIALOG_UI_EVENTS; | 162 return AutofillMetrics::NUM_DIALOG_UI_EVENTS; |
| 175 } | 163 } |
| 176 | 164 |
| 177 AutofillMetrics::DialogUiEvent DialogSectionToUiItemAddedEvent( | 165 AutofillMetrics::DialogUiEvent DialogSectionToUiItemAddedEvent( |
| 178 DialogSection section) { | 166 DialogSection section) { |
| 179 switch (section) { | 167 switch (section) { |
| 180 case SECTION_EMAIL: | |
| 181 return AutofillMetrics::DIALOG_UI_EMAIL_ITEM_ADDED; | |
| 182 | |
| 183 case SECTION_BILLING: | 168 case SECTION_BILLING: |
| 184 return AutofillMetrics::DIALOG_UI_BILLING_ITEM_ADDED; | 169 return AutofillMetrics::DIALOG_UI_BILLING_ITEM_ADDED; |
| 185 | 170 |
| 186 case SECTION_CC_BILLING: | 171 case SECTION_CC_BILLING: |
| 187 return AutofillMetrics::DIALOG_UI_CC_BILLING_ITEM_ADDED; | 172 return AutofillMetrics::DIALOG_UI_CC_BILLING_ITEM_ADDED; |
| 188 | 173 |
| 189 case SECTION_SHIPPING: | 174 case SECTION_SHIPPING: |
| 190 return AutofillMetrics::DIALOG_UI_SHIPPING_ITEM_ADDED; | 175 return AutofillMetrics::DIALOG_UI_SHIPPING_ITEM_ADDED; |
| 191 | 176 |
| 192 case SECTION_CC: | 177 case SECTION_CC: |
| 193 return AutofillMetrics::DIALOG_UI_CC_ITEM_ADDED; | 178 return AutofillMetrics::DIALOG_UI_CC_ITEM_ADDED; |
| 194 } | 179 } |
| 195 | 180 |
| 196 NOTREACHED(); | 181 NOTREACHED(); |
| 197 return AutofillMetrics::NUM_DIALOG_UI_EVENTS; | 182 return AutofillMetrics::NUM_DIALOG_UI_EVENTS; |
| 198 } | 183 } |
| 199 | 184 |
| 200 AutofillMetrics::DialogUiEvent DialogSectionToUiSelectionChangedEvent( | 185 AutofillMetrics::DialogUiEvent DialogSectionToUiSelectionChangedEvent( |
| 201 DialogSection section) { | 186 DialogSection section) { |
| 202 switch (section) { | 187 switch (section) { |
| 203 case SECTION_EMAIL: | |
| 204 return AutofillMetrics::DIALOG_UI_EMAIL_SELECTED_SUGGESTION_CHANGED; | |
| 205 | |
| 206 case SECTION_BILLING: | 188 case SECTION_BILLING: |
| 207 return AutofillMetrics::DIALOG_UI_BILLING_SELECTED_SUGGESTION_CHANGED; | 189 return AutofillMetrics::DIALOG_UI_BILLING_SELECTED_SUGGESTION_CHANGED; |
| 208 | 190 |
| 209 case SECTION_CC_BILLING: | 191 case SECTION_CC_BILLING: |
| 210 return AutofillMetrics::DIALOG_UI_CC_BILLING_SELECTED_SUGGESTION_CHANGED; | 192 return AutofillMetrics::DIALOG_UI_CC_BILLING_SELECTED_SUGGESTION_CHANGED; |
| 211 | 193 |
| 212 case SECTION_SHIPPING: | 194 case SECTION_SHIPPING: |
| 213 return AutofillMetrics::DIALOG_UI_SHIPPING_SELECTED_SUGGESTION_CHANGED; | 195 return AutofillMetrics::DIALOG_UI_SHIPPING_SELECTED_SUGGESTION_CHANGED; |
| 214 | 196 |
| 215 case SECTION_CC: | 197 case SECTION_CC: |
| 216 return AutofillMetrics::DIALOG_UI_CC_SELECTED_SUGGESTION_CHANGED; | 198 return AutofillMetrics::DIALOG_UI_CC_SELECTED_SUGGESTION_CHANGED; |
| 217 } | 199 } |
| 218 | 200 |
| 219 NOTREACHED(); | 201 NOTREACHED(); |
| 220 return AutofillMetrics::NUM_DIALOG_UI_EVENTS; | 202 return AutofillMetrics::NUM_DIALOG_UI_EVENTS; |
| 221 } | 203 } |
| 222 | 204 |
| 223 } // namespace common | 205 } // namespace common |
| 224 } // namespace autofill | 206 } // namespace autofill |
| OLD | NEW |