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

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

Issue 11539003: Pop up requestAutocomplete UI when autofill server hints chrome client that it is in a multipage au… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: address initial comments Created 8 years 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/wallet_infobar_delegate.cc
diff --git a/chrome/browser/autofill/wallet_infobar_delegate.cc b/chrome/browser/autofill/wallet_infobar_delegate.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ed2ab1a4a7ab56ce48bb0513af8706fe8b0f41a9
--- /dev/null
+++ b/chrome/browser/autofill/wallet_infobar_delegate.cc
@@ -0,0 +1,140 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/autofill/wallet_infobar_delegate.h"
+
+#include "base/logging.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/api/infobars/infobar_service.h"
+#include "chrome/browser/autofill/autofill_manager.h"
+#include "chrome/browser/autofill/personal_data_manager.h"
+#include "chrome/common/form_data.h"
+#include "chrome/common/url_constants.h"
+#include "content/public/browser/page_navigator.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_contents_delegate.h"
+#include "grit/generated_resources.h"
+#include "grit/theme_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/resource/resource_bundle.h"
+
+
+FormFieldData BuildField(const std::string& autocomplete_attribute) {
+ FormFieldData field;
+ field.name = string16();
+ field.value = string16();
+ field.autocomplete_attribute = autocomplete_attribute;
+ field.form_control_type = "text";
+ return field;
+}
+
+FormData BuildWalletFormData() {
ahutter 2012/12/17 17:35:39 Should probably be static.
Raman Kakilate 2013/01/10 00:54:40 These are utility functions outside any object's s
+ FormData formdata;
+ formdata.fields.push_back(BuildField("name"));
+ formdata.fields.push_back(BuildField("email"));
+ formdata.fields.push_back(BuildField("cc-name"));
+ formdata.fields.push_back(BuildField("cc-number"));
+ formdata.fields.push_back(BuildField("cc-exp"));
+ formdata.fields.push_back(BuildField("cc-csc"));
+ formdata.fields.push_back(BuildField("billing address-line1"));
ahutter 2012/12/17 17:35:39 Where's address line 2?
Raman Kakilate 2013/01/10 00:54:40 changed to street-address.
ahutter 2013/01/10 15:58:54 Not sure if it matters but Sugar expects address l
Albert Bodenhamer 2013/01/10 17:54:27 Autofill also handles Address line 1 and line 2 as
+ formdata.fields.push_back(BuildField("billing locality"));
+ formdata.fields.push_back(BuildField("billing region"));
+ formdata.fields.push_back(BuildField("billing country"));
+ formdata.fields.push_back(BuildField("billing postal-code"));
+ formdata.fields.push_back(BuildField("shipping address-line1"));
+ formdata.fields.push_back(BuildField("shipping locality"));
+ formdata.fields.push_back(BuildField("shipping region"));
+ formdata.fields.push_back(BuildField("shipping country"));
+ formdata.fields.push_back(BuildField("shipping postal-code"));
+ return formdata;
+}
+
+WalletInfoBarDelegate::WalletInfoBarDelegate(
+ InfoBarService* infobar_service,
+ AutofillManager* autofill_manager,
+ const AutofillMetrics* metric_logger,
+ const GURL& source_url,
+ const content::SSLStatus& ssl_status)
+ : ConfirmInfoBarDelegate(infobar_service),
+ metric_logger_(metric_logger),
+ autofill_manager_(autofill_manager),
+ source_url_(source_url),
+ ssl_status_(ssl_status),
+ had_user_interaction_(false) {
+ metric_logger_->LogWalletInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN);
+}
+
+WalletInfoBarDelegate::~WalletInfoBarDelegate() {
+ if (!had_user_interaction_)
+ LogUserAction(AutofillMetrics::INFOBAR_IGNORED);
+}
+
+void WalletInfoBarDelegate::LogUserAction(
+ AutofillMetrics::InfoBarMetric user_action) {
+ DCHECK(!had_user_interaction_);
+ metric_logger_->LogWalletInfoBarMetric(user_action);
+ had_user_interaction_ = true;
+}
+
+bool WalletInfoBarDelegate::ShouldExpire(
+ const content::LoadCommittedDetails& details) const {
+ // The user has submitted a form, causing the page to navigate elsewhere. We
+ // want the infobar to be expired at this point, because the user has
+ // potentially started the checkout flow manually.
+ return true;
+}
+
+void WalletInfoBarDelegate::InfoBarDismissed() {
+ LogUserAction(AutofillMetrics::INFOBAR_DENIED);
+}
+
+gfx::Image* WalletInfoBarDelegate::GetIcon() const {
+ return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
+ IDR_INFOBAR_AUTOFILL);
+}
+
+InfoBarDelegate::Type WalletInfoBarDelegate::GetInfoBarType() const {
+ return PAGE_ACTION_TYPE;
+}
+
+string16 WalletInfoBarDelegate::GetMessageText() const {
+ return l10n_util::GetStringUTF16(IDS_WALLET_AUTOFILL_INFOBAR_TEXT);
+}
+
+string16 WalletInfoBarDelegate::GetButtonLabel(InfoBarButton button) const {
+ return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
+ IDS_WALLET_AUTOFILL_INFOBAR_ACCEPT : IDS_WALLET_AUTOFILL_INFOBAR_DENY);
+}
+
+bool WalletInfoBarDelegate::Accept() {
+ LogUserAction(AutofillMetrics::INFOBAR_ACCEPTED);
+ GURL frame_url;
+ content::SSLStatus ssl_status;
+
+ autofill_manager_->ShowWalletDialog(BuildWalletFormData(),
+ source_url_, ssl_status_);
+ return true;
+}
+
+bool WalletInfoBarDelegate::Cancel() {
+ LogUserAction(AutofillMetrics::INFOBAR_DENIED);
+ return true;
+}
+
+string16 WalletInfoBarDelegate::GetLinkText() const {
+ return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
+}
+
+bool WalletInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
+ // TODO(ramankk): Fix the help URL when we have one.
+ owner()->GetWebContents()->GetDelegate()->OpenURLFromTab(
+ owner()->GetWebContents(),
+ content::OpenURLParams(GURL(chrome::kAutofillHelpURL),
+ content::Referrer(),
+ NEW_FOREGROUND_TAB,
+ content::PAGE_TRANSITION_LINK,
+ false));
+ return false;
+}
+

Powered by Google App Engine
This is Rietveld 408576698