Commit 980885c6 authored by Ian Clelland's avatar Ian Clelland Committed by Commit Bot

Move WebUSB feature policy checks to Document

Bug: 888668
Change-Id: Iddc72d0638ddebbab044f070237d6bd885c557aa
Reviewed-on: https://chromium-review.googlesource.com/c/1243523Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: Ian Clelland <iclelland@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596314}
parent 2d9db2d8
......@@ -114,9 +114,7 @@ ScriptPromise USB::getDevices(ScriptState* script_state) {
ExecutionContext* execution_context = ExecutionContext::From(script_state);
if (execution_context && execution_context->IsDocument()) {
ToDocument(execution_context)
->GetFrame()
->DeprecatedReportFeaturePolicyViolation(
mojom::FeaturePolicyFeature::kUsb);
->ReportFeaturePolicyViolation(mojom::FeaturePolicyFeature::kUsb);
}
return ScriptPromise::RejectWithDOMException(
script_state, DOMException::Create(DOMExceptionCode::kSecurityError,
......@@ -134,14 +132,14 @@ ScriptPromise USB::getDevices(ScriptState* script_state) {
ScriptPromise USB::requestDevice(ScriptState* script_state,
const USBDeviceRequestOptions& options) {
LocalFrame* frame = GetFrame();
if (!frame) {
if (!frame || !frame->GetDocument()) {
return ScriptPromise::RejectWithDOMException(
script_state,
DOMException::Create(DOMExceptionCode::kNotSupportedError));
}
if (!frame->DeprecatedIsFeatureEnabled(mojom::FeaturePolicyFeature::kUsb,
ReportOptions::kReportOnFailure)) {
if (!frame->GetDocument()->IsFeatureEnabled(
mojom::FeaturePolicyFeature::kUsb, ReportOptions::kReportOnFailure)) {
return ScriptPromise::RejectWithDOMException(
script_state, DOMException::Create(DOMExceptionCode::kSecurityError,
kFeaturePolicyBlocked));
......@@ -315,9 +313,8 @@ bool USB::IsContextSupported() const {
}
bool USB::IsFeatureEnabled() const {
ExecutionContext* context = GetExecutionContext();
FeaturePolicy* policy = context->GetSecurityContext().GetFeaturePolicy();
return policy->IsFeatureEnabled(mojom::FeaturePolicyFeature::kUsb);
return GetExecutionContext()->GetSecurityContext().IsFeatureEnabled(
mojom::FeaturePolicyFeature::kUsb);
}
void USB::Trace(blink::Visitor* visitor) {
......
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