Chromium Code Reviews| Index: chrome/browser/autofill/autofill_cc_infobar_delegate.cc |
| diff --git a/chrome/browser/autofill/autofill_cc_infobar_delegate.cc b/chrome/browser/autofill/autofill_cc_infobar_delegate.cc |
| index 8ecc497639d8a2be976ac04cfb950edc6a28b191..f4f972e1727c77524b15c90507a6d5b6833322a0 100644 |
| --- a/chrome/browser/autofill/autofill_cc_infobar_delegate.cc |
| +++ b/chrome/browser/autofill/autofill_cc_infobar_delegate.cc |
| @@ -18,28 +18,32 @@ |
| #include "ui/base/resource/resource_bundle.h" |
| // static |
| -void AutofillCCInfoBarDelegate::Create( |
| - InfoBarService* infobar_service, |
| - const CreditCard* credit_card, |
| - PersonalDataManager* personal_data, |
| - const AutofillMetrics* metric_logger) { |
| +void AutofillCCInfoBarDelegate::Create(InfoBarService* infobar_service, |
| + const AutofillMetrics* metric_logger, |
| + const base::Closure& import_callback) { |
| infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( |
| - new AutofillCCInfoBarDelegate(infobar_service, credit_card, personal_data, |
| - metric_logger))); |
| + new AutofillCCInfoBarDelegate( |
| + infobar_service, metric_logger, import_callback))); |
| + metric_logger->LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN); |
|
Ilya Sherman
2013/03/06 09:13:24
Hmm, why did you move this out of the constructor?
kaiwang
2013/03/06 18:25:04
Creating an infobar delegate does not mean showing
|
| +} |
| + |
| +// static |
| +scoped_ptr<ConfirmInfoBarDelegate> AutofillCCInfoBarDelegate::CreateForTesting( |
| + const AutofillMetrics* metric_logger, |
| + const base::Closure& import_callback) { |
| + metric_logger->LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN); |
| + return scoped_ptr<ConfirmInfoBarDelegate>( |
| + new AutofillCCInfoBarDelegate(NULL, metric_logger, import_callback)); |
| } |
| AutofillCCInfoBarDelegate::AutofillCCInfoBarDelegate( |
| InfoBarService* infobar_service, |
| - const CreditCard* credit_card, |
| - PersonalDataManager* personal_data, |
| - const AutofillMetrics* metric_logger) |
| + const AutofillMetrics* metric_logger, |
| + const base::Closure& import_callback) |
| : ConfirmInfoBarDelegate(infobar_service), |
| - credit_card_(credit_card), |
| - personal_data_(personal_data), |
| metric_logger_(metric_logger), |
| - had_user_interaction_(false) { |
| - metric_logger_->LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN); |
| -} |
| + import_callback_(import_callback), |
| + had_user_interaction_(false) {} |
| AutofillCCInfoBarDelegate::~AutofillCCInfoBarDelegate() { |
| if (!had_user_interaction_) |
| @@ -85,7 +89,8 @@ string16 AutofillCCInfoBarDelegate::GetButtonLabel(InfoBarButton button) const { |
| } |
| bool AutofillCCInfoBarDelegate::Accept() { |
| - personal_data_->SaveImportedCreditCard(*credit_card_); |
| + import_callback_.Run(); |
| + import_callback_.Reset(); |
| LogUserAction(AutofillMetrics::INFOBAR_ACCEPTED); |
| return true; |
| } |