OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/card_unmask_prompt_controller_impl.h" | 5 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 if (card_unmask_view_) | 37 if (card_unmask_view_) |
38 card_unmask_view_->ControllerGone(); | 38 card_unmask_view_->ControllerGone(); |
39 | 39 |
40 pending_response_ = CardUnmaskDelegate::UnmaskResponse(); | 40 pending_response_ = CardUnmaskDelegate::UnmaskResponse(); |
41 LoadRiskFingerprint(); | 41 LoadRiskFingerprint(); |
42 card_ = card; | 42 card_ = card; |
43 delegate_ = delegate; | 43 delegate_ = delegate; |
44 card_unmask_view_ = CardUnmaskPromptView::CreateAndShow(this); | 44 card_unmask_view_ = CardUnmaskPromptView::CreateAndShow(this); |
45 } | 45 } |
46 | 46 |
47 void CardUnmaskPromptControllerImpl::OnVerificationResult(bool success) { | 47 void CardUnmaskPromptControllerImpl::OnVerificationResult( |
48 if (card_unmask_view_) | 48 AutofillClient::GetRealPanResult result) { |
49 card_unmask_view_->GotVerificationResult(success); | 49 if (!card_unmask_view_) |
| 50 return; |
| 51 |
| 52 base::string16 error_message; |
| 53 bool allow_retry = true; |
| 54 switch (result) { |
| 55 case AutofillClient::SUCCESS: |
| 56 break; |
| 57 |
| 58 case AutofillClient::TRY_AGAIN_FAILURE: { |
| 59 error_message = l10n_util::GetStringUTF16( |
| 60 IDS_AUTOFILL_CARD_UNMASK_PROMPT_ERROR_TRY_AGAIN); |
| 61 break; |
| 62 } |
| 63 |
| 64 case AutofillClient::PERMANENT_FAILURE: { |
| 65 error_message = l10n_util::GetStringUTF16( |
| 66 IDS_AUTOFILL_CARD_UNMASK_PROMPT_ERROR_PERMANENT); |
| 67 allow_retry = false; |
| 68 break; |
| 69 } |
| 70 |
| 71 case AutofillClient::NETWORK_ERROR: { |
| 72 error_message = l10n_util::GetStringUTF16( |
| 73 IDS_AUTOFILL_CARD_UNMASK_PROMPT_ERROR_NETWORK); |
| 74 allow_retry = false; |
| 75 break; |
| 76 } |
| 77 } |
| 78 |
| 79 card_unmask_view_->GotVerificationResult(error_message, allow_retry); |
50 } | 80 } |
51 | 81 |
52 void CardUnmaskPromptControllerImpl::OnUnmaskDialogClosed() { | 82 void CardUnmaskPromptControllerImpl::OnUnmaskDialogClosed() { |
53 card_unmask_view_ = nullptr; | 83 card_unmask_view_ = nullptr; |
54 delegate_->OnUnmaskPromptClosed(); | 84 delegate_->OnUnmaskPromptClosed(); |
55 } | 85 } |
56 | 86 |
57 void CardUnmaskPromptControllerImpl::OnUnmaskResponse( | 87 void CardUnmaskPromptControllerImpl::OnUnmaskResponse( |
58 const base::string16& cvc, | 88 const base::string16& cvc, |
59 const base::string16& exp_month, | 89 const base::string16& exp_month, |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 166 } |
137 | 167 |
138 void CardUnmaskPromptControllerImpl::OnDidLoadRiskFingerprint( | 168 void CardUnmaskPromptControllerImpl::OnDidLoadRiskFingerprint( |
139 const std::string& risk_data) { | 169 const std::string& risk_data) { |
140 pending_response_.risk_data = risk_data; | 170 pending_response_.risk_data = risk_data; |
141 if (!pending_response_.cvc.empty()) | 171 if (!pending_response_.cvc.empty()) |
142 delegate_->OnUnmaskResponse(pending_response_); | 172 delegate_->OnUnmaskResponse(pending_response_); |
143 } | 173 } |
144 | 174 |
145 } // namespace autofill | 175 } // namespace autofill |
OLD | NEW |