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 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1597 CvcIconForCreditCardType(credit_card_type); | 1597 CvcIconForCreditCardType(credit_card_type); |
1598 | 1598 |
1599 return result; | 1599 return result; |
1600 } | 1600 } |
1601 | 1601 |
1602 bool AutofillDialogControllerImpl::FieldControlsIcons( | 1602 bool AutofillDialogControllerImpl::FieldControlsIcons( |
1603 ServerFieldType type) const { | 1603 ServerFieldType type) const { |
1604 return type == CREDIT_CARD_NUMBER; | 1604 return type == CREDIT_CARD_NUMBER; |
1605 } | 1605 } |
1606 | 1606 |
1607 // TODO(estade): Replace all the error messages here with more helpful and | |
1608 // translateable ones. TODO(groby): Also add tests. | |
Evan Stade
2013/10/01 01:53:00
do we have sufficient tests?
Dan Beam
2013/10/01 02:00:41
we have quite a few for InputsAreValid(), but I'll
| |
1609 string16 AutofillDialogControllerImpl::InputValidityMessage( | 1607 string16 AutofillDialogControllerImpl::InputValidityMessage( |
1610 DialogSection section, | 1608 DialogSection section, |
1611 ServerFieldType type, | 1609 ServerFieldType type, |
1612 const string16& value) { | 1610 const string16& value) { |
1613 // If the field is edited, clear any Wallet errors. | 1611 // If the field is edited, clear any Wallet errors. |
1614 if (IsPayingWithWallet()) { | 1612 if (IsPayingWithWallet()) { |
1615 WalletValidationErrors::iterator it = wallet_errors_.find(section); | 1613 WalletValidationErrors::iterator it = wallet_errors_.find(section); |
1616 if (it != wallet_errors_.end()) { | 1614 if (it != wallet_errors_.end()) { |
1617 TypeErrorInputMap::const_iterator iter = it->second.find(type); | 1615 TypeErrorInputMap::const_iterator iter = it->second.find(type); |
1618 if (iter != it->second.end()) { | 1616 if (iter != it->second.end()) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1704 default: | 1702 default: |
1705 NOTREACHED(); // Trying to validate unknown field. | 1703 NOTREACHED(); // Trying to validate unknown field. |
1706 break; | 1704 break; |
1707 } | 1705 } |
1708 | 1706 |
1709 return value.empty() ? | 1707 return value.empty() ? |
1710 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_VALIDATION_MISSING_VALUE) : | 1708 l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_VALIDATION_MISSING_VALUE) : |
1711 base::string16(); | 1709 base::string16(); |
1712 } | 1710 } |
1713 | 1711 |
1714 // TODO(estade): Replace all the error messages here with more helpful and | |
1715 // translateable ones. TODO(groby): Also add tests. | |
1716 ValidityData AutofillDialogControllerImpl::InputsAreValid( | 1712 ValidityData AutofillDialogControllerImpl::InputsAreValid( |
1717 DialogSection section, | 1713 DialogSection section, |
1718 const DetailOutputMap& inputs, | 1714 const DetailOutputMap& inputs, |
1719 ValidationType validation_type) { | 1715 ValidationType validation_type) { |
1720 ValidityData invalid_messages; | 1716 ValidityData invalid_messages; |
1721 std::map<ServerFieldType, string16> field_values; | 1717 std::map<ServerFieldType, string16> field_values; |
1722 for (DetailOutputMap::const_iterator iter = inputs.begin(); | 1718 for (DetailOutputMap::const_iterator iter = inputs.begin(); |
1723 iter != inputs.end(); ++iter) { | 1719 iter != inputs.end(); ++iter) { |
1724 const ServerFieldType type = iter->first->type; | 1720 const ServerFieldType type = iter->first->type; |
1725 | 1721 |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2172 | 2168 |
2173 void AutofillDialogControllerImpl::OnDidAcceptLegalDocuments() { | 2169 void AutofillDialogControllerImpl::OnDidAcceptLegalDocuments() { |
2174 DCHECK(is_submitting_ && IsPayingWithWallet()); | 2170 DCHECK(is_submitting_ && IsPayingWithWallet()); |
2175 has_accepted_legal_documents_ = true; | 2171 has_accepted_legal_documents_ = true; |
2176 LoadRiskFingerprintData(); | 2172 LoadRiskFingerprintData(); |
2177 } | 2173 } |
2178 | 2174 |
2179 void AutofillDialogControllerImpl::OnDidAuthenticateInstrument(bool success) { | 2175 void AutofillDialogControllerImpl::OnDidAuthenticateInstrument(bool success) { |
2180 DCHECK(is_submitting_ && IsPayingWithWallet()); | 2176 DCHECK(is_submitting_ && IsPayingWithWallet()); |
2181 | 2177 |
2182 // TODO(dbeam): use the returned full wallet. b/8332329 | 2178 // TODO(dbeam): use the returned full wallet. http://crbug.com/224992 |
2183 if (success) { | 2179 if (success) { |
2184 GetFullWallet(); | 2180 GetFullWallet(); |
2185 } else { | 2181 } else { |
2186 DisableWallet(wallet::WalletClient::UNKNOWN_ERROR); | 2182 DisableWallet(wallet::WalletClient::UNKNOWN_ERROR); |
2187 SuggestionsUpdated(); | 2183 SuggestionsUpdated(); |
2188 } | 2184 } |
2189 } | 2185 } |
2190 | 2186 |
2191 void AutofillDialogControllerImpl::OnDidGetFullWallet( | 2187 void AutofillDialogControllerImpl::OnDidGetFullWallet( |
2192 scoped_ptr<wallet::FullWallet> full_wallet) { | 2188 scoped_ptr<wallet::FullWallet> full_wallet) { |
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3127 source_url_, | 3123 source_url_, |
3128 wallet_items_->google_transaction_id(), | 3124 wallet_items_->google_transaction_id(), |
3129 capabilities, | 3125 capabilities, |
3130 wallet_items_->HasRequiredAction(wallet::SETUP_WALLET))); | 3126 wallet_items_->HasRequiredAction(wallet::SETUP_WALLET))); |
3131 } | 3127 } |
3132 | 3128 |
3133 void AutofillDialogControllerImpl::HandleSaveOrUpdateRequiredActions( | 3129 void AutofillDialogControllerImpl::HandleSaveOrUpdateRequiredActions( |
3134 const std::vector<wallet::RequiredAction>& required_actions) { | 3130 const std::vector<wallet::RequiredAction>& required_actions) { |
3135 DCHECK(!required_actions.empty()); | 3131 DCHECK(!required_actions.empty()); |
3136 | 3132 |
3137 // TODO(ahutter): Invesitigate if we need to support more generic actions on | 3133 // TODO(ahutter): Investigate if we need to support more generic actions on |
3138 // this call such as GAIA_AUTH. See crbug.com/243457. | 3134 // this call such as GAIA_AUTH. See crbug.com/243457. |
3139 for (std::vector<wallet::RequiredAction>::const_iterator iter = | 3135 for (std::vector<wallet::RequiredAction>::const_iterator iter = |
3140 required_actions.begin(); | 3136 required_actions.begin(); |
3141 iter != required_actions.end(); ++iter) { | 3137 iter != required_actions.end(); ++iter) { |
3142 if (*iter != wallet::INVALID_FORM_FIELD) { | 3138 if (*iter != wallet::INVALID_FORM_FIELD) { |
3143 // TODO(dbeam): handle this more gracefully. | 3139 // TODO(dbeam): handle this more gracefully. |
3144 DisableWallet(wallet::WalletClient::UNKNOWN_ERROR); | 3140 DisableWallet(wallet::WalletClient::UNKNOWN_ERROR); |
3145 } | 3141 } |
3146 } | 3142 } |
3147 SetIsSubmitting(false); | 3143 SetIsSubmitting(false); |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3440 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); | 3436 net::URLRequestContextGetter* request_context = profile_->GetRequestContext(); |
3441 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); | 3437 signin_helper_.reset(new wallet::WalletSigninHelper(this, request_context)); |
3442 signin_helper_->StartWalletCookieValueFetch(); | 3438 signin_helper_->StartWalletCookieValueFetch(); |
3443 | 3439 |
3444 username_fetcher_.reset( | 3440 username_fetcher_.reset( |
3445 new wallet::WalletSigninHelper(this, request_context)); | 3441 new wallet::WalletSigninHelper(this, request_context)); |
3446 username_fetcher_->StartUserNameFetch(); | 3442 username_fetcher_->StartUserNameFetch(); |
3447 } | 3443 } |
3448 | 3444 |
3449 } // namespace autofill | 3445 } // namespace autofill |
OLD | NEW |