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/string16.h"
13 #include "chrome/browser/infobars/confirm_infobar_delegate.h"
14 #include "components/autofill/browser/autofill_metrics.h"
15 #include "ui/base/window_open_disposition.h"
18 class PersonalDataManager
;
21 struct LoadCommittedDetails
;
26 // An InfoBar delegate that enables the user to allow or deny storing credit
27 // card information gathered from a form submission.
28 class AutofillCCInfoBarDelegate
: public ConfirmInfoBarDelegate
{
30 // Creates an AutofillCCInfoBarDelegate and adds it to |infobar_service|.
31 static void Create(InfoBarService
* infobar_service
,
32 const AutofillMetrics
* metric_logger
,
33 const base::Closure
& save_card_callback
);
35 static scoped_ptr
<ConfirmInfoBarDelegate
> CreateForTesting(
36 const AutofillMetrics
* metric_logger
,
37 const base::Closure
& save_card_callback
);
40 AutofillCCInfoBarDelegate(InfoBarService
* infobar_service
,
41 const AutofillMetrics
* metric_logger
,
42 const base::Closure
& save_card_callback
);
43 virtual ~AutofillCCInfoBarDelegate();
45 void LogUserAction(AutofillMetrics::InfoBarMetric user_action
);
47 // ConfirmInfoBarDelegate:
48 virtual void InfoBarDismissed() OVERRIDE
;
49 virtual gfx::Image
* GetIcon() const OVERRIDE
;
50 virtual Type
GetInfoBarType() const OVERRIDE
;
51 virtual bool ShouldExpireInternal(
52 const content::LoadCommittedDetails
& details
) const OVERRIDE
;
53 virtual string16
GetMessageText() const OVERRIDE
;
54 virtual string16
GetButtonLabel(InfoBarButton button
) const OVERRIDE
;
55 virtual bool Accept() OVERRIDE
;
56 virtual bool Cancel() OVERRIDE
;
57 virtual string16
GetLinkText() const OVERRIDE
;
58 virtual bool LinkClicked(WindowOpenDisposition disposition
) OVERRIDE
;
60 // For logging UMA metrics.
61 // Weak reference. Owned by the AutofillManager that initiated this infobar.
62 const AutofillMetrics
* metric_logger_
;
64 // The callback to save credit card if the user accepts the infobar.
65 base::Closure save_card_callback_
;
67 // Did the user ever explicitly accept or dismiss this infobar?
68 bool had_user_interaction_
;
70 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest
, CreditCardInfoBar
);
72 DISALLOW_COPY_AND_ASSIGN(AutofillCCInfoBarDelegate
);
75 } // namespace autofill
77 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_