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

Side by Side Diff: chrome/browser/ui/autofill/card_unmask_prompt_controller_impl.cc

Issue 949323002: Collecting UMA metrics for the UnmaskPrompt. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 5 years, 9 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ui/autofill/card_unmask_prompt_controller_impl.h" 5 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/autofill/risk_util.h" 12 #include "chrome/browser/autofill/risk_util.h"
13 #include "chrome/browser/ui/autofill/card_unmask_prompt_view.h" 13 #include "chrome/browser/ui/autofill/card_unmask_prompt_view.h"
14 #include "chrome/grit/generated_resources.h" 14 #include "chrome/grit/generated_resources.h"
15 #include "components/autofill/core/browser/autofill_metrics.h"
15 #include "components/autofill/core/common/autofill_pref_names.h" 16 #include "components/autofill/core/common/autofill_pref_names.h"
16 #include "components/user_prefs/user_prefs.h" 17 #include "components/user_prefs/user_prefs.h"
17 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
18 #include "grit/theme_resources.h" 19 #include "grit/theme_resources.h"
19 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
20 21
21 namespace autofill { 22 namespace autofill {
22 23
23 CardUnmaskPromptControllerImpl::CardUnmaskPromptControllerImpl( 24 CardUnmaskPromptControllerImpl::CardUnmaskPromptControllerImpl(
24 content::WebContents* web_contents) 25 content::WebContents* web_contents)
25 : web_contents_(web_contents), 26 : web_contents_(web_contents),
26 card_unmask_view_(nullptr), 27 card_unmask_view_(nullptr),
28 unmasking_success_(false),
29 unmasking_initial_should_store_pan_(false),
30 unmasking_number_of_attempts_(0),
31 unmasking_allow_retry_(true),
27 weak_pointer_factory_(this) { 32 weak_pointer_factory_(this) {
28 } 33 }
29 34
30 CardUnmaskPromptControllerImpl::~CardUnmaskPromptControllerImpl() { 35 CardUnmaskPromptControllerImpl::~CardUnmaskPromptControllerImpl() {
31 if (card_unmask_view_) 36 if (card_unmask_view_)
32 card_unmask_view_->ControllerGone(); 37 card_unmask_view_->ControllerGone();
33 } 38 }
34 39
40 CardUnmaskPromptView* CardUnmaskPromptControllerImpl::CreateAndShowView() {
41 return CardUnmaskPromptView::CreateAndShow(this);
42 }
43
35 void CardUnmaskPromptControllerImpl::ShowPrompt( 44 void CardUnmaskPromptControllerImpl::ShowPrompt(
36 const CreditCard& card, 45 const CreditCard& card,
37 base::WeakPtr<CardUnmaskDelegate> delegate) { 46 base::WeakPtr<CardUnmaskDelegate> delegate) {
38 if (card_unmask_view_) 47 if (card_unmask_view_)
39 card_unmask_view_->ControllerGone(); 48 card_unmask_view_->ControllerGone();
40 49
41 pending_response_ = CardUnmaskDelegate::UnmaskResponse(); 50 pending_response_ = CardUnmaskDelegate::UnmaskResponse();
42 LoadRiskFingerprint(); 51 LoadRiskFingerprint();
43 card_ = card; 52 card_ = card;
44 delegate_ = delegate; 53 delegate_ = delegate;
45 card_unmask_view_ = CardUnmaskPromptView::CreateAndShow(this); 54 card_unmask_view_ = CreateAndShowView();
55 unmasking_success_ = false;
56 unmasking_number_of_attempts_ = 0;
57 unmasking_initial_should_store_pan_ = GetStoreLocallyStartState();
58 unmasking_allow_retry_ = true;
59 AutofillMetrics::LogUnmaskPromptEvent(AutofillMetrics::UNMASK_PROMPT_SHOWN);
46 } 60 }
47 61
48 void CardUnmaskPromptControllerImpl::OnVerificationResult( 62 void CardUnmaskPromptControllerImpl::OnVerificationResult(
49 AutofillClient::GetRealPanResult result) { 63 AutofillClient::GetRealPanResult result) {
50 if (!card_unmask_view_) 64 if (!card_unmask_view_)
51 return; 65 return;
52 66
53 base::string16 error_message; 67 base::string16 error_message;
54 bool allow_retry = true; 68 bool allow_retry = true;
55 switch (result) { 69 switch (result) {
56 case AutofillClient::SUCCESS: 70 case AutofillClient::SUCCESS: {
71 unmasking_success_ = true;
72 AutofillMetrics::LogUnmaskPromptEvent(
73 unmasking_number_of_attempts_ == 1
74 ? AutofillMetrics::UNMASK_PROMPT_UNMASKED_CARD_FIRST_ATTEMPT
75 : AutofillMetrics::UNMASK_PROMPT_UNMASKED_CARD_AFTER_FAILED_ATTEMPTS);
76 bool final_should_store_pan =
77 user_prefs::UserPrefs::Get(web_contents_->GetBrowserContext())
78 ->GetBoolean(prefs::kAutofillWalletImportStorageCheckboxState);
79 if (final_should_store_pan) {
80 AutofillMetrics::LogUnmaskPromptEvent(
81 AutofillMetrics::UNMASK_PROMPT_SAVED_CARD_LOCALLY);
82 }
57 break; 83 break;
84 }
58 85
59 case AutofillClient::TRY_AGAIN_FAILURE: { 86 case AutofillClient::TRY_AGAIN_FAILURE: {
60 error_message = l10n_util::GetStringUTF16( 87 error_message = l10n_util::GetStringUTF16(
61 IDS_AUTOFILL_CARD_UNMASK_PROMPT_ERROR_TRY_AGAIN); 88 IDS_AUTOFILL_CARD_UNMASK_PROMPT_ERROR_TRY_AGAIN);
62 break; 89 break;
63 } 90 }
64 91
65 case AutofillClient::PERMANENT_FAILURE: { 92 case AutofillClient::PERMANENT_FAILURE: {
66 error_message = l10n_util::GetStringUTF16( 93 error_message = l10n_util::GetStringUTF16(
67 IDS_AUTOFILL_CARD_UNMASK_PROMPT_ERROR_PERMANENT); 94 IDS_AUTOFILL_CARD_UNMASK_PROMPT_ERROR_PERMANENT);
68 allow_retry = false; 95 allow_retry = false;
69 break; 96 break;
70 } 97 }
71 98
72 case AutofillClient::NETWORK_ERROR: { 99 case AutofillClient::NETWORK_ERROR: {
73 error_message = l10n_util::GetStringUTF16( 100 error_message = l10n_util::GetStringUTF16(
74 IDS_AUTOFILL_CARD_UNMASK_PROMPT_ERROR_NETWORK); 101 IDS_AUTOFILL_CARD_UNMASK_PROMPT_ERROR_NETWORK);
75 allow_retry = false; 102 allow_retry = false;
76 break; 103 break;
77 } 104 }
78 } 105 }
79 106
107 unmasking_allow_retry_ = allow_retry;
80 card_unmask_view_->GotVerificationResult(error_message, allow_retry); 108 card_unmask_view_->GotVerificationResult(error_message, allow_retry);
81 } 109 }
82 110
83 void CardUnmaskPromptControllerImpl::OnUnmaskDialogClosed() { 111 void CardUnmaskPromptControllerImpl::OnUnmaskDialogClosed() {
84 card_unmask_view_ = nullptr; 112 card_unmask_view_ = nullptr;
113 if (!unmasking_success_) {
114 AutofillMetrics::UnmaskPromptEvent event;
115 if (unmasking_number_of_attempts_ == 0) {
116 event = AutofillMetrics::UNMASK_PROMPT_CLOSED_NO_ATTEMPTS;
117 } else if (unmasking_allow_retry_) {
118 event = AutofillMetrics
119 ::UNMASK_PROMPT_CLOSED_FAILED_TO_UNMASK_RETRIABLE_FAILURE;
Evan Stade 2015/03/18 21:29:07 on further reflection, we should perhaps log exact
Walter Cacau 2015/03/18 23:50:05 Done.
120 } else {
121 event = AutofillMetrics
122 ::UNMASK_PROMPT_CLOSED_FAILED_TO_UNMASK_NON_RETRIABLE_FAILURE;
123 }
124 AutofillMetrics::LogUnmaskPromptEvent(event);
125 }
126 if (unmasking_number_of_attempts_ > 0) {
127 bool final_should_store_pan =
128 user_prefs::UserPrefs::Get(web_contents_->GetBrowserContext())
129 ->GetBoolean(prefs::kAutofillWalletImportStorageCheckboxState);
130 AutofillMetrics::UnmaskPromptEvent event;
131 if (unmasking_initial_should_store_pan_ && final_should_store_pan) {
132 event = AutofillMetrics::UNMASK_PROMPT_LOCAL_SAVE_DID_NOT_OPT_OUT;
133 } else if (!unmasking_initial_should_store_pan_
134 && !final_should_store_pan) {
135 event = AutofillMetrics::UNMASK_PROMPT_LOCAL_SAVE_DID_NOT_OPT_IN;
136 } else if (unmasking_initial_should_store_pan_ && !final_should_store_pan) {
137 event = AutofillMetrics::UNMASK_PROMPT_LOCAL_SAVE_DID_OPT_OUT;
138 } else {
139 event = AutofillMetrics::UNMASK_PROMPT_LOCAL_SAVE_DID_OPT_IN;
140 }
141 AutofillMetrics::LogUnmaskPromptEvent(event);
142 }
85 delegate_->OnUnmaskPromptClosed(); 143 delegate_->OnUnmaskPromptClosed();
86 } 144 }
87 145
88 void CardUnmaskPromptControllerImpl::OnUnmaskResponse( 146 void CardUnmaskPromptControllerImpl::OnUnmaskResponse(
89 const base::string16& cvc, 147 const base::string16& cvc,
90 const base::string16& exp_month, 148 const base::string16& exp_month,
91 const base::string16& exp_year, 149 const base::string16& exp_year,
92 bool should_store_pan) { 150 bool should_store_pan) {
151 unmasking_number_of_attempts_++;
93 card_unmask_view_->DisableAndWaitForVerification(); 152 card_unmask_view_->DisableAndWaitForVerification();
94 153
95 DCHECK(!cvc.empty()); 154 DCHECK(!cvc.empty());
96 pending_response_.cvc = cvc; 155 pending_response_.cvc = cvc;
97 if (ShouldRequestExpirationDate()) { 156 if (ShouldRequestExpirationDate()) {
98 pending_response_.exp_month = exp_month; 157 pending_response_.exp_month = exp_month;
99 pending_response_.exp_year = exp_year; 158 pending_response_.exp_year = exp_year;
100 } 159 }
101 pending_response_.should_store_pan = should_store_pan; 160 pending_response_.should_store_pan = should_store_pan;
102 // Remember the last choice the user made (on this device). 161 // Remember the last choice the user made (on this device).
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 259 }
201 260
202 void CardUnmaskPromptControllerImpl::OnDidLoadRiskFingerprint( 261 void CardUnmaskPromptControllerImpl::OnDidLoadRiskFingerprint(
203 const std::string& risk_data) { 262 const std::string& risk_data) {
204 pending_response_.risk_data = risk_data; 263 pending_response_.risk_data = risk_data;
205 if (!pending_response_.cvc.empty()) 264 if (!pending_response_.cvc.empty())
206 delegate_->OnUnmaskResponse(pending_response_); 265 delegate_->OnUnmaskResponse(pending_response_);
207 } 266 }
208 267
209 } // namespace autofill 268 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698