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