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

Side by Side Diff: chrome/browser/autofill/autofill_cc_infobar_delegate.cc

Issue 780423002: Don't deref stale AutofillMetrics pointer in AutofillCCInfoBarDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" 5 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/infobars/infobar_service.h" 8 #include "chrome/browser/infobars/infobar_service.h"
9 #include "chrome/grit/generated_resources.h" 9 #include "chrome/grit/generated_resources.h"
10 #include "chrome/grit/google_chrome_strings.h" 10 #include "chrome/grit/google_chrome_strings.h"
(...skipping 18 matching lines...) Expand all
29 infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( 29 infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar(
30 scoped_ptr<ConfirmInfoBarDelegate>(new AutofillCCInfoBarDelegate( 30 scoped_ptr<ConfirmInfoBarDelegate>(new AutofillCCInfoBarDelegate(
31 metric_logger, save_card_callback)))); 31 metric_logger, save_card_callback))));
32 } 32 }
33 33
34 AutofillCCInfoBarDelegate::AutofillCCInfoBarDelegate( 34 AutofillCCInfoBarDelegate::AutofillCCInfoBarDelegate(
35 const AutofillMetrics* metric_logger, 35 const AutofillMetrics* metric_logger,
36 const base::Closure& save_card_callback) 36 const base::Closure& save_card_callback)
37 : ConfirmInfoBarDelegate(), 37 : ConfirmInfoBarDelegate(),
38 metric_logger_(metric_logger), 38 metric_logger_(metric_logger),
39 save_card_callback_(save_card_callback), 39 save_card_callback_(save_card_callback) {
40 had_user_interaction_(false) {
41 metric_logger->LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN); 40 metric_logger->LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN);
42 } 41 }
43 42
44 AutofillCCInfoBarDelegate::~AutofillCCInfoBarDelegate() { 43 AutofillCCInfoBarDelegate::~AutofillCCInfoBarDelegate() {
45 if (!had_user_interaction_)
46 LogUserAction(AutofillMetrics::INFOBAR_IGNORED);
47 } 44 }
48 45
49 void AutofillCCInfoBarDelegate::LogUserAction( 46 void AutofillCCInfoBarDelegate::LogUserAction(
50 AutofillMetrics::InfoBarMetric user_action) { 47 AutofillMetrics::InfoBarMetric user_action) {
51 DCHECK(!had_user_interaction_);
52
53 metric_logger_->LogCreditCardInfoBarMetric(user_action);
Ilya Sherman 2014/12/05 22:58:54 Rather than breaking the metrics, let's just make
Evan Stade 2014/12/05 23:42:47 Done. "Break" is a strong word. I'd instead say "
54 had_user_interaction_ = true;
55 } 48 }
56 49
57 void AutofillCCInfoBarDelegate::InfoBarDismissed() { 50 void AutofillCCInfoBarDelegate::InfoBarDismissed() {
58 LogUserAction(AutofillMetrics::INFOBAR_DENIED); 51 LogUserAction(AutofillMetrics::INFOBAR_DENIED);
59 } 52 }
60 53
61 int AutofillCCInfoBarDelegate::GetIconID() const { 54 int AutofillCCInfoBarDelegate::GetIconID() const {
62 return IDR_INFOBAR_AUTOFILL_CC; 55 return IDR_INFOBAR_AUTOFILL_CC;
63 } 56 }
64 57
(...skipping 15 matching lines...) Expand all
80 } 73 }
81 74
82 base::string16 AutofillCCInfoBarDelegate::GetButtonLabel( 75 base::string16 AutofillCCInfoBarDelegate::GetButtonLabel(
83 InfoBarButton button) const { 76 InfoBarButton button) const {
84 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? 77 return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
85 IDS_AUTOFILL_CC_INFOBAR_ACCEPT : IDS_AUTOFILL_CC_INFOBAR_DENY); 78 IDS_AUTOFILL_CC_INFOBAR_ACCEPT : IDS_AUTOFILL_CC_INFOBAR_DENY);
86 } 79 }
87 80
88 bool AutofillCCInfoBarDelegate::Accept() { 81 bool AutofillCCInfoBarDelegate::Accept() {
89 save_card_callback_.Run(); 82 save_card_callback_.Run();
90 save_card_callback_.Reset(); 83 metric_logger_->LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_ACCEPTED);
91 LogUserAction(AutofillMetrics::INFOBAR_ACCEPTED);
92 return true; 84 return true;
93 } 85 }
94 86
95 bool AutofillCCInfoBarDelegate::Cancel() { 87 bool AutofillCCInfoBarDelegate::Cancel() {
96 LogUserAction(AutofillMetrics::INFOBAR_DENIED); 88 metric_logger_->LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_DENIED);
97 return true; 89 return true;
98 } 90 }
99 91
100 base::string16 AutofillCCInfoBarDelegate::GetLinkText() const { 92 base::string16 AutofillCCInfoBarDelegate::GetLinkText() const {
101 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); 93 return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
102 } 94 }
103 95
104 bool AutofillCCInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { 96 bool AutofillCCInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
105 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL( 97 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL(
106 content::OpenURLParams( 98 content::OpenURLParams(
107 GURL(autofill::kHelpURL), content::Referrer(), 99 GURL(autofill::kHelpURL), content::Referrer(),
108 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, 100 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
109 ui::PAGE_TRANSITION_LINK, false)); 101 ui::PAGE_TRANSITION_LINK, false));
110 return false; 102 return false;
111 } 103 }
112 104
113 } // namespace autofill 105 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_cc_infobar_delegate.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698