| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_CVC_UNMASK_VIEW_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_CVC_UNMASK_VIEW_CONTROLLER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/observer_list.h" |
| 13 #include "base/strings/string16.h" |
| 14 #include "chrome/browser/ui/views/payments/payment_request_sheet_controller.h" |
| 15 #include "components/autofill/core/browser/payments/full_card_request.h" |
| 16 #include "components/autofill/core/browser/payments/payments_client.h" |
| 17 #include "components/autofill/core/browser/risk_data_loader.h" |
| 18 |
| 19 namespace autofill { |
| 20 class AutofillClient; |
| 21 } |
| 22 |
| 23 namespace content { |
| 24 class WebContents; |
| 25 } |
| 26 |
| 27 namespace views { |
| 28 class Textfield; |
| 29 } |
| 30 |
| 31 namespace payments { |
| 32 |
| 33 class PaymentRequestSpec; |
| 34 class PaymentRequestState; |
| 35 class PaymentRequestDialogView; |
| 36 |
| 37 class CvcUnmaskViewController |
| 38 : public PaymentRequestSheetController, |
| 39 public autofill::RiskDataLoader, |
| 40 public autofill::payments::PaymentsClientDelegate, |
| 41 public autofill::payments::FullCardRequest::UIDelegate { |
| 42 public: |
| 43 CvcUnmaskViewController( |
| 44 PaymentRequestSpec* spec, |
| 45 PaymentRequestState* state, |
| 46 PaymentRequestDialogView* dialog, |
| 47 const autofill::CreditCard& credit_card, |
| 48 base::WeakPtr<autofill::payments::FullCardRequest::ResultDelegate> |
| 49 result_delegate, |
| 50 content::WebContents* web_contents); |
| 51 ~CvcUnmaskViewController() override; |
| 52 |
| 53 // autofill::payments::PaymentsClientDelegate: |
| 54 IdentityProvider* GetIdentityProvider() override; |
| 55 void OnDidGetRealPan(autofill::AutofillClient::PaymentsRpcResult result, |
| 56 const std::string& real_pan) override; |
| 57 void OnDidGetUploadDetails( |
| 58 autofill::AutofillClient::PaymentsRpcResult result, |
| 59 const base::string16& context_token, |
| 60 std::unique_ptr<base::DictionaryValue> legal_message) override; |
| 61 void OnDidUploadCard( |
| 62 autofill::AutofillClient::PaymentsRpcResult result) override; |
| 63 |
| 64 // autofill::RiskDataLoader: |
| 65 void LoadRiskData( |
| 66 const base::Callback<void(const std::string&)>& callback) override; |
| 67 |
| 68 // autofill::payments::FullCardRequest::UIDelegate: |
| 69 void ShowUnmaskPrompt( |
| 70 const autofill::CreditCard& card, |
| 71 autofill::AutofillClient::UnmaskCardReason reason, |
| 72 base::WeakPtr<autofill::CardUnmaskDelegate> delegate) override; |
| 73 void OnUnmaskVerificationResult( |
| 74 autofill::AutofillClient::PaymentsRpcResult result) override; |
| 75 |
| 76 protected: |
| 77 // PaymentRequestSheetController: |
| 78 base::string16 GetSheetTitle() override; |
| 79 void FillContentView(views::View* content_view) override; |
| 80 std::unique_ptr<views::Button> CreatePrimaryButton() override; |
| 81 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 82 |
| 83 private: |
| 84 // Called when the user confirms their CVC. This will pass the value to the |
| 85 // active FullCardRequest. |
| 86 void CvcConfirmed(); |
| 87 |
| 88 views::Textfield* cvc_field_; // owned by the view hierarchy, outlives this. |
| 89 autofill::CreditCard credit_card_; |
| 90 content::WebContents* web_contents_; |
| 91 // The identity provider, used for Payments integration. |
| 92 std::unique_ptr<IdentityProvider> identity_provider_; |
| 93 autofill::payments::PaymentsClient payments_client_; |
| 94 autofill::payments::FullCardRequest full_card_request_; |
| 95 base::WeakPtr<autofill::CardUnmaskDelegate> unmask_delegate_; |
| 96 |
| 97 base::WeakPtrFactory<CvcUnmaskViewController> weak_ptr_factory_; |
| 98 |
| 99 DISALLOW_COPY_AND_ASSIGN(CvcUnmaskViewController); |
| 100 }; |
| 101 |
| 102 } // namespace payments |
| 103 |
| 104 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_CVC_UNMASK_VIEW_CONTROLLER_H_ |
| OLD | NEW |