Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / autofill / card_unmask_prompt_controller_impl.h
blob623b53ad677b8457ba0681f48bb4d852c1334297
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/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h"
10 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller.h"
11 #include "components/autofill/core/browser/autofill_client.h"
12 #include "components/autofill/core/browser/autofill_metrics.h"
13 #include "components/autofill/core/browser/card_unmask_delegate.h"
14 #include "components/autofill/core/browser/credit_card.h"
16 namespace autofill {
18 class CardUnmaskPromptView;
20 class CardUnmaskPromptControllerImpl : public CardUnmaskPromptController {
21 public:
22 explicit CardUnmaskPromptControllerImpl(content::WebContents* web_contents);
23 virtual ~CardUnmaskPromptControllerImpl();
25 // Functions called by ChromeAutofillClient.
26 void ShowPrompt(const CreditCard& card,
27 base::WeakPtr<CardUnmaskDelegate> delegate);
28 // The CVC the user entered went through validation.
29 void OnVerificationResult(AutofillClient::GetRealPanResult result);
31 // CardUnmaskPromptController implementation.
32 void OnUnmaskDialogClosed() override;
33 void OnUnmaskResponse(const base::string16& cvc,
34 const base::string16& exp_month,
35 const base::string16& exp_year,
36 bool should_store_pan) override;
38 content::WebContents* GetWebContents() override;
39 base::string16 GetWindowTitle() const override;
40 base::string16 GetInstructionsMessage() const override;
41 int GetCvcImageRid() const override;
42 bool ShouldRequestExpirationDate() const override;
43 bool CanStoreLocally() const override;
44 bool GetStoreLocallyStartState() const override;
45 bool InputCvcIsValid(const base::string16& input_text) const override;
46 bool InputExpirationIsValid(const base::string16& month,
47 const base::string16& year) const override;
48 base::TimeDelta GetSuccessMessageDuration() const override;
50 protected:
51 // Virtual so tests can suppress it.
52 virtual CardUnmaskPromptView* CreateAndShowView();
53 virtual void LoadRiskFingerprint();
55 // Protected so tests can call it.
56 void OnDidLoadRiskFingerprint(const std::string& risk_data);
58 // Exposed for testing.
59 CardUnmaskPromptView* view() { return card_unmask_view_; }
61 private:
62 bool AllowsRetry(AutofillClient::GetRealPanResult result);
63 void LogOnCloseEvents();
64 AutofillMetrics::UnmaskPromptEvent GetCloseReasonEvent();
66 content::WebContents* web_contents_;
67 CreditCard card_;
68 base::WeakPtr<CardUnmaskDelegate> delegate_;
69 CardUnmaskPromptView* card_unmask_view_;
71 AutofillClient::GetRealPanResult unmasking_result_;
72 bool unmasking_initial_should_store_pan_;
73 int unmasking_number_of_attempts_;
74 base::Time shown_timestamp_;
75 // Timestamp of the last time the user clicked the Verify button.
76 base::Time verify_timestamp_;
78 CardUnmaskDelegate::UnmaskResponse pending_response_;
80 base::WeakPtrFactory<CardUnmaskPromptControllerImpl> weak_pointer_factory_;
82 DISALLOW_COPY_AND_ASSIGN(CardUnmaskPromptControllerImpl);
85 } // namespace autofill
87 #endif // CHROME_BROWSER_UI_AUTOFILL_CARD_UNMASK_PROMPT_CONTROLLER_IMPL_H_