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

Side by Side Diff: chrome/browser/autofill/autofill_flow_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: Addressed review comments. Created 7 years, 11 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/autofill/autofill_flow_infobar_delegate.h"
6
7 #include "base/logging.h"
8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/api/infobars/infobar_service.h"
10 #include "chrome/browser/autofill/autofill_flow_util.h"
11 #include "chrome/browser/autofill/autofill_manager.h"
12 #include "chrome/common/form_data.h"
13 #include "chrome/common/url_constants.h"
14 #include "content/public/browser/page_navigator.h"
15 #include "content/public/browser/web_contents.h"
16 #include "content/public/browser/web_contents_delegate.h"
17 #include "grit/generated_resources.h"
18 #include "grit/theme_resources.h"
19 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/base/resource/resource_bundle.h"
21
22 // static
23 void AutofillFlowInfoBarDelegate::Create(
24 InfoBarService* infobar_service,
25 AutofillManager* autofill_manager,
26 const AutofillMetrics* metric_logger,
27 const GURL& source_url,
28 const content::SSLStatus& ssl_status) {
29 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
30 new AutofillFlowInfoBarDelegate(infobar_service, autofill_manager,
31 metric_logger, source_url, ssl_status)));
32 }
33
34 AutofillFlowInfoBarDelegate::AutofillFlowInfoBarDelegate(
35 InfoBarService* infobar_service,
36 AutofillManager* autofill_manager,
37 const AutofillMetrics* metric_logger,
38 const GURL& source_url,
39 const content::SSLStatus& ssl_status)
40 : ConfirmInfoBarDelegate(infobar_service),
41 metric_logger_(metric_logger),
42 autofill_manager_(autofill_manager),
43 source_url_(source_url),
44 ssl_status_(ssl_status),
45 had_user_interaction_(false) {
46 metric_logger_->LogAutofillFlowInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN);
47 autofill_flow_form_data_ = autofill::BuildAutofillFlowFormData();
48 }
49
50 AutofillFlowInfoBarDelegate::~AutofillFlowInfoBarDelegate() {
51 if (!had_user_interaction_)
52 LogUserAction(AutofillMetrics::INFOBAR_IGNORED);
53 }
54
55 void AutofillFlowInfoBarDelegate::LogUserAction(
56 AutofillMetrics::InfoBarMetric user_action) {
57 DCHECK(!had_user_interaction_);
58 metric_logger_->LogAutofillFlowInfoBarMetric(user_action);
59 had_user_interaction_ = true;
60 }
61
62 void AutofillFlowInfoBarDelegate::InfoBarDismissed() {
63 LogUserAction(AutofillMetrics::INFOBAR_DENIED);
64 }
65
66 gfx::Image* AutofillFlowInfoBarDelegate::GetIcon() const {
67 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
68 IDR_INFOBAR_AUTOFILL);
69 }
70
71 InfoBarDelegate::Type AutofillFlowInfoBarDelegate::GetInfoBarType() const {
72 return PAGE_ACTION_TYPE;
73 }
74
75 bool AutofillFlowInfoBarDelegate::ShouldExpireInternal(
76 const content::LoadCommittedDetails& details) const {
77 // The user has submitted a form, causing the page to navigate elsewhere. We
78 // want the infobar to be expired at this point, because the user has
79 // potentially started the checkout flow manually.
80 return true;
81 }
82
83
84 string16 AutofillFlowInfoBarDelegate::GetMessageText() const {
85 return l10n_util::GetStringUTF16(IDS_AUTOFILL_FLOW_INFOBAR_TEXT);
86 }
87
88 string16 AutofillFlowInfoBarDelegate::GetButtonLabel(
89 InfoBarButton button) const {
90 return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
91 IDS_AUTOFILL_FLOW_INFOBAR_ACCEPT : IDS_AUTOFILL_FLOW_INFOBAR_DENY);
92 }
93
94 bool AutofillFlowInfoBarDelegate::Accept() {
95 LogUserAction(AutofillMetrics::INFOBAR_ACCEPTED);
96 GURL frame_url;
97 content::SSLStatus ssl_status;
98
99 autofill_manager_->ShowAutofillFlowDialog(autofill_flow_form_data_,
100 source_url_, ssl_status_);
101 return true;
102 }
103
104 bool AutofillFlowInfoBarDelegate::Cancel() {
105 LogUserAction(AutofillMetrics::INFOBAR_DENIED);
106 return true;
107 }
108
109 string16 AutofillFlowInfoBarDelegate::GetLinkText() const {
110 return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
111 }
112
113 bool AutofillFlowInfoBarDelegate::LinkClicked(
114 WindowOpenDisposition disposition) {
115 // TODO(ramankk): Fix the help URL when we have one.
116 owner()->GetWebContents()->GetDelegate()->OpenURLFromTab(
117 owner()->GetWebContents(),
118 content::OpenURLParams(GURL(chrome::kAutofillHelpURL),
119 content::Referrer(),
120 NEW_FOREGROUND_TAB,
121 content::PAGE_TRANSITION_LINK,
122 false));
123 return false;
124 }
125
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698