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/callback.h" | 9 #include "base/callback.h" |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
13 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 13 #include "chrome/browser/infobars/content_confirm_infobar_delegate.h" |
14 #include "components/autofill/core/browser/autofill_metrics.h" | 14 #include "components/autofill/core/browser/autofill_metrics.h" |
15 #include "ui/base/window_open_disposition.h" | 15 #include "ui/base/window_open_disposition.h" |
16 | 16 |
17 class CreditCard; | 17 class CreditCard; |
18 class PersonalDataManager; | 18 class PersonalDataManager; |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 struct LoadCommittedDetails; | 21 struct LoadCommittedDetails; |
22 } | 22 } |
23 | 23 |
24 namespace autofill { | 24 namespace autofill { |
25 | 25 |
26 // An InfoBar delegate that enables the user to allow or deny storing credit | 26 // An InfoBar delegate that enables the user to allow or deny storing credit |
27 // card information gathered from a form submission. | 27 // card information gathered from a form submission. |
28 class AutofillCCInfoBarDelegate : public ConfirmInfoBarDelegate { | 28 class AutofillCCInfoBarDelegate : public ContentConfirmInfoBarDelegate { |
29 public: | 29 public: |
30 // Creates an autofill credit card infobar and delegate and adds the infobar | 30 // Creates an autofill credit card infobar and delegate and adds the infobar |
31 // to |infobar_service|. | 31 // to |infobar_service|. |
32 static void Create(InfoBarService* infobar_service, | 32 static void Create(InfoBarService* infobar_service, |
33 const AutofillMetrics* metric_logger, | 33 const AutofillMetrics* metric_logger, |
34 const base::Closure& save_card_callback); | 34 const base::Closure& save_card_callback); |
35 | 35 |
36 #if defined(UNIT_TEST) | 36 #if defined(UNIT_TEST) |
37 static scoped_ptr<ConfirmInfoBarDelegate> Create( | 37 static scoped_ptr<ConfirmInfoBarDelegate> Create( |
| 38 content::WebContents* web_contents, |
38 const AutofillMetrics* metric_logger, | 39 const AutofillMetrics* metric_logger, |
39 const base::Closure& save_card_callback) { | 40 const base::Closure& save_card_callback) { |
40 return scoped_ptr<ConfirmInfoBarDelegate>( | 41 return scoped_ptr<ConfirmInfoBarDelegate>(new AutofillCCInfoBarDelegate( |
41 new AutofillCCInfoBarDelegate(metric_logger, save_card_callback)); | 42 web_contents, metric_logger, save_card_callback)); |
42 } | 43 } |
43 #endif | 44 #endif |
44 | 45 |
45 private: | 46 private: |
46 AutofillCCInfoBarDelegate(const AutofillMetrics* metric_logger, | 47 AutofillCCInfoBarDelegate(content::WebContents* web_contents, |
| 48 const AutofillMetrics* metric_logger, |
47 const base::Closure& save_card_callback); | 49 const base::Closure& save_card_callback); |
48 virtual ~AutofillCCInfoBarDelegate(); | 50 virtual ~AutofillCCInfoBarDelegate(); |
49 | 51 |
50 void LogUserAction(AutofillMetrics::InfoBarMetric user_action); | 52 void LogUserAction(AutofillMetrics::InfoBarMetric user_action); |
51 | 53 |
52 // ConfirmInfoBarDelegate: | 54 // ConfirmInfoBarDelegate: |
53 virtual void InfoBarDismissed() OVERRIDE; | 55 virtual void InfoBarDismissed() OVERRIDE; |
54 virtual int GetIconID() const OVERRIDE; | 56 virtual int GetIconID() const OVERRIDE; |
55 virtual Type GetInfoBarType() const OVERRIDE; | 57 virtual Type GetInfoBarType() const OVERRIDE; |
56 virtual bool ShouldExpireInternal( | 58 virtual bool ShouldExpireInternal(const NavigationDetails& details) const |
57 const content::LoadCommittedDetails& details) const OVERRIDE; | 59 OVERRIDE; |
58 virtual base::string16 GetMessageText() const OVERRIDE; | 60 virtual base::string16 GetMessageText() const OVERRIDE; |
59 virtual base::string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 61 virtual base::string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
60 virtual bool Accept() OVERRIDE; | 62 virtual bool Accept() OVERRIDE; |
61 virtual bool Cancel() OVERRIDE; | 63 virtual bool Cancel() OVERRIDE; |
62 virtual base::string16 GetLinkText() const OVERRIDE; | 64 virtual base::string16 GetLinkText() const OVERRIDE; |
63 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; | 65 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; |
64 | 66 |
65 // For logging UMA metrics. | 67 // For logging UMA metrics. |
66 // Weak reference. Owned by the AutofillManager that initiated this infobar. | 68 // Weak reference. Owned by the AutofillManager that initiated this infobar. |
67 const AutofillMetrics* metric_logger_; | 69 const AutofillMetrics* metric_logger_; |
68 | 70 |
69 // The callback to save credit card if the user accepts the infobar. | 71 // The callback to save credit card if the user accepts the infobar. |
70 base::Closure save_card_callback_; | 72 base::Closure save_card_callback_; |
71 | 73 |
72 // Did the user ever explicitly accept or dismiss this infobar? | 74 // Did the user ever explicitly accept or dismiss this infobar? |
73 bool had_user_interaction_; | 75 bool had_user_interaction_; |
74 | 76 |
75 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, CreditCardInfoBar); | 77 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, CreditCardInfoBar); |
76 | 78 |
77 DISALLOW_COPY_AND_ASSIGN(AutofillCCInfoBarDelegate); | 79 DISALLOW_COPY_AND_ASSIGN(AutofillCCInfoBarDelegate); |
78 }; | 80 }; |
79 | 81 |
80 } // namespace autofill | 82 } // namespace autofill |
81 | 83 |
82 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_ | 84 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_ |
OLD | NEW |