Roll src/third_party/WebKit 8b42d1d:744641d (svn 186770:186771)
[chromium-blink-merge.git] / chrome / browser / autofill / autofill_cc_infobar_delegate.h
blob717cd900f5b8f054431e7d15c75e535b5d64b55b
1 // Copyright (c) 2011 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_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_
6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_
8 #include "base/basictypes.h"
9 #include "base/callback.h"
10 #include "base/gtest_prod_util.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string16.h"
13 #include "components/autofill/core/browser/autofill_metrics.h"
14 #include "components/infobars/core/confirm_infobar_delegate.h"
15 #include "ui/base/window_open_disposition.h"
17 class CreditCard;
18 class PersonalDataManager;
19 class InfoBarService;
21 namespace autofill {
23 // An InfoBar delegate that enables the user to allow or deny storing credit
24 // card information gathered from a form submission.
25 class AutofillCCInfoBarDelegate : public ConfirmInfoBarDelegate {
26 public:
27 // Creates an autofill credit card infobar and delegate and adds the infobar
28 // to |infobar_service|.
29 static void Create(InfoBarService* infobar_service,
30 const base::Closure& save_card_callback);
32 #if defined(UNIT_TEST)
33 static scoped_ptr<ConfirmInfoBarDelegate> Create(
34 const base::Closure& save_card_callback) {
35 return scoped_ptr<ConfirmInfoBarDelegate>(
36 new AutofillCCInfoBarDelegate(save_card_callback));
38 #endif
40 private:
41 explicit AutofillCCInfoBarDelegate(const base::Closure& save_card_callback);
42 ~AutofillCCInfoBarDelegate() override;
44 void LogUserAction(AutofillMetrics::InfoBarMetric user_action);
46 // ConfirmInfoBarDelegate:
47 void InfoBarDismissed() override;
48 int GetIconID() const override;
49 Type GetInfoBarType() const override;
50 bool ShouldExpireInternal(const NavigationDetails& details) const override;
51 base::string16 GetMessageText() const override;
52 base::string16 GetButtonLabel(InfoBarButton button) const override;
53 bool Accept() override;
54 bool Cancel() override;
55 base::string16 GetLinkText() const override;
56 bool LinkClicked(WindowOpenDisposition disposition) override;
58 // The callback to save credit card if the user accepts the infobar.
59 base::Closure save_card_callback_;
61 // Did the user ever explicitly accept or dismiss this infobar?
62 bool had_user_interaction_;
64 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, CreditCardInfoBar);
66 DISALLOW_COPY_AND_ASSIGN(AutofillCCInfoBarDelegate);
69 } // namespace autofill
71 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_