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_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 1727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1738 return value.empty() ? | 1738 return value.empty() ? |
| 1739 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_VALIDATION_MISSING_VALUE) : | 1739 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_VALIDATION_MISSING_VALUE) : |
| 1740 base::string16(); | 1740 base::string16(); |
| 1741 } | 1741 } |
| 1742 | 1742 |
| 1743 // TODO(groby): Also add tests. | 1743 // TODO(groby): Also add tests. |
| 1744 ValidityMessages AutofillDialogControllerImpl::InputsAreValid( | 1744 ValidityMessages AutofillDialogControllerImpl::InputsAreValid( |
| 1745 DialogSection section, | 1745 DialogSection section, |
| 1746 const FieldValueMap& inputs) { | 1746 const FieldValueMap& inputs) { |
| 1747 ValidityMessages messages; | 1747 ValidityMessages messages; |
| 1748 FieldValueMap field_values; | |
| 1749 for (FieldValueMap::const_iterator iter = inputs.begin(); | 1748 for (FieldValueMap::const_iterator iter = inputs.begin(); |
| 1750 iter != inputs.end(); ++iter) { | 1749 iter != inputs.end(); ++iter) { |
| 1751 const ServerFieldType type = iter->first; | 1750 const ServerFieldType type = iter->first; |
| 1752 | 1751 |
| 1753 base::string16 text = InputValidityMessage(section, type, iter->second); | 1752 base::string16 text = InputValidityMessage(section, type, iter->second); |
| 1754 | 1753 |
| 1755 // Skip empty/unchanged fields in edit mode. Ignore country as it always has | 1754 // Skip empty/unchanged fields in edit mode. Ignore country as it always has |
| 1756 // a value. If the individual field does not have validation errors, assume | 1755 // a value. If the individual field does not have validation errors, assume |
| 1757 // it to be valid unless later proven otherwise. | 1756 // it to be valid unless later proven otherwise. |
| 1758 bool sure = InputWasEdited(type, iter->second) || | 1757 bool sure = InputWasEdited(type, iter->second) || |
| 1759 AutofillType(type).GetStorableType() == ADDRESS_HOME_COUNTRY; | 1758 AutofillType(type).GetStorableType() == ADDRESS_HOME_COUNTRY; |
| 1760 | |
| 1761 // Consider only individually valid fields for inter-field validation. | |
| 1762 if (text.empty()) { | |
| 1763 field_values[type] = iter->second; | |
| 1764 // If the field is valid but can be invalidated by inter-field validation, | |
|
Evan Stade
2014/01/31 00:22:13
example of the problem this caused:
1) CC is inva
groby-ooo-7-16
2014/01/31 19:59:59
I'm not sure this addresses that issue without sid
Evan Stade
2014/01/31 21:50:28
yes, we want it to always occur, so that we can va
| |
| 1765 // assume it to be unsure. | |
| 1766 if (type == CREDIT_CARD_EXP_4_DIGIT_YEAR || | |
| 1767 type == CREDIT_CARD_EXP_MONTH || | |
| 1768 type == CREDIT_CARD_VERIFICATION_CODE || | |
| 1769 type == PHONE_HOME_WHOLE_NUMBER || | |
| 1770 type == PHONE_BILLING_WHOLE_NUMBER) { | |
| 1771 sure = false; | |
| 1772 } | |
| 1773 } | |
| 1774 messages.Set(type, ValidityMessage(text, sure)); | 1759 messages.Set(type, ValidityMessage(text, sure)); |
| 1775 } | 1760 } |
| 1776 | 1761 |
| 1762 // For the convenience of using operator[]. | |
| 1763 FieldValueMap& field_values = const_cast<FieldValueMap&>(inputs); | |
| 1777 // Validate the date formed by month and year field. (Autofill dialog is | 1764 // Validate the date formed by month and year field. (Autofill dialog is |
| 1778 // never supposed to have 2-digit years, so not checked). | 1765 // never supposed to have 2-digit years, so not checked). |
| 1779 if (field_values.count(CREDIT_CARD_EXP_4_DIGIT_YEAR) && | 1766 if (field_values.count(CREDIT_CARD_EXP_4_DIGIT_YEAR) && |
| 1780 field_values.count(CREDIT_CARD_EXP_MONTH) && | 1767 field_values.count(CREDIT_CARD_EXP_MONTH) && |
| 1781 InputWasEdited(CREDIT_CARD_EXP_4_DIGIT_YEAR, | 1768 InputWasEdited(CREDIT_CARD_EXP_4_DIGIT_YEAR, |
| 1782 field_values[CREDIT_CARD_EXP_4_DIGIT_YEAR]) && | 1769 field_values[CREDIT_CARD_EXP_4_DIGIT_YEAR]) && |
| 1783 InputWasEdited(CREDIT_CARD_EXP_MONTH, | 1770 InputWasEdited(CREDIT_CARD_EXP_MONTH, |
| 1784 field_values[CREDIT_CARD_EXP_MONTH])) { | 1771 field_values[CREDIT_CARD_EXP_MONTH])) { |
| 1785 ValidityMessage year_message(base::string16(), true); | 1772 ValidityMessage year_message(base::string16(), true); |
| 1786 ValidityMessage month_message(base::string16(), true); | 1773 ValidityMessage month_message(base::string16(), true); |
| (...skipping 1861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3648 view_->UpdateButtonStrip(); | 3635 view_->UpdateButtonStrip(); |
| 3649 } | 3636 } |
| 3650 | 3637 |
| 3651 void AutofillDialogControllerImpl::FetchWalletCookie() { | 3638 void AutofillDialogControllerImpl::FetchWalletCookie() { |
| 3652 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); | 3639 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); |
| 3653 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); | 3640 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); |
| 3654 signin_helper_->StartWalletCookieValueFetch(); | 3641 signin_helper_->StartWalletCookieValueFetch(); |
| 3655 } | 3642 } |
| 3656 | 3643 |
| 3657 } // namespace autofill | 3644 } // namespace autofill |
| OLD | NEW |