| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_CARD_UNMASK_PROMPT_CONTROLLER_IMPL_H_ | |
| 6 #define CHROME_BROWSER_UI_AUTOFILL_CARD_UNMASK_PROMPT_CONTROLLER_IMPL_H_ | |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller.h" | |
| 12 #include "components/autofill/core/browser/autofill_client.h" | |
| 13 #include "components/autofill/core/browser/autofill_metrics.h" | |
| 14 #include "components/autofill/core/browser/card_unmask_delegate.h" | |
| 15 #include "components/autofill/core/browser/credit_card.h" | |
| 16 | |
| 17 namespace autofill { | |
| 18 | |
| 19 class CardUnmaskPromptView; | |
| 20 | |
| 21 class CardUnmaskPromptControllerImpl : public CardUnmaskPromptController { | |
| 22 public: | |
| 23 typedef base::Callback<void(const base::Callback<void(const std::string&)>&)> | |
| 24 RiskDataCallback; | |
| 25 | |
| 26 CardUnmaskPromptControllerImpl( | |
| 27 content::WebContents* web_contents, | |
| 28 const RiskDataCallback& risk_data_callback, | |
| 29 PrefService* pref_service, | |
| 30 bool is_off_the_record); | |
| 31 virtual ~CardUnmaskPromptControllerImpl(); | |
| 32 | |
| 33 // Functions called by ChromeAutofillClient. | |
| 34 void ShowPrompt(const CreditCard& card, | |
| 35 base::WeakPtr<CardUnmaskDelegate> delegate); | |
| 36 // The CVC the user entered went through validation. | |
| 37 void OnVerificationResult(AutofillClient::GetRealPanResult result); | |
| 38 | |
| 39 // CardUnmaskPromptController implementation. | |
| 40 void OnUnmaskDialogClosed() override; | |
| 41 void OnUnmaskResponse(const base::string16& cvc, | |
| 42 const base::string16& exp_month, | |
| 43 const base::string16& exp_year, | |
| 44 bool should_store_pan) override; | |
| 45 void NewCardLinkClicked() override; | |
| 46 content::WebContents* GetWebContents() override; | |
| 47 base::string16 GetWindowTitle() const override; | |
| 48 base::string16 GetInstructionsMessage() const override; | |
| 49 int GetCvcImageRid() const override; | |
| 50 bool ShouldRequestExpirationDate() const override; | |
| 51 bool CanStoreLocally() const override; | |
| 52 bool GetStoreLocallyStartState() const override; | |
| 53 bool InputCvcIsValid(const base::string16& input_text) const override; | |
| 54 bool InputExpirationIsValid(const base::string16& month, | |
| 55 const base::string16& year) const override; | |
| 56 base::TimeDelta GetSuccessMessageDuration() const override; | |
| 57 | |
| 58 protected: | |
| 59 // Virtual so tests can suppress it. | |
| 60 virtual CardUnmaskPromptView* CreateAndShowView(); | |
| 61 virtual void LoadRiskFingerprint(); | |
| 62 | |
| 63 // Protected so tests can call it. | |
| 64 void OnDidLoadRiskFingerprint(const std::string& risk_data); | |
| 65 | |
| 66 // Exposed for testing. | |
| 67 CardUnmaskPromptView* view() { return card_unmask_view_; } | |
| 68 | |
| 69 private: | |
| 70 bool AllowsRetry(AutofillClient::GetRealPanResult result); | |
| 71 void LogOnCloseEvents(); | |
| 72 AutofillMetrics::UnmaskPromptEvent GetCloseReasonEvent(); | |
| 73 | |
| 74 content::WebContents* web_contents_; | |
| 75 RiskDataCallback risk_data_callback_; | |
| 76 PrefService* pref_service_; | |
| 77 bool new_card_link_clicked_; | |
| 78 bool is_off_the_record_; | |
| 79 CreditCard card_; | |
| 80 base::WeakPtr<CardUnmaskDelegate> delegate_; | |
| 81 CardUnmaskPromptView* card_unmask_view_; | |
| 82 | |
| 83 AutofillClient::GetRealPanResult unmasking_result_; | |
| 84 bool unmasking_initial_should_store_pan_; | |
| 85 int unmasking_number_of_attempts_; | |
| 86 base::Time shown_timestamp_; | |
| 87 // Timestamp of the last time the user clicked the Verify button. | |
| 88 base::Time verify_timestamp_; | |
| 89 | |
| 90 CardUnmaskDelegate::UnmaskResponse pending_response_; | |
| 91 | |
| 92 base::WeakPtrFactory<CardUnmaskPromptControllerImpl> weak_pointer_factory_; | |
| 93 | |
| 94 DISALLOW_COPY_AND_ASSIGN(CardUnmaskPromptControllerImpl); | |
| 95 }; | |
| 96 | |
| 97 } // namespace autofill | |
| 98 | |
| 99 #endif // CHROME_BROWSER_UI_AUTOFILL_CARD_UNMASK_PROMPT_CONTROLLER_IMPL_H_ | |
| OLD | NEW |