[Password manager] Temporarily add some CHECKs to investigate a crash
[chromium-blink-merge.git] / chrome / browser / ui / autofill / card_unmask_prompt_controller_impl.h
blobb1bee4d392c272573cf473846f90b16a4160e251
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.
5 #ifndef CHROME_BROWSER_UI_AUTOFILL_CARD_UNMASK_PROMPT_CONTROLLER_IMPL_H_
6 #define CHROME_BROWSER_UI_AUTOFILL_CARD_UNMASK_PROMPT_CONTROLLER_IMPL_H_
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"
17 namespace autofill {
19 class CardUnmaskPromptView;
21 class CardUnmaskPromptControllerImpl : public CardUnmaskPromptController {
22 public:
23 typedef base::Callback<void(const base::Callback<void(const std::string&)>&)>
24 RiskDataCallback;
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();
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);
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;
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;
58 protected:
59 // Virtual so tests can suppress it.
60 virtual CardUnmaskPromptView* CreateAndShowView();
61 virtual void LoadRiskFingerprint();
63 // Protected so tests can call it.
64 void OnDidLoadRiskFingerprint(const std::string& risk_data);
66 // Exposed for testing.
67 CardUnmaskPromptView* view() { return card_unmask_view_; }
69 private:
70 bool AllowsRetry(AutofillClient::GetRealPanResult result);
71 void LogOnCloseEvents();
72 AutofillMetrics::UnmaskPromptEvent GetCloseReasonEvent();
74 content::WebContents* web_contents_;
75 RiskDataCallback risk_data_callback_;
76 PrefService* pref_service_;
77 bool is_off_the_record_;
78 CreditCard card_;
79 base::WeakPtr<CardUnmaskDelegate> delegate_;
80 CardUnmaskPromptView* card_unmask_view_;
82 AutofillClient::GetRealPanResult unmasking_result_;
83 bool unmasking_initial_should_store_pan_;
84 int unmasking_number_of_attempts_;
85 base::Time shown_timestamp_;
86 // Timestamp of the last time the user clicked the Verify button.
87 base::Time verify_timestamp_;
89 CardUnmaskDelegate::UnmaskResponse pending_response_;
91 base::WeakPtrFactory<CardUnmaskPromptControllerImpl> weak_pointer_factory_;
93 DISALLOW_COPY_AND_ASSIGN(CardUnmaskPromptControllerImpl);
96 } // namespace autofill
98 #endif // CHROME_BROWSER_UI_AUTOFILL_CARD_UNMASK_PROMPT_CONTROLLER_IMPL_H_