OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_ |
6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_ | 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" | 12 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" |
13 #include "chrome/browser/autofill/autofill_metrics.h" | 13 #include "chrome/browser/autofill/autofill_metrics.h" |
14 #include "webkit/glue/window_open_disposition.h" | 14 #include "webkit/glue/window_open_disposition.h" |
15 | 15 |
16 class CreditCard; | 16 class CreditCard; |
17 class PersonalDataManager; | 17 class PersonalDataManager; |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 struct LoadCommittedDetails; | 20 struct LoadCommittedDetails; |
21 } | 21 } |
22 | 22 |
23 // An InfoBar delegate that enables the user to allow or deny storing credit | 23 // An InfoBar delegate that enables the user to allow or deny storing credit |
24 // card information gathered from a form submission. | 24 // card information gathered from a form submission. |
25 class AutofillCCInfoBarDelegate : public ConfirmInfoBarDelegate { | 25 class AutofillCCInfoBarDelegate : public ConfirmInfoBarDelegate { |
26 public: | 26 public: |
| 27 // Creates an autofill credit card delegate and adds it to |infobar_service|. |
| 28 static void Create(InfoBarService* infobar_service, |
| 29 const CreditCard* credit_card, |
| 30 PersonalDataManager* personal_data, |
| 31 const AutofillMetrics* metric_logger); |
| 32 |
| 33 #if defined(UNIT_TEST) |
| 34 static scoped_ptr<ConfirmInfoBarDelegate> Create( |
| 35 const CreditCard* credit_card, |
| 36 PersonalDataManager* personal_data, |
| 37 const AutofillMetrics* metric_logger) { |
| 38 return scoped_ptr<ConfirmInfoBarDelegate>(new AutofillCCInfoBarDelegate( |
| 39 NULL, credit_card, personal_data, metric_logger)); |
| 40 } |
| 41 #endif |
| 42 |
| 43 private: |
27 AutofillCCInfoBarDelegate(InfoBarService* infobar_service, | 44 AutofillCCInfoBarDelegate(InfoBarService* infobar_service, |
28 const CreditCard* credit_card, | 45 const CreditCard* credit_card, |
29 PersonalDataManager* personal_data, | 46 PersonalDataManager* personal_data, |
30 const AutofillMetrics* metric_logger); | 47 const AutofillMetrics* metric_logger); |
31 | |
32 private: | |
33 virtual ~AutofillCCInfoBarDelegate(); | 48 virtual ~AutofillCCInfoBarDelegate(); |
34 | 49 |
35 void LogUserAction(AutofillMetrics::InfoBarMetric user_action); | 50 void LogUserAction(AutofillMetrics::InfoBarMetric user_action); |
36 | 51 |
37 // ConfirmInfoBarDelegate: | 52 // ConfirmInfoBarDelegate: |
38 virtual void InfoBarDismissed() OVERRIDE; | 53 virtual void InfoBarDismissed() OVERRIDE; |
39 virtual gfx::Image* GetIcon() const OVERRIDE; | 54 virtual gfx::Image* GetIcon() const OVERRIDE; |
40 virtual Type GetInfoBarType() const OVERRIDE; | 55 virtual Type GetInfoBarType() const OVERRIDE; |
41 virtual bool ShouldExpireInternal( | 56 virtual bool ShouldExpireInternal( |
42 const content::LoadCommittedDetails& details) const OVERRIDE; | 57 const content::LoadCommittedDetails& details) const OVERRIDE; |
(...skipping 17 matching lines...) Expand all Loading... |
60 | 75 |
61 // Did the user ever explicitly accept or dismiss this infobar? | 76 // Did the user ever explicitly accept or dismiss this infobar? |
62 bool had_user_interaction_; | 77 bool had_user_interaction_; |
63 | 78 |
64 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, CreditCardInfoBar); | 79 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, CreditCardInfoBar); |
65 | 80 |
66 DISALLOW_COPY_AND_ASSIGN(AutofillCCInfoBarDelegate); | 81 DISALLOW_COPY_AND_ASSIGN(AutofillCCInfoBarDelegate); |
67 }; | 82 }; |
68 | 83 |
69 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_ | 84 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_ |
OLD | NEW |