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_controller_impl.h" | 5 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 (*inputs)[j].initial_value = | 146 (*inputs)[j].initial_value = |
147 group->GetInfo((*inputs)[j].type, app_locale); | 147 group->GetInfo((*inputs)[j].type, app_locale); |
148 } | 148 } |
149 } | 149 } |
150 | 150 |
151 // Initializes |form_group| from user-entered data. | 151 // Initializes |form_group| from user-entered data. |
152 void FillFormGroupFromOutputs(const DetailOutputMap& detail_outputs, | 152 void FillFormGroupFromOutputs(const DetailOutputMap& detail_outputs, |
153 FormGroup* form_group) { | 153 FormGroup* form_group) { |
154 for (DetailOutputMap::const_iterator iter = detail_outputs.begin(); | 154 for (DetailOutputMap::const_iterator iter = detail_outputs.begin(); |
155 iter != detail_outputs.end(); ++iter) { | 155 iter != detail_outputs.end(); ++iter) { |
156 if (!iter->second.empty()) | 156 if (!iter->second.empty()) { |
157 form_group->SetRawInfo(iter->first->type, iter->second); | 157 if (iter->first->type == ADDRESS_HOME_COUNTRY || |
| 158 iter->first->type == ADDRESS_BILLING_COUNTRY) { |
| 159 form_group->SetInfo(iter->first->type, |
| 160 iter->second, |
| 161 g_browser_process->GetApplicationLocale()); |
| 162 } else { |
| 163 form_group->SetRawInfo(iter->first->type, iter->second); |
| 164 } |
| 165 } |
158 } | 166 } |
159 } | 167 } |
160 | 168 |
161 // Get billing info from |output| and put it into |card|, |cvc|, and |profile|. | 169 // Get billing info from |output| and put it into |card|, |cvc|, and |profile|. |
162 // These outparams are required because |card|/|profile| accept different types | 170 // These outparams are required because |card|/|profile| accept different types |
163 // of raw info, and CreditCard doesn't save CVCs. | 171 // of raw info, and CreditCard doesn't save CVCs. |
164 void GetBillingInfoFromOutputs(const DetailOutputMap& output, | 172 void GetBillingInfoFromOutputs(const DetailOutputMap& output, |
165 CreditCard* card, | 173 CreditCard* card, |
166 string16* cvc, | 174 string16* cvc, |
167 AutofillProfile* profile) { | 175 AutofillProfile* profile) { |
168 for (DetailOutputMap::const_iterator it = output.begin(); | 176 for (DetailOutputMap::const_iterator it = output.begin(); |
169 it != output.end(); ++it) { | 177 it != output.end(); ++it) { |
170 string16 trimmed; | 178 string16 trimmed; |
171 TrimWhitespace(it->second, TRIM_ALL, &trimmed); | 179 TrimWhitespace(it->second, TRIM_ALL, &trimmed); |
172 | 180 |
173 // Special case CVC as CreditCard just swallows it. | 181 // Special case CVC as CreditCard just swallows it. |
174 if (it->first->type == CREDIT_CARD_VERIFICATION_CODE) { | 182 if (it->first->type == CREDIT_CARD_VERIFICATION_CODE) { |
175 if (cvc) | 183 if (cvc) |
176 cvc->assign(trimmed); | 184 cvc->assign(trimmed); |
| 185 } else if (it->first->type == ADDRESS_HOME_COUNTRY || |
| 186 it->first->type == ADDRESS_BILLING_COUNTRY) { |
| 187 profile->SetInfo(it->first->type, |
| 188 trimmed, |
| 189 g_browser_process->GetApplicationLocale()); |
177 } else { | 190 } else { |
178 // Copy the credit card name to |profile| in addition to |card| as | 191 // Copy the credit card name to |profile| in addition to |card| as |
179 // wallet::Instrument requires a recipient name for its billing address. | 192 // wallet::Instrument requires a recipient name for its billing address. |
180 if (profile && it->first->type == CREDIT_CARD_NAME) | 193 if (profile && it->first->type == CREDIT_CARD_NAME) |
181 profile->SetRawInfo(NAME_FULL, trimmed); | 194 profile->SetRawInfo(NAME_FULL, trimmed); |
182 | 195 |
183 if (IsCreditCardType(it->first->type)) { | 196 if (IsCreditCardType(it->first->type)) { |
184 if (card) | 197 if (card) |
185 card->SetRawInfo(it->first->type, trimmed); | 198 card->SetRawInfo(it->first->type, trimmed); |
186 } else if (profile) { | 199 } else if (profile) { |
(...skipping 1878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2065 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; | 2078 AutofillMetrics::DIALOG_USER_SIGNED_IN_NO_WALLET_NO_AUTOFILL; |
2066 } | 2079 } |
2067 | 2080 |
2068 // Has Wallet items. | 2081 // Has Wallet items. |
2069 return has_autofill_profiles ? | 2082 return has_autofill_profiles ? |
2070 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : | 2083 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_HAS_AUTOFILL : |
2071 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; | 2084 AutofillMetrics::DIALOG_USER_SIGNED_IN_HAS_WALLET_NO_AUTOFILL; |
2072 } | 2085 } |
2073 | 2086 |
2074 } // namespace autofill | 2087 } // namespace autofill |
OLD | NEW |