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

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

Powered by Google App Engine
This is Rietveld 408576698