Index: chrome/browser/autofill/autofill_flow_infobar_delegate.cc |
diff --git a/chrome/browser/autofill/autofill_flow_infobar_delegate.cc b/chrome/browser/autofill/autofill_flow_infobar_delegate.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..116f4fbb67a66acfc54268de213fb88484c7a205 |
--- /dev/null |
+++ b/chrome/browser/autofill/autofill_flow_infobar_delegate.cc |
@@ -0,0 +1,126 @@ |
+// 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/autofill_flow_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_flow_util.h" |
+#include "chrome/browser/autofill/autofill_manager.h" |
+#include "chrome/common/form_data.h" |
Ilya Sherman
2013/01/15 06:31:52
nit: Already included in the header file.
Raman Kakilate
2013/01/15 23:02:33
Done.
|
+#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 "googleurl/src/gurl.h" |
Ilya Sherman
2013/01/15 06:31:52
nit: Already included in the header file.
Raman Kakilate
2013/01/15 23:02:33
Done.
|
+#include "grit/generated_resources.h" |
+#include "grit/theme_resources.h" |
+#include "ui/base/l10n/l10n_util.h" |
+#include "ui/base/resource/resource_bundle.h" |
+ |
+// static |
+void AutofillFlowInfoBarDelegate::Create( |
+ InfoBarService* infobar_service, |
+ AutofillManager* autofill_manager, |
+ const AutofillMetrics* metric_logger, |
+ const GURL& source_url, |
+ const content::SSLStatus& ssl_status) { |
+ infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( |
+ new AutofillFlowInfoBarDelegate(infobar_service, autofill_manager, |
+ metric_logger, source_url, ssl_status))); |
+} |
+ |
+AutofillFlowInfoBarDelegate::AutofillFlowInfoBarDelegate( |
+ 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_->LogAutofillFlowInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN); |
+ autofill_flow_form_data_ = autofill::BuildAutofillFlowFormData(); |
Ilya Sherman
2013/01/15 06:31:52
Why cache this, rather than just passing it to Sho
Raman Kakilate
2013/01/15 23:02:33
Done.
|
+} |
+ |
+AutofillFlowInfoBarDelegate::~AutofillFlowInfoBarDelegate() { |
+ if (!had_user_interaction_) |
+ LogUserAction(AutofillMetrics::INFOBAR_IGNORED); |
+} |
+ |
+void AutofillFlowInfoBarDelegate::LogUserAction( |
+ AutofillMetrics::InfoBarMetric user_action) { |
+ DCHECK(!had_user_interaction_); |
+ metric_logger_->LogAutofillFlowInfoBarMetric(user_action); |
+ had_user_interaction_ = true; |
+} |
+ |
+void AutofillFlowInfoBarDelegate::InfoBarDismissed() { |
+ LogUserAction(AutofillMetrics::INFOBAR_DENIED); |
+} |
+ |
+gfx::Image* AutofillFlowInfoBarDelegate::GetIcon() const { |
+ return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
+ IDR_INFOBAR_AUTOFILL); |
+} |
+ |
+InfoBarDelegate::Type AutofillFlowInfoBarDelegate::GetInfoBarType() const { |
+ return PAGE_ACTION_TYPE; |
+} |
+ |
+bool AutofillFlowInfoBarDelegate::ShouldExpireInternal( |
+ 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; |
+} |
+ |
+ |
+string16 AutofillFlowInfoBarDelegate::GetMessageText() const { |
+ return l10n_util::GetStringUTF16(IDS_AUTOFILL_FLOW_INFOBAR_TEXT); |
+} |
+ |
+string16 AutofillFlowInfoBarDelegate::GetButtonLabel( |
+ InfoBarButton button) const { |
+ return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
+ IDS_AUTOFILL_FLOW_INFOBAR_ACCEPT : IDS_AUTOFILL_FLOW_INFOBAR_DENY); |
+} |
+ |
+bool AutofillFlowInfoBarDelegate::Accept() { |
+ LogUserAction(AutofillMetrics::INFOBAR_ACCEPTED); |
+ GURL frame_url; |
+ content::SSLStatus ssl_status; |
Ilya Sherman
2013/01/15 06:31:52
nit: Remove these two locals, as they're not used.
Raman Kakilate
2013/01/15 23:02:33
My bad, Removed.
|
+ |
+ autofill_manager_->ShowAutofillFlowDialog(autofill_flow_form_data_, |
+ source_url_, ssl_status_); |
+ return true; |
+} |
+ |
+bool AutofillFlowInfoBarDelegate::Cancel() { |
+ LogUserAction(AutofillMetrics::INFOBAR_DENIED); |
+ return true; |
+} |
+ |
+string16 AutofillFlowInfoBarDelegate::GetLinkText() const { |
+ return l10n_util::GetStringUTF16(IDS_LEARN_MORE); |
+} |
+ |
+bool AutofillFlowInfoBarDelegate::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; |
+} |
+ |