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

Side by Side Diff: components/payments/content/payment_request.cc

Issue 2870153002: [Payments] Record navigations that close the Payment Request as aborts. (Closed)
Patch Set: Addressed comments Created 3 years, 7 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/payments/content/payment_request.h" 5 #include "components/payments/content/payment_request.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 return; 143 return;
144 } 144 }
145 spec_->UpdateWith(std::move(details)); 145 spec_->UpdateWith(std::move(details));
146 } 146 }
147 147
148 void PaymentRequest::Abort() { 148 void PaymentRequest::Abort() {
149 // The API user has decided to abort. We return a successful abort message to 149 // The API user has decided to abort. We return a successful abort message to
150 // the renderer, which closes the Mojo message pipe, which triggers 150 // the renderer, which closes the Mojo message pipe, which triggers
151 // PaymentRequest::OnConnectionTerminated, which destroys this object. 151 // PaymentRequest::OnConnectionTerminated, which destroys this object.
152 // TODO(crbug.com/716546): Add a merchant abort metric, 152 // TODO(crbug.com/716546): Add a merchant abort metric,
153 journey_logger_.RecordJourneyStatsHistograms( 153 if (!has_recorded_abort_reason_) {
Mathieu 2017/05/10 20:23:07 as discussed let's move this to a private method
154 JourneyLogger::COMPLETION_STATUS_OTHER_ABORTED); 154 has_recorded_abort_reason_ = true;
155 journey_logger_.RecordJourneyStatsHistograms(
156 JourneyLogger::COMPLETION_STATUS_OTHER_ABORTED);
157 }
155 if (client_.is_bound()) 158 if (client_.is_bound())
156 client_->OnAbort(true /* aborted_successfully */); 159 client_->OnAbort(true /* aborted_successfully */);
157 } 160 }
158 161
159 void PaymentRequest::Complete(mojom::PaymentComplete result) { 162 void PaymentRequest::Complete(mojom::PaymentComplete result) {
160 if (!client_.is_bound()) 163 if (!client_.is_bound())
161 return; 164 return;
162 165
163 if (result != mojom::PaymentComplete::SUCCESS) { 166 if (result != mojom::PaymentComplete::SUCCESS) {
164 delegate_->ShowErrorMessage(); 167 delegate_->ShowErrorMessage();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 mojom::PaymentAddressPtr address) { 217 mojom::PaymentAddressPtr address) {
215 client_->OnShippingAddressChange(std::move(address)); 218 client_->OnShippingAddressChange(std::move(address));
216 } 219 }
217 220
218 void PaymentRequest::UserCancelled() { 221 void PaymentRequest::UserCancelled() {
219 // If |client_| is not bound, then the object is already being destroyed as 222 // If |client_| is not bound, then the object is already being destroyed as
220 // a result of a renderer event. 223 // a result of a renderer event.
221 if (!client_.is_bound()) 224 if (!client_.is_bound())
222 return; 225 return;
223 226
224 journey_logger_.RecordJourneyStatsHistograms( 227 if (!has_recorded_abort_reason_) {
225 JourneyLogger::COMPLETION_STATUS_USER_ABORTED); 228 has_recorded_abort_reason_ = true;
229 journey_logger_.RecordJourneyStatsHistograms(
230 JourneyLogger::COMPLETION_STATUS_USER_ABORTED);
231 }
226 232
227 // This sends an error to the renderer, which informs the API user. 233 // This sends an error to the renderer, which informs the API user.
228 client_->OnError(mojom::PaymentErrorReason::USER_CANCEL); 234 client_->OnError(mojom::PaymentErrorReason::USER_CANCEL);
229 235
230 // We close all bindings and ask to be destroyed. 236 // We close all bindings and ask to be destroyed.
231 client_.reset(); 237 client_.reset();
232 binding_.Close(); 238 binding_.Close();
233 if (observer_for_testing_) 239 if (observer_for_testing_)
234 observer_for_testing_->OnConnectionTerminated(); 240 observer_for_testing_->OnConnectionTerminated();
235 manager_->DestroyRequest(this); 241 manager_->DestroyRequest(this);
236 } 242 }
237 243
244 void PaymentRequest::DidStartNavigation(bool is_user_initiated) {
245 if (!has_recorded_abort_reason_) {
246 has_recorded_abort_reason_ = true;
247 journey_logger_.RecordJourneyStatsHistograms(
248 is_user_initiated ? JourneyLogger::COMPLETION_STATUS_USER_ABORTED
249 : JourneyLogger::COMPLETION_STATUS_OTHER_ABORTED);
250 }
251 }
252
238 void PaymentRequest::OnConnectionTerminated() { 253 void PaymentRequest::OnConnectionTerminated() {
239 // We are here because of a browser-side error, or likely as a result of the 254 // We are here because of a browser-side error, or likely as a result of the
240 // connection_error_handler on |binding_|, which can mean that the renderer 255 // connection_error_handler on |binding_|, which can mean that the renderer
241 // has decided to close the pipe for various reasons (see all uses of 256 // has decided to close the pipe for various reasons (see all uses of
242 // PaymentRequest::clearResolversAndCloseMojoConnection() in Blink). We close 257 // PaymentRequest::clearResolversAndCloseMojoConnection() in Blink). We close
243 // the binding and the dialog, and ask to be deleted. 258 // the binding and the dialog, and ask to be deleted.
244 client_.reset(); 259 client_.reset();
245 binding_.Close(); 260 binding_.Close();
246 delegate_->CloseDialog(); 261 delegate_->CloseDialog();
247 if (observer_for_testing_) 262 if (observer_for_testing_)
248 observer_for_testing_->OnConnectionTerminated(); 263 observer_for_testing_->OnConnectionTerminated();
249 manager_->DestroyRequest(this); 264 manager_->DestroyRequest(this);
250 } 265 }
251 266
252 void PaymentRequest::Pay() { 267 void PaymentRequest::Pay() {
253 state_->GeneratePaymentResponse(); 268 state_->GeneratePaymentResponse();
254 } 269 }
255 270
256 } // namespace payments 271 } // namespace payments
OLDNEW
« no previous file with comments | « components/payments/content/payment_request.h ('k') | components/payments/content/payment_request_web_contents_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698