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 1984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1995 FillFormGroupFromOutputs(inputs, &profile); | 1995 FillFormGroupFromOutputs(inputs, &profile); |
1996 scoped_ptr<AddressData> address_data = | 1996 scoped_ptr<AddressData> address_data = |
1997 i18n::CreateAddressDataFromAutofillProfile( | 1997 i18n::CreateAddressDataFromAutofillProfile( |
1998 profile, g_browser_process->GetApplicationLocale()); | 1998 profile, g_browser_process->GetApplicationLocale()); |
1999 address_data->language_code = AddressLanguageCodeForSection(section); | 1999 address_data->language_code = AddressLanguageCodeForSection(section); |
2000 | 2000 |
2001 Localization localization; | 2001 Localization localization; |
2002 localization.SetGetter(l10n_util::GetStringUTF8); | 2002 localization.SetGetter(l10n_util::GetStringUTF8); |
2003 FieldProblemMap problems; | 2003 FieldProblemMap problems; |
2004 status = GetValidator()->ValidateAddress(*address_data, NULL, &problems); | 2004 status = GetValidator()->ValidateAddress(*address_data, NULL, &problems); |
2005 common::AddressType address_type = section == SECTION_SHIPPING ? | 2005 bool billing = section != SECTION_SHIPPING; |
2006 common::ADDRESS_TYPE_SHIPPING : common::ADDRESS_TYPE_BILLING; | |
2007 | 2006 |
2008 for (FieldProblemMap::const_iterator iter = problems.begin(); | 2007 for (FieldProblemMap::const_iterator iter = problems.begin(); |
2009 iter != problems.end(); ++iter) { | 2008 iter != problems.end(); ++iter) { |
2010 bool sure = iter->second != MISSING_REQUIRED_FIELD; | 2009 bool sure = iter->second != MISSING_REQUIRED_FIELD; |
2011 base::string16 text = base::UTF8ToUTF16(localization.GetErrorMessage( | 2010 base::string16 text = base::UTF8ToUTF16(localization.GetErrorMessage( |
2012 *address_data, iter->first, iter->second, true, false)); | 2011 *address_data, iter->first, iter->second, true, false)); |
2013 messages.Set(i18ninput::TypeForField(iter->first, address_type), | 2012 messages.Set(i18n::TypeForField(iter->first, billing), |
2014 ValidityMessage(text, sure)); | 2013 ValidityMessage(text, sure)); |
2015 } | 2014 } |
2016 } | 2015 } |
2017 | 2016 |
2018 for (FieldValueMap::const_iterator iter = inputs.begin(); | 2017 for (FieldValueMap::const_iterator iter = inputs.begin(); |
2019 iter != inputs.end(); ++iter) { | 2018 iter != inputs.end(); ++iter) { |
2020 const ServerFieldType type = iter->first; | 2019 const ServerFieldType type = iter->first; |
2021 base::string16 text = InputValidityMessage(section, type, iter->second); | 2020 base::string16 text = InputValidityMessage(section, type, iter->second); |
2022 | 2021 |
2023 // Skip empty/unchanged fields in edit mode. If the individual field does | 2022 // Skip empty/unchanged fields in edit mode. If the individual field does |
(...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3393 return NULL; | 3392 return NULL; |
3394 } | 3393 } |
3395 | 3394 |
3396 void AutofillDialogControllerImpl::GetI18nValidatorSuggestions( | 3395 void AutofillDialogControllerImpl::GetI18nValidatorSuggestions( |
3397 DialogSection section, | 3396 DialogSection section, |
3398 ServerFieldType type, | 3397 ServerFieldType type, |
3399 std::vector<base::string16>* popup_values, | 3398 std::vector<base::string16>* popup_values, |
3400 std::vector<base::string16>* popup_labels, | 3399 std::vector<base::string16>* popup_labels, |
3401 std::vector<base::string16>* popup_icons) { | 3400 std::vector<base::string16>* popup_icons) { |
3402 AddressField focused_field; | 3401 AddressField focused_field; |
3403 if (!i18ninput::FieldForType(type, &focused_field)) | 3402 if (!i18n::FieldForType(type, &focused_field)) |
3404 return; | 3403 return; |
3405 | 3404 |
3406 FieldValueMap inputs; | 3405 FieldValueMap inputs; |
3407 view_->GetUserInput(section, &inputs); | 3406 view_->GetUserInput(section, &inputs); |
3408 | 3407 |
3409 AutofillProfile profile; | 3408 AutofillProfile profile; |
3410 FillFormGroupFromOutputs(inputs, &profile); | 3409 FillFormGroupFromOutputs(inputs, &profile); |
3411 | 3410 |
3412 scoped_ptr<AddressData> user_input = | 3411 scoped_ptr<AddressData> user_input = |
3413 i18n::CreateAddressDataFromAutofillProfile( | 3412 i18n::CreateAddressDataFromAutofillProfile( |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4158 view_->UpdateButtonStrip(); | 4157 view_->UpdateButtonStrip(); |
4159 } | 4158 } |
4160 | 4159 |
4161 void AutofillDialogControllerImpl::FetchWalletCookie() { | 4160 void AutofillDialogControllerImpl::FetchWalletCookie() { |
4162 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); | 4161 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); |
4163 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); | 4162 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); |
4164 signin_helper_->StartWalletCookieValueFetch(); | 4163 signin_helper_->StartWalletCookieValueFetch(); |
4165 } | 4164 } |
4166 | 4165 |
4167 } // namespace autofill | 4166 } // namespace autofill |
OLD | NEW |