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 <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 field.Type().GetStorableType()))); | 194 field.Type().GetStorableType()))); |
195 } | 195 } |
196 | 196 |
197 // Initializes |form_group| from user-entered data. | 197 // Initializes |form_group| from user-entered data. |
198 void FillFormGroupFromOutputs(const FieldValueMap& detail_outputs, | 198 void FillFormGroupFromOutputs(const FieldValueMap& detail_outputs, |
199 FormGroup* form_group) { | 199 FormGroup* form_group) { |
200 for (FieldValueMap::const_iterator iter = detail_outputs.begin(); | 200 for (FieldValueMap::const_iterator iter = detail_outputs.begin(); |
201 iter != detail_outputs.end(); ++iter) { | 201 iter != detail_outputs.end(); ++iter) { |
202 ServerFieldType type = iter->first; | 202 ServerFieldType type = iter->first; |
203 if (!iter->second.empty()) { | 203 if (!iter->second.empty()) { |
204 if (type == ADDRESS_HOME_COUNTRY || type == ADDRESS_BILLING_COUNTRY) { | 204 form_group->SetInfo(AutofillType(type), |
205 form_group->SetInfo(AutofillType(type), | 205 iter->second, |
206 iter->second, | 206 g_browser_process->GetApplicationLocale()); |
207 g_browser_process->GetApplicationLocale()); | |
208 } else { | |
209 form_group->SetRawInfo( | |
210 AutofillType(type).GetStorableType(), iter->second); | |
211 } | |
212 } | 207 } |
213 } | 208 } |
214 } | 209 } |
215 | 210 |
216 // Get billing info from |output| and put it into |card|, |cvc|, and |profile|. | 211 // Get billing info from |output| and put it into |card|, |cvc|, and |profile|. |
217 // These outparams are required because |card|/|profile| accept different types | 212 // These outparams are required because |card|/|profile| accept different types |
218 // of raw info, and CreditCard doesn't save CVCs. | 213 // of raw info, and CreditCard doesn't save CVCs. |
219 void GetBillingInfoFromOutputs(const FieldValueMap& output, | 214 void GetBillingInfoFromOutputs(const FieldValueMap& output, |
220 CreditCard* card, | 215 CreditCard* card, |
221 base::string16* cvc, | 216 base::string16* cvc, |
222 AutofillProfile* profile) { | 217 AutofillProfile* profile) { |
223 for (FieldValueMap::const_iterator it = output.begin(); | 218 for (FieldValueMap::const_iterator it = output.begin(); |
224 it != output.end(); ++it) { | 219 it != output.end(); ++it) { |
225 const ServerFieldType type = it->first; | 220 const ServerFieldType type = it->first; |
226 base::string16 trimmed; | 221 base::string16 trimmed; |
227 base::TrimWhitespace(it->second, base::TRIM_ALL, &trimmed); | 222 base::TrimWhitespace(it->second, base::TRIM_ALL, &trimmed); |
228 | 223 |
229 // Special case CVC as CreditCard just swallows it. | 224 // Special case CVC as CreditCard just swallows it. |
230 if (type == CREDIT_CARD_VERIFICATION_CODE) { | 225 if (type == CREDIT_CARD_VERIFICATION_CODE) { |
231 if (cvc) | 226 if (cvc) |
232 cvc->assign(trimmed); | 227 cvc->assign(trimmed); |
233 } else if (type == ADDRESS_HOME_COUNTRY || | 228 } else if (common::IsCreditCardType(type)) { |
234 type == ADDRESS_BILLING_COUNTRY) { | 229 card->SetRawInfo(type, trimmed); |
235 if (profile) { | |
236 profile->SetInfo(AutofillType(type), | |
237 trimmed, | |
238 g_browser_process->GetApplicationLocale()); | |
239 } | |
240 } else { | 230 } else { |
241 // Copy the credit card name to |profile| in addition to |card| as | 231 // Copy the credit card name to |profile| in addition to |card| as |
242 // wallet::Instrument requires a recipient name for its billing address. | 232 // wallet::Instrument requires a recipient name for its billing address. |
243 if (card && type == NAME_FULL) | 233 if (card && type == NAME_FULL) |
244 card->SetRawInfo(CREDIT_CARD_NAME, trimmed); | 234 card->SetRawInfo(CREDIT_CARD_NAME, trimmed); |
245 | 235 |
246 if (common::IsCreditCardType(type)) { | 236 if (profile) { |
247 if (card) | 237 profile->SetInfo(AutofillType(AutofillType(type).GetStorableType()), |
248 card->SetRawInfo(type, trimmed); | 238 trimmed, |
249 } else if (profile) { | 239 g_browser_process->GetApplicationLocale()); |
250 profile->SetRawInfo(AutofillType(type).GetStorableType(), trimmed); | |
251 } | 240 } |
252 } | 241 } |
253 } | 242 } |
254 } | 243 } |
255 | 244 |
256 // Returns the containing window for the given |web_contents|. The containing | 245 // Returns the containing window for the given |web_contents|. The containing |
257 // window might be a browser window for a Chrome tab, or it might be an app | 246 // window might be a browser window for a Chrome tab, or it might be an app |
258 // window for a platform app. | 247 // window for a platform app. |
259 ui::BaseWindow* GetBaseWindowForWebContents( | 248 ui::BaseWindow* GetBaseWindowForWebContents( |
260 content::WebContents* web_contents) { | 249 content::WebContents* web_contents) { |
(...skipping 2823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3084 cards[i]->guid(), | 3073 cards[i]->guid(), |
3085 cards[i]->Label(), | 3074 cards[i]->Label(), |
3086 rb.GetImageNamed(CreditCard::IconResourceId(cards[i]->type()))); | 3075 rb.GetImageNamed(CreditCard::IconResourceId(cards[i]->type()))); |
3087 suggested_cc_.SetEnabled( | 3076 suggested_cc_.SetEnabled( |
3088 cards[i]->guid(), | 3077 cards[i]->guid(), |
3089 !ShouldDisallowCcType(cards[i]->TypeForDisplay())); | 3078 !ShouldDisallowCcType(cards[i]->TypeForDisplay())); |
3090 } | 3079 } |
3091 | 3080 |
3092 const std::vector<AutofillProfile*>& profiles = manager->GetProfiles(); | 3081 const std::vector<AutofillProfile*>& profiles = manager->GetProfiles(); |
3093 std::vector<base::string16> labels; | 3082 std::vector<base::string16> labels; |
3094 AutofillProfile::CreateDifferentiatingLabels(profiles, &labels); | 3083 AutofillProfile::CreateDifferentiatingLabels( |
| 3084 profiles, |
| 3085 g_browser_process->GetApplicationLocale(), |
| 3086 &labels); |
3095 DCHECK_EQ(labels.size(), profiles.size()); | 3087 DCHECK_EQ(labels.size(), profiles.size()); |
3096 for (size_t i = 0; i < profiles.size(); ++i) { | 3088 for (size_t i = 0; i < profiles.size(); ++i) { |
3097 const AutofillProfile& profile = *profiles[i]; | 3089 const AutofillProfile& profile = *profiles[i]; |
3098 if (!i18ninput::AddressHasCompleteAndVerifiedData( | 3090 if (!i18ninput::AddressHasCompleteAndVerifiedData( |
3099 profile, g_browser_process->GetApplicationLocale())) { | 3091 profile, g_browser_process->GetApplicationLocale())) { |
3100 continue; | 3092 continue; |
3101 } | 3093 } |
3102 | 3094 |
3103 // Don't add variants for addresses: name is part of credit card and | 3095 // Don't add variants for addresses: name is part of credit card and |
3104 // we'll just ignore email and phone number variants. | 3096 // we'll just ignore email and phone number variants. |
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4168 view_->UpdateButtonStrip(); | 4160 view_->UpdateButtonStrip(); |
4169 } | 4161 } |
4170 | 4162 |
4171 void AutofillDialogControllerImpl::FetchWalletCookie() { | 4163 void AutofillDialogControllerImpl::FetchWalletCookie() { |
4172 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); | 4164 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); |
4173 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); | 4165 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); |
4174 signin_helper_->StartWalletCookieValueFetch(); | 4166 signin_helper_->StartWalletCookieValueFetch(); |
4175 } | 4167 } |
4176 | 4168 |
4177 } // namespace autofill | 4169 } // namespace autofill |
OLD | NEW |