Commit 9597ec50 authored by Rouslan Solomakhin's avatar Rouslan Solomakhin Committed by Chromium LUCI CQ

[Web Payment] Measure usage of standardized payment methods.

This patch adds a use counter for the number of times that a user
invokes a payment handler with a standardized payment method identifier,
such as "basic-card" or "tokenized-card", as distinct from URL-based
payment method identifiers, such as "https://bobpay.xyz".

Chrome status: https://chromestatus.com/feature/5717324021628928
Blink intent to deprecate and remove:
https://groups.google.com/a/chromium.org/g/blink-dev/c/ZS0JxjApEhI/m/GP1_t04gBAAJ

Bug: 1159510
Change-Id: I4082ddfee7dcf293d57cb1847a526192419ff0eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2595617
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Reviewed-by: default avatarMarijn Kruisselbrink <mek@chromium.org>
Reviewed-by: default avatarLiquan (Max) Gu <maxlg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842013}
parent 26bb5b2a
...@@ -3068,6 +3068,7 @@ enum WebFeature { ...@@ -3068,6 +3068,7 @@ enum WebFeature {
kSamePartyCookieExclusionOverruledSameSite = 3747, kSamePartyCookieExclusionOverruledSameSite = 3747,
kSamePartyCookieInclusionOverruledSameSite = 3748, kSamePartyCookieInclusionOverruledSameSite = 3748,
kEmbedElementWithoutTypeSrcChanged = 3749, kEmbedElementWithoutTypeSrcChanged = 3749,
kPaymentHandlerStandardizedPaymentMethodIdentifier = 3750,
// Add new features immediately above this line. Don't change assigned // Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots. // numbers of any item, and don't reuse removed slots.
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "third_party/blink/renderer/modules/service_worker/service_worker_global_scope.h" #include "third_party/blink/renderer/modules/service_worker/service_worker_global_scope.h"
#include <algorithm>
#include <memory> #include <memory>
#include <utility> #include <utility>
...@@ -47,6 +48,7 @@ ...@@ -47,6 +48,7 @@
#include "third_party/blink/public/mojom/appcache/appcache.mojom-blink.h" #include "third_party/blink/public/mojom/appcache/appcache.mojom-blink.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-blink.h" #include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-blink.h"
#include "third_party/blink/public/mojom/timing/worker_timing_container.mojom-blink.h" #include "third_party/blink/public/mojom/timing/worker_timing_container.mojom-blink.h"
#include "third_party/blink/public/mojom/web_feature/web_feature.mojom-blink.h"
#include "third_party/blink/public/mojom/worker/subresource_loader_updater.mojom.h" #include "third_party/blink/public/mojom/worker/subresource_loader_updater.mojom.h"
#include "third_party/blink/public/platform/modules/service_worker/web_service_worker_error.h" #include "third_party/blink/public/platform/modules/service_worker/web_service_worker_error.h"
#include "third_party/blink/public/platform/modules/service_worker/web_service_worker_fetch_context.h" #include "third_party/blink/public/platform/modules/service_worker/web_service_worker_fetch_context.h"
...@@ -2406,6 +2408,18 @@ void ServiceWorkerGlobalScope::StartPaymentRequestEvent( ...@@ -2406,6 +2408,18 @@ void ServiceWorkerGlobalScope::StartPaymentRequestEvent(
event_data->payment_options->request_shipping); event_data->payment_options->request_shipping);
} }
// Count standardized payment method identifiers, such as "basic-card" or
// "tokenized-card". Omit counting the URL-based payment method identifiers,
// such as "https://bobpay.xyz".
if (std::any_of(
event_data->method_data.begin(), event_data->method_data.end(),
[](const payments::mojom::blink::PaymentMethodDataPtr& datum) {
return datum && !datum->supported_method.StartsWith("http");
})) {
UseCounter::Count(
this, WebFeature::kPaymentHandlerStandardizedPaymentMethodIdentifier);
}
mojo::PendingRemote<payments::mojom::blink::PaymentHandlerHost> mojo::PendingRemote<payments::mojom::blink::PaymentHandlerHost>
payment_handler_host = std::move(event_data->payment_handler_host); payment_handler_host = std::move(event_data->payment_handler_host);
Event* event = PaymentRequestEvent::Create( Event* event = PaymentRequestEvent::Create(
...@@ -2413,8 +2427,7 @@ void ServiceWorkerGlobalScope::StartPaymentRequestEvent( ...@@ -2413,8 +2427,7 @@ void ServiceWorkerGlobalScope::StartPaymentRequestEvent(
PaymentEventDataConversion::ToPaymentRequestEventInit( PaymentEventDataConversion::ToPaymentRequestEventInit(
ScriptController()->GetScriptState(), std::move(event_data)), ScriptController()->GetScriptState(), std::move(event_data)),
std::move(payment_handler_host), respond_with_observer, std::move(payment_handler_host), respond_with_observer,
wait_until_observer, wait_until_observer, this);
ExecutionContext::From(ScriptController()->GetScriptState()));
DispatchExtendableEventWithRespondWith(event, wait_until_observer, DispatchExtendableEventWithRespondWith(event, wait_until_observer,
respond_with_observer); respond_with_observer);
......
...@@ -30823,6 +30823,7 @@ Called by update_use_counter_feature_enum.py.--> ...@@ -30823,6 +30823,7 @@ Called by update_use_counter_feature_enum.py.-->
<int value="3747" label="SamePartyCookieExclusionOverruledSameSite"/> <int value="3747" label="SamePartyCookieExclusionOverruledSameSite"/>
<int value="3748" label="SamePartyCookieInclusionOverruledSameSite"/> <int value="3748" label="SamePartyCookieInclusionOverruledSameSite"/>
<int value="3749" label="EmbedElementWithoutTypeSrcChanged"/> <int value="3749" label="EmbedElementWithoutTypeSrcChanged"/>
<int value="3750" label="PaymentHandlerStandardizedPaymentMethodIdentifier"/>
</enum> </enum>
<enum name="FeaturePolicyAllowlistType"> <enum name="FeaturePolicyAllowlistType">
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