bool SerializedScriptValueReaderForModules::readDOMFileSystem( v8::Local<v8::Value>* value) { uint32_t type; String name; String url; if (!doReadUint32(&type)) return false; if (!readWebCoreString(&name)) return false; if (!readWebCoreString(&url)) return false; DOMFileSystem* fs = DOMFileSystem::create( getScriptState()->getExecutionContext(), name, static_cast<FileSystemType>(type), KURL(ParsedURLString, url)); *value = toV8(fs, getScriptState()->context()->Global(), isolate()); return !value->IsEmpty(); }
bool SerializedScriptValueReaderForModules::readCryptoKey( v8::Local<v8::Value>* value) { uint32_t rawKeyType; if (!doReadUint32(&rawKeyType)) return false; WebCryptoKeyAlgorithm algorithm; WebCryptoKeyType type = WebCryptoKeyTypeSecret; switch (static_cast<CryptoKeySubTag>(rawKeyType)) { case AesKeyTag: if (!doReadAesKey(algorithm, type)) return false; break; case HmacKeyTag: if (!doReadHmacKey(algorithm, type)) return false; break; case RsaHashedKeyTag: if (!doReadRsaHashedKey(algorithm, type)) return false; break; case EcKeyTag: if (!doReadEcKey(algorithm, type)) return false; break; case NoParamsKeyTag: if (!doReadKeyWithoutParams(algorithm, type)) return false; break; default: return false; } WebCryptoKeyUsageMask usages; bool extractable; if (!doReadKeyUsages(usages, extractable)) return false; uint32_t keyDataLength; if (!doReadUint32(&keyDataLength)) return false; if (position() + keyDataLength > length()) return false; const uint8_t* keyData = allocate(keyDataLength); WebCryptoKey key = WebCryptoKey::createNull(); if (!Platform::current()->crypto()->deserializeKeyForClone( algorithm, type, extractable, usages, keyData, keyDataLength, key)) { return false; } *value = toV8(CryptoKey::create(key), getScriptState()->context()->Global(), isolate()); return !value->IsEmpty(); }
void ScriptPromiseResolver::onTimerFired(TimerBase*) { ASSERT(m_state == Resolving || m_state == Rejecting); if (!getScriptState()->contextIsValid()) { detach(); return; } ScriptState::Scope scope(m_scriptState.get()); resolveOrRejectImmediately(); }
bool SerializedScriptValueReaderForModules::readRTCCertificate( v8::Local<v8::Value>* value) { String pemPrivateKey; if (!readWebCoreString(&pemPrivateKey)) return false; String pemCertificate; if (!readWebCoreString(&pemCertificate)) return false; std::unique_ptr<WebRTCCertificateGenerator> certificateGenerator = wrapUnique(Platform::current()->createRTCCertificateGenerator()); std::unique_ptr<WebRTCCertificate> certificate( certificateGenerator->fromPEM(pemPrivateKey, pemCertificate)); RTCCertificate* jsCertificate = new RTCCertificate(std::move(certificate)); *value = toV8(jsCertificate, getScriptState()->context()->Global(), isolate()); return !value->IsEmpty(); }
ScriptWrappable* V8ScriptValueDeserializerForModules::readDOMObject( SerializationTag tag) { // Give the core/ implementation a chance to try first. // If it didn't recognize the kind of wrapper, try the modules types. if (ScriptWrappable* wrappable = V8ScriptValueDeserializer::readDOMObject(tag)) return wrappable; switch (tag) { case CryptoKeyTag: return readCryptoKey(); case DOMFileSystemTag: { uint32_t rawType; String name; String rootURL; if (!readUint32(&rawType) || rawType > FileSystemTypeLast || !readUTF8String(&name) || !readUTF8String(&rootURL)) return nullptr; return DOMFileSystem::create(getScriptState()->getExecutionContext(), name, static_cast<FileSystemType>(rawType), KURL(ParsedURLString, rootURL)); } case RTCCertificateTag: { String pemPrivateKey; String pemCertificate; if (!readUTF8String(&pemPrivateKey) || !readUTF8String(&pemCertificate)) return nullptr; std::unique_ptr<WebRTCCertificateGenerator> certificateGenerator( Platform::current()->createRTCCertificateGenerator()); std::unique_ptr<WebRTCCertificate> certificate = certificateGenerator->fromPEM(pemPrivateKey, pemCertificate); return new RTCCertificate(std::move(certificate)); } default: break; } return nullptr; }