| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/views/payments/cvc_unmask_view_controller.h" | 5 #include "chrome/browser/ui/views/payments/cvc_unmask_view_controller.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/autofill/risk_util.h" | 8 #include "chrome/browser/autofill/risk_util.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 10 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 void CvcUnmaskViewController::ShowUnmaskPrompt( | 103 void CvcUnmaskViewController::ShowUnmaskPrompt( |
| 104 const autofill::CreditCard& card, | 104 const autofill::CreditCard& card, |
| 105 autofill::AutofillClient::UnmaskCardReason reason, | 105 autofill::AutofillClient::UnmaskCardReason reason, |
| 106 base::WeakPtr<autofill::CardUnmaskDelegate> delegate) { | 106 base::WeakPtr<autofill::CardUnmaskDelegate> delegate) { |
| 107 unmask_delegate_ = delegate; | 107 unmask_delegate_ = delegate; |
| 108 } | 108 } |
| 109 | 109 |
| 110 void CvcUnmaskViewController::OnUnmaskVerificationResult( | 110 void CvcUnmaskViewController::OnUnmaskVerificationResult( |
| 111 autofill::AutofillClient::PaymentsRpcResult result) { | 111 autofill::AutofillClient::PaymentsRpcResult result) { |
| 112 // TODO(anthonyvd): Show result. | 112 // TODO(crbug.com/716020): Handle FullCardRequest errors with more |
| 113 // granularity and display an error in the UI. |
| 113 } | 114 } |
| 114 | 115 |
| 115 base::string16 CvcUnmaskViewController::GetSheetTitle() { | 116 base::string16 CvcUnmaskViewController::GetSheetTitle() { |
| 116 return l10n_util::GetStringFUTF16(IDS_AUTOFILL_CARD_UNMASK_PROMPT_TITLE, | 117 return l10n_util::GetStringFUTF16(IDS_AUTOFILL_CARD_UNMASK_PROMPT_TITLE, |
| 117 credit_card_.TypeAndLastFourDigits()); | 118 credit_card_.TypeAndLastFourDigits()); |
| 118 } | 119 } |
| 119 | 120 |
| 120 void CvcUnmaskViewController::FillContentView(views::View* content_view) { | 121 void CvcUnmaskViewController::FillContentView(views::View* content_view) { |
| 121 std::unique_ptr<views::GridLayout> layout = | 122 std::unique_ptr<views::GridLayout> layout = |
| 122 base::MakeUnique<views::GridLayout>(content_view); | 123 base::MakeUnique<views::GridLayout>(content_view); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 button->set_tag(static_cast<int>(Tags::CONFIRM_TAG)); | 177 button->set_tag(static_cast<int>(Tags::CONFIRM_TAG)); |
| 177 return button; | 178 return button; |
| 178 } | 179 } |
| 179 | 180 |
| 180 void CvcUnmaskViewController::ButtonPressed(views::Button* sender, | 181 void CvcUnmaskViewController::ButtonPressed(views::Button* sender, |
| 181 const ui::Event& event) { | 182 const ui::Event& event) { |
| 182 switch (sender->tag()) { | 183 switch (sender->tag()) { |
| 183 case static_cast<int>(Tags::CONFIRM_TAG): | 184 case static_cast<int>(Tags::CONFIRM_TAG): |
| 184 CvcConfirmed(); | 185 CvcConfirmed(); |
| 185 break; | 186 break; |
| 187 case static_cast<int>(PaymentRequestCommonTags::BACK_BUTTON_TAG): |
| 188 unmask_delegate_->OnUnmaskPromptClosed(); |
| 189 dialog()->GoBack(); |
| 190 break; |
| 186 default: | 191 default: |
| 187 PaymentRequestSheetController::ButtonPressed(sender, event); | 192 PaymentRequestSheetController::ButtonPressed(sender, event); |
| 188 } | 193 } |
| 189 } | 194 } |
| 190 | 195 |
| 191 void CvcUnmaskViewController::CvcConfirmed() { | 196 void CvcUnmaskViewController::CvcConfirmed() { |
| 192 const base::string16& cvc = cvc_field_->text(); | 197 const base::string16& cvc = cvc_field_->text(); |
| 193 if (unmask_delegate_) { | 198 if (unmask_delegate_) { |
| 194 autofill::CardUnmaskDelegate::UnmaskResponse response; | 199 autofill::CardUnmaskDelegate::UnmaskResponse response; |
| 195 response.cvc = cvc; | 200 response.cvc = cvc; |
| 196 unmask_delegate_->OnUnmaskResponse(response); | 201 unmask_delegate_->OnUnmaskResponse(response); |
| 197 } | 202 } |
| 198 | 203 |
| 199 dialog()->ShowProcessingSpinner(); | 204 dialog()->ShowProcessingSpinner(); |
| 200 } | 205 } |
| 201 | 206 |
| 202 } // namespace payments | 207 } // namespace payments |
| OLD | NEW |