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

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: Updated string. Pop the UI only on first page of the flow. 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..c4da34a8ac241311eaeeded4b02e971b418c55c4
--- /dev/null
+++ b/chrome/browser/autofill/wallet_infobar_delegate.cc
@@ -0,0 +1,142 @@
+// 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(std::string autocomplete_attribute) {
Ilya Sherman 2012/12/13 02:29:23 nit: Pass by const reference
Raman Kakilate 2012/12/13 21:34:34 Done.
+ FormFieldData field;
+ field.name = string16();
+ field.value = string16();
+ field.autocomplete_attribute = autocomplete_attribute;
+ field.form_control_type = "text";
+ return field;
+}
+
+FormData BuildWalletFormData() {
+ 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"));
Ilya Sherman 2012/12/13 23:23:18 This should be street-address; or else you should
+ 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;
+}
Ilya Sherman 2012/12/13 02:29:23 These functions have nothing to do with the infoba
Raman Kakilate 2012/12/13 21:34:34 Given that this infobar will be close to wallet, I
Ilya Sherman 2012/12/13 23:23:18 I am strongly inclined for the code not to live in
+
+WalletInfoBarDelegate::WalletInfoBarDelegate(
+ InfoBarService* infobar_service,
+ PersonalDataManager* personal_data,
+ AutofillManager* autofill_mgr,
+ const AutofillMetrics* metric_logger,
+ const GURL& source_url,
+ const content::SSLStatus& ssl_status)
+ : ConfirmInfoBarDelegate(infobar_service),
+ personal_data_(personal_data),
+ metric_logger_(metric_logger),
+ autofill_mgr_(autofill_mgr),
+ 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_mgr_->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