Commit f688b327 authored by Ian Clelland's avatar Ian Clelland Committed by Commit Bot

Move PaymentRequest feature policy checks to Document

Bug: 888668
Change-Id: I2ca249628b9395480f5dfcaaf2b300046dba9b2c
Reviewed-on: https://chromium-review.googlesource.com/c/1243503Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Ian Clelland <iclelland@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596315}
parent 980885c6
......@@ -739,17 +739,22 @@ void ValidateAndConvertPaymentMethodData(
}
}
bool AllowedToUsePaymentRequest(const Frame* frame) {
bool AllowedToUsePaymentRequest(const ExecutionContext* execution_context) {
// To determine whether a Document object |document| is allowed to use the
// feature indicated by attribute name |allowpaymentrequest|, run these steps:
// If this context is not a document, return false.
if (!execution_context->IsDocument())
return false;
// 1. If |document| has no browsing context, then return false.
if (!frame)
const Document* document = ToDocument(execution_context);
if (!document->GetFrame())
return false;
// 2. If Feature Policy is enabled, return the policy for "payment" feature.
return frame->DeprecatedIsFeatureEnabled(
mojom::FeaturePolicyFeature::kPayment, ReportOptions::kReportOnFailure);
return document->IsFeatureEnabled(mojom::FeaturePolicyFeature::kPayment,
ReportOptions::kReportOnFailure);
}
void WarnIgnoringQueryQuotaForCanMakePayment(
......@@ -1056,7 +1061,7 @@ PaymentRequest::PaymentRequest(ExecutionContext* execution_context,
&PaymentRequest::OnCompleteTimeout) {
DCHECK(GetExecutionContext()->IsSecureContext());
if (!AllowedToUsePaymentRequest(GetFrame())) {
if (!AllowedToUsePaymentRequest(execution_context)) {
exception_state.ThrowSecurityError(
"Must be in a top-level browsing context or an iframe needs to specify "
"'allowpaymentrequest' explicitly");
......
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