Update mojo surfaces bindings and mojo/cc/ glue
[chromium-blink-merge.git] / chrome / browser / autofill / autofill_cc_infobar_delegate.h
blob58d9a34b17c7912f72919ec214d9e967a7e7dc6b
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;
20 namespace autofill {
22 // An InfoBar delegate that enables the user to allow or deny storing credit
23 // card information gathered from a form submission.
24 class AutofillCCInfoBarDelegate : public ConfirmInfoBarDelegate {
25 public:
26 // Creates an autofill credit card infobar and delegate and adds the infobar
27 // to |infobar_service|.
28 static void Create(InfoBarService* infobar_service,
29 const AutofillMetrics* metric_logger,
30 const base::Closure& save_card_callback);
32 #if defined(UNIT_TEST)
33 static scoped_ptr<ConfirmInfoBarDelegate> Create(
34 const AutofillMetrics* metric_logger,
35 const base::Closure& save_card_callback) {
36 return scoped_ptr<ConfirmInfoBarDelegate>(
37 new AutofillCCInfoBarDelegate(metric_logger, save_card_callback));
39 #endif
41 private:
42 AutofillCCInfoBarDelegate(const AutofillMetrics* metric_logger,
43 const base::Closure& save_card_callback);
44 virtual ~AutofillCCInfoBarDelegate();
46 void LogUserAction(AutofillMetrics::InfoBarMetric user_action);
48 // ConfirmInfoBarDelegate:
49 virtual void InfoBarDismissed() OVERRIDE;
50 virtual int GetIconID() const OVERRIDE;
51 virtual Type GetInfoBarType() const OVERRIDE;
52 virtual bool ShouldExpireInternal(
53 const NavigationDetails& details) const OVERRIDE;
54 virtual base::string16 GetMessageText() const OVERRIDE;
55 virtual base::string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
56 virtual bool Accept() OVERRIDE;
57 virtual bool Cancel() OVERRIDE;
58 virtual base::string16 GetLinkText() const OVERRIDE;
59 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE;
61 // For logging UMA metrics.
62 // Weak reference. Owned by the AutofillManager that initiated this infobar.
63 const AutofillMetrics* metric_logger_;
65 // The callback to save credit card if the user accepts the infobar.
66 base::Closure save_card_callback_;
68 // Did the user ever explicitly accept or dismiss this infobar?
69 bool had_user_interaction_;
71 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, CreditCardInfoBar);
73 DISALLOW_COPY_AND_ASSIGN(AutofillCCInfoBarDelegate);
76 } // namespace autofill
78 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_