Chromium Code Reviews| 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 COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_CC_INFOBAR_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_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 "components/autofill/core/browser/autofill_metrics.h" | 13 #include "components/autofill/core/browser/autofill_metrics.h" |
| 14 #include "components/infobars/core/confirm_infobar_delegate.h" | 14 #include "components/infobars/core/confirm_infobar_delegate.h" |
| 15 #include "ui/base/window_open_disposition.h" | 15 #include "ui/base/window_open_disposition.h" |
| 16 | 16 |
| 17 class CreditCard; | 17 namespace infobars { |
| 18 class PersonalDataManager; | 18 class InfoBarManager; |
| 19 class InfoBarService; | 19 } |
| 20 | 20 |
| 21 namespace autofill { | 21 namespace autofill { |
| 22 | 22 |
| 23 class AutofillManager; | |
| 24 class AutofillDriver; | |
| 25 | |
| 23 // 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 |
| 24 // card information gathered from a form submission. | 27 // card information gathered from a form submission. |
| 25 class AutofillCCInfoBarDelegate : public ConfirmInfoBarDelegate { | 28 class AutofillCCInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 26 public: | 29 public: |
| 27 // 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 |
| 28 // to |infobar_service|. | 31 // to |infobar_manager|. |
| 29 static void Create(InfoBarService* infobar_service, | 32 static void Create(infobars::InfoBarManager* infobar_manager, |
| 33 AutofillManager* autofill_manager, | |
| 30 const AutofillMetrics* metric_logger, | 34 const AutofillMetrics* metric_logger, |
| 31 const base::Closure& save_card_callback); | 35 const base::Closure& save_card_callback); |
| 32 | 36 |
| 33 #if defined(UNIT_TEST) | 37 #if defined(UNIT_TEST) |
| 34 static scoped_ptr<ConfirmInfoBarDelegate> Create( | 38 static scoped_ptr<ConfirmInfoBarDelegate> Create( |
| 39 AutofillDriver* autofill_driver, | |
| 35 const AutofillMetrics* metric_logger, | 40 const AutofillMetrics* metric_logger, |
| 36 const base::Closure& save_card_callback) { | 41 const base::Closure& save_card_callback) { |
| 37 return scoped_ptr<ConfirmInfoBarDelegate>( | 42 return scoped_ptr<ConfirmInfoBarDelegate>(new AutofillCCInfoBarDelegate( |
| 38 new AutofillCCInfoBarDelegate(metric_logger, save_card_callback)); | 43 autofill_driver, metric_logger, save_card_callback)); |
| 39 } | 44 } |
| 40 #endif | 45 #endif |
| 41 | 46 |
| 42 private: | 47 private: |
| 43 AutofillCCInfoBarDelegate(const AutofillMetrics* metric_logger, | 48 AutofillCCInfoBarDelegate(AutofillDriver* autofill_driver, |
| 49 const AutofillMetrics* metric_logger, | |
| 44 const base::Closure& save_card_callback); | 50 const base::Closure& save_card_callback); |
| 45 ~AutofillCCInfoBarDelegate() override; | 51 ~AutofillCCInfoBarDelegate() override; |
| 46 | 52 |
| 47 void LogUserAction(AutofillMetrics::InfoBarMetric user_action); | 53 void LogUserAction(AutofillMetrics::InfoBarMetric user_action); |
| 48 | 54 |
| 49 // ConfirmInfoBarDelegate: | 55 // ConfirmInfoBarDelegate: |
| 50 void InfoBarDismissed() override; | 56 void InfoBarDismissed() override; |
| 51 int GetIconID() const override; | 57 int GetIconID() const override; |
| 52 Type GetInfoBarType() const override; | 58 Type GetInfoBarType() const override; |
| 53 bool ShouldExpireInternal(const NavigationDetails& details) const override; | 59 bool ShouldExpireInternal(const NavigationDetails& details) const override; |
| 54 base::string16 GetMessageText() const override; | 60 base::string16 GetMessageText() const override; |
| 55 base::string16 GetButtonLabel(InfoBarButton button) const override; | 61 base::string16 GetButtonLabel(InfoBarButton button) const override; |
| 56 bool Accept() override; | 62 bool Accept() override; |
| 57 bool Cancel() override; | 63 bool Cancel() override; |
| 58 base::string16 GetLinkText() const override; | 64 base::string16 GetLinkText() const override; |
| 59 bool LinkClicked(WindowOpenDisposition disposition) override; | 65 bool LinkClicked(WindowOpenDisposition disposition) override; |
| 60 | 66 |
| 67 // Performs navigations to handle any link clicks. | |
| 68 AutofillDriver* autofill_driver_; | |
|
Ilya Sherman
2014/12/03 20:00:21
Please document lifetime expectations. Are you co
Pritam Nikam
2014/12/04 15:37:30
Done.
| |
| 69 | |
| 61 // For logging UMA metrics. | 70 // For logging UMA metrics. |
| 62 // Weak reference. Owned by the AutofillManager that initiated this infobar. | 71 // Weak reference. Owned by the AutofillManager that initiated this infobar. |
| 63 const AutofillMetrics* metric_logger_; | 72 const AutofillMetrics* metric_logger_; |
| 64 | 73 |
| 65 // The callback to save credit card if the user accepts the infobar. | 74 // The callback to save credit card if the user accepts the infobar. |
| 66 base::Closure save_card_callback_; | 75 base::Closure save_card_callback_; |
| 67 | 76 |
| 68 // Did the user ever explicitly accept or dismiss this infobar? | 77 // Did the user ever explicitly accept or dismiss this infobar? |
| 69 bool had_user_interaction_; | 78 bool had_user_interaction_; |
| 70 | 79 |
| 71 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, CreditCardInfoBar); | 80 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, CreditCardInfoBar); |
| 72 | 81 |
| 73 DISALLOW_COPY_AND_ASSIGN(AutofillCCInfoBarDelegate); | 82 DISALLOW_COPY_AND_ASSIGN(AutofillCCInfoBarDelegate); |
| 74 }; | 83 }; |
| 75 | 84 |
| 76 } // namespace autofill | 85 } // namespace autofill |
| 77 | 86 |
| 78 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_ | 87 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_CC_INFOBAR_DELEGATE_H_ |
| OLD | NEW |