Commit 0752fa22 authored by Jihwan Marc Kim's avatar Jihwan Marc Kim Committed by Commit Bot

Developer console warning for requesting extra information

with Play Billing.

Whenever an app-store payment method is one of the payment methods
being supported and any of the "requestShipping", "requestPayerName",
"requestPayerEmail", and "requestPayerPhone" is true,
then payment_request.cc should print an error message in developer
console.

Bug: 1095812
Change-Id: Icd1c0d1f43d1525591d701458afee1a8a828c7f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2249206Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779915}
parent 9693417f
......@@ -270,13 +270,18 @@ void ValidateShippingOptionOrPaymentItem(const T* item,
}
}
const WTF::HashSet<String> GetAppStoreBillingMethods() {
static const WTF::HashSet<String> app_store_billing_methods = {
kGooglePlayBillingMethod};
return app_store_billing_methods;
}
bool RequestingOnlyAppStoreBillingMethods(
const Vector<payments::mojom::blink::PaymentMethodDataPtr>& method_data) {
DCHECK(!method_data.IsEmpty());
static const WTF::HashSet<String> app_store_billing_methods = {
kGooglePlayBillingMethod};
const WTF::HashSet<String> billing_methods = GetAppStoreBillingMethods();
for (const auto& method : method_data) {
if (!app_store_billing_methods.Contains(method->supported_method))
if (!billing_methods.Contains(method->supported_method))
return false;
}
return true;
......@@ -1187,6 +1192,20 @@ PaymentRequest::PaymentRequest(
if (exception_state.HadException())
return;
const WTF::HashSet<String> billing_methods = GetAppStoreBillingMethods();
for (const PaymentMethodDataPtr& data : validated_method_data) {
if (billing_methods.Contains(data->supported_method) &&
(options_->requestShipping() || options_->requestPayerName() ||
options_->requestPayerEmail() || options_->requestPayerPhone())) {
execution_context->AddConsoleMessage(MakeGarbageCollected<ConsoleMessage>(
mojom::blink::ConsoleMessageSource::kJavaScript,
mojom::blink::ConsoleMessageLevel::kError,
"Payment method \"" + data->supported_method +
"\" cannot be used with \"requestShipping\", \"requestPayerName\", "
"\"requestPayerEmail\", or \"requestPayerPhone\"."));
}
}
if (options_->requestShipping()) {
shipping_type_ = options_->shippingType();
......
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