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

Side by Side Diff: chrome/browser/autofill/autocheckout_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: More comments addressed. 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) 2013 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/autocheckout_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/autocheckout_manager.h"
11 #include "chrome/browser/autofill/autofill_manager.h"
12 #include "chrome/common/url_constants.h"
13 #include "content/public/browser/page_navigator.h"
14 #include "content/public/browser/web_contents.h"
15 #include "content/public/browser/web_contents_delegate.h"
16 #include "grit/generated_resources.h"
17 #include "grit/theme_resources.h"
18 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/base/resource/resource_bundle.h"
20
21 // static
22 void AutocheckoutInfoBarDelegate::Create(
23 const AutofillMetrics* metric_logger,
24 const GURL& source_url,
25 const content::SSLStatus& ssl_status,
26 AutofillManager* autofill_manager,
27 InfoBarService* infobar_service) {
28 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
29 new AutocheckoutInfoBarDelegate(metric_logger, source_url, ssl_status,
30 autofill_manager, infobar_service)));
31 }
32
33 AutocheckoutInfoBarDelegate::AutocheckoutInfoBarDelegate(
34 const AutofillMetrics* metric_logger,
35 const GURL& source_url,
36 const content::SSLStatus& ssl_status,
37 AutofillManager* autofill_manager,
38 InfoBarService* infobar_service)
39 : ConfirmInfoBarDelegate(infobar_service),
40 metric_logger_(metric_logger),
41 autofill_manager_(autofill_manager),
42 source_url_(source_url),
43 ssl_status_(ssl_status),
44 had_user_interaction_(false) {
45 metric_logger_->LogAutocheckoutInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN);
46 }
47
48 AutocheckoutInfoBarDelegate::~AutocheckoutInfoBarDelegate() {
49 if (!had_user_interaction_)
50 LogUserAction(AutofillMetrics::INFOBAR_IGNORED);
51 }
52
53 void AutocheckoutInfoBarDelegate::LogUserAction(
54 AutofillMetrics::InfoBarMetric user_action) {
55 DCHECK(!had_user_interaction_);
56 metric_logger_->LogAutocheckoutInfoBarMetric(user_action);
57 had_user_interaction_ = true;
58 }
59
60 void AutocheckoutInfoBarDelegate::InfoBarDismissed() {
61 LogUserAction(AutofillMetrics::INFOBAR_DENIED);
62 }
63
64 gfx::Image* AutocheckoutInfoBarDelegate::GetIcon() const {
65 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
66 IDR_INFOBAR_AUTOFILL);
67 }
68
69 InfoBarDelegate::Type AutocheckoutInfoBarDelegate::GetInfoBarType() const {
70 return PAGE_ACTION_TYPE;
71 }
72
73 bool AutocheckoutInfoBarDelegate::ShouldExpireInternal(
74 const content::LoadCommittedDetails& details) const {
75 // The user has submitted a form, causing the page to navigate elsewhere. We
76 // want the infobar to be expired at this point, because the user has
77 // potentially started the checkout flow manually.
78 return true;
79 }
80
81
82 string16 AutocheckoutInfoBarDelegate::GetMessageText() const {
83 return l10n_util::GetStringUTF16(IDS_AUTOFILL_FLOW_INFOBAR_TEXT);
84 }
85
86 string16 AutocheckoutInfoBarDelegate::GetButtonLabel(
87 InfoBarButton button) const {
88 return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
89 IDS_AUTOFILL_FLOW_INFOBAR_ACCEPT : IDS_AUTOFILL_FLOW_INFOBAR_DENY);
90 }
91
92 bool AutocheckoutInfoBarDelegate::Accept() {
93 LogUserAction(AutofillMetrics::INFOBAR_ACCEPTED);
94 autofill_manager_->ShowAutocheckoutDialog(source_url_, ssl_status_);
95 return true;
96 }
97
98 bool AutocheckoutInfoBarDelegate::Cancel() {
99 LogUserAction(AutofillMetrics::INFOBAR_DENIED);
100 return true;
101 }
102
103 string16 AutocheckoutInfoBarDelegate::GetLinkText() const {
104 return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
105 }
106
107 bool AutocheckoutInfoBarDelegate::LinkClicked(
108 WindowOpenDisposition disposition) {
109 // TODO(ramankk): Fix the help URL when we have one.
110 owner()->GetWebContents()->GetDelegate()->OpenURLFromTab(
111 owner()->GetWebContents(),
112 content::OpenURLParams(GURL(chrome::kAutofillHelpURL),
113 content::Referrer(),
114 NEW_FOREGROUND_TAB,
115 content::PAGE_TRANSITION_LINK,
116 false));
117 return false;
118 }
119
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698