Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Unified Diff: chrome/browser/autofill/autofill_cc_infobar_delegate.cc

Issue 12378055: Make autofill stop depending on InfoBarService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..dde5990cdddc183c75012031b2d544077c71a9a4 100644
--- a/chrome/browser/autofill/autofill_cc_infobar_delegate.cc
+++ b/chrome/browser/autofill/autofill_cc_infobar_delegate.cc
@@ -6,8 +6,7 @@
#include "base/logging.h"
#include "chrome/browser/api/infobars/infobar_service.h"
-#include "chrome/browser/autofill/credit_card.h"
-#include "chrome/browser/autofill/personal_data_manager.h"
+#include "chrome/browser/autofill/autofill_cc_import_confirmation_delegate.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/page_navigator.h"
#include "content/public/browser/web_contents.h"
@@ -17,45 +16,41 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
+using autofill::AutofillCCImportConfirmationDelegate;
+
+class InfoBarDelegate;
+
// static
void AutofillCCInfoBarDelegate::Create(
InfoBarService* infobar_service,
- const CreditCard* credit_card,
- PersonalDataManager* personal_data,
- const AutofillMetrics* metric_logger) {
- infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
- new AutofillCCInfoBarDelegate(infobar_service, credit_card, personal_data,
- metric_logger)));
+ scoped_ptr<AutofillCCImportConfirmationDelegate> delegate) {
+ AutofillCCImportConfirmationDelegate* confirmation_delegate = delegate.get();
+
+ InfoBarDelegate* infobar_delegate = infobar_service->AddInfoBar(
+ scoped_ptr<InfoBarDelegate>(
+ new AutofillCCInfoBarDelegate(infobar_service, delegate.Pass())));
+ if (infobar_delegate)
+ confirmation_delegate->DidShow();
+}
+
+// static
+scoped_ptr<ConfirmInfoBarDelegate> AutofillCCInfoBarDelegate::Create(
+ scoped_ptr<AutofillCCImportConfirmationDelegate> delegate) {
+ delegate->DidShow();
+ return scoped_ptr<ConfirmInfoBarDelegate>(
+ new AutofillCCInfoBarDelegate(NULL, delegate.Pass()));
}
AutofillCCInfoBarDelegate::AutofillCCInfoBarDelegate(
InfoBarService* infobar_service,
- const CreditCard* credit_card,
- PersonalDataManager* personal_data,
- const AutofillMetrics* metric_logger)
+ scoped_ptr<autofill::AutofillCCImportConfirmationDelegate> delegate)
: 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);
-}
-
-AutofillCCInfoBarDelegate::~AutofillCCInfoBarDelegate() {
- if (!had_user_interaction_)
- LogUserAction(AutofillMetrics::INFOBAR_IGNORED);
-}
+ delegate_(delegate.Pass()) {}
-void AutofillCCInfoBarDelegate::LogUserAction(
- AutofillMetrics::InfoBarMetric user_action) {
- DCHECK(!had_user_interaction_);
-
- metric_logger_->LogCreditCardInfoBarMetric(user_action);
- had_user_interaction_ = true;
-}
+AutofillCCInfoBarDelegate::~AutofillCCInfoBarDelegate() {}
void AutofillCCInfoBarDelegate::InfoBarDismissed() {
- LogUserAction(AutofillMetrics::INFOBAR_DENIED);
+ delegate_->DidDismiss();
}
gfx::Image* AutofillCCInfoBarDelegate::GetIcon() const {
@@ -85,13 +80,12 @@ string16 AutofillCCInfoBarDelegate::GetButtonLabel(InfoBarButton button) const {
}
bool AutofillCCInfoBarDelegate::Accept() {
- personal_data_->SaveImportedCreditCard(*credit_card_);
- LogUserAction(AutofillMetrics::INFOBAR_ACCEPTED);
+ delegate_->DidAccept();
return true;
}
bool AutofillCCInfoBarDelegate::Cancel() {
- LogUserAction(AutofillMetrics::INFOBAR_DENIED);
+ delegate_->DidCancel();
return true;
}

Powered by Google App Engine
This is Rietveld 408576698