ScriptPromise Permissions::revoke(ScriptState* scriptState, const Dictionary& rawPermission) { WebPermissionClient* client = getClient(scriptState->getExecutionContext()); if (!client) return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(InvalidStateError, "In its current state, the global scope can't revoke permissions.")); ExceptionState exceptionState(ExceptionState::GetterContext, "revoke", "Permissions", scriptState->context()->Global(), scriptState->isolate()); Nullable<WebPermissionType> type = parsePermission(scriptState, rawPermission, exceptionState); if (exceptionState.hadException()) return exceptionState.reject(scriptState); ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); ScriptPromise promise = resolver->promise(); client->revokePermission(type.get(), KURL(KURL(), scriptState->getExecutionContext()->getSecurityOrigin()->toString()), new PermissionCallback(resolver, type.get())); return promise; }
ScriptPromise Permissions::revoke(ScriptState* scriptState, const Dictionary& rawPermission) { WebPermissionClient* client = getClient(scriptState->executionContext()); if (!client) return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(InvalidStateError, "In its current state, the global scope can't query permissions.")); TrackExceptionState exceptionState; PermissionDescriptor permission = NativeValueTraits<PermissionDescriptor>::nativeValue(scriptState->isolate(), rawPermission.v8Value(), exceptionState); if (exceptionState.hadException()) return ScriptPromise::reject(scriptState, v8::Exception::TypeError(v8String(scriptState->isolate(), exceptionState.message()))); ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); ScriptPromise promise = resolver->promise(); WebPermissionType type = getPermissionType(scriptState, rawPermission, permission, exceptionState); if (handleNotSupportedPermission(scriptState, rawPermission, resolver, type, exceptionState)) return promise; client->revokePermission(type, KURL(KURL(), scriptState->executionContext()->securityOrigin()->toString()), new PermissionCallback(resolver, type)); return promise; }