Commit 2b480c04 authored by Sahel Sharify's avatar Sahel Sharify Committed by Commit Bot

[Payments]UkmSourceId() doesn't crash for JIT install PH in incognito.

This cl changes payments::ServiceWorkerPaymentApp::UkmSourceId() to
use |installable_web_app_info_->sw_scope| for JIT installable PHs while
calculating UkmSourceId.

Without this change using |stored_payment_app_info_->scope| for JIT
installable PHs would cause browser crash in incognito mode. Please
note that explicitly returning InvalidUkmSourceId for incognito
mode is not needed since UKM recorder does not record entries in
incognito mode.

Change-Id: I291d1404c89f5261e97d61ca8b74bbbfa905b229
Bug: 1066199
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2132944Reviewed-by: default avatarDanyao Wang <danyao@chromium.org>
Commit-Queue: Sahel Sharify <sahel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756008}
parent 808b68cf
...@@ -533,12 +533,15 @@ void ServiceWorkerPaymentApp::OnPaymentAppIdentity(const url::Origin& origin, ...@@ -533,12 +533,15 @@ void ServiceWorkerPaymentApp::OnPaymentAppIdentity(const url::Origin& origin,
ukm::SourceId ServiceWorkerPaymentApp::UkmSourceId() { ukm::SourceId ServiceWorkerPaymentApp::UkmSourceId() {
if (ukm_source_id_ == ukm::kInvalidSourceId) { if (ukm_source_id_ == ukm::kInvalidSourceId) {
GURL sw_scope = needs_installation_
? GURL(installable_web_app_info_->sw_scope)
: stored_payment_app_info_->scope;
// At this point we know that the payment handler window is open for this // At this point we know that the payment handler window is open for this
// app since this getter is called for the invoked app inside the // app since this getter is called for the invoked app inside the
// PaymentRequest::OnPaymentHandlerOpenWindowCalled function. // PaymentRequest::OnPaymentHandlerOpenWindowCalled function.
ukm_source_id_ = content::PaymentAppProvider::GetInstance() ukm_source_id_ =
->GetSourceIdForPaymentAppFromScope( content::PaymentAppProvider::GetInstance()
GURL(stored_payment_app_info_->scope).GetOrigin()); ->GetSourceIdForPaymentAppFromScope(sw_scope.GetOrigin());
} }
return ukm_source_id_; return ukm_source_id_;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment