OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "bindings/modules/v8/serialization/V8ScriptValueDeserializerForModules.
h" | 5 #include "bindings/modules/v8/serialization/V8ScriptValueDeserializerForModules.
h" |
6 | 6 |
7 #include "bindings/modules/v8/serialization/WebCryptoSubTags.h" | 7 #include "bindings/modules/v8/serialization/WebCryptoSubTags.h" |
8 #include "modules/crypto/CryptoKey.h" | 8 #include "modules/crypto/CryptoKey.h" |
| 9 #include "modules/filesystem/DOMFileSystem.h" |
9 #include "modules/peerconnection/RTCCertificate.h" | 10 #include "modules/peerconnection/RTCCertificate.h" |
| 11 #include "platform/FileSystemType.h" |
10 #include "public/platform/Platform.h" | 12 #include "public/platform/Platform.h" |
11 #include "public/platform/WebCrypto.h" | 13 #include "public/platform/WebCrypto.h" |
12 #include "public/platform/WebCryptoKeyAlgorithm.h" | 14 #include "public/platform/WebCryptoKeyAlgorithm.h" |
13 #include "public/platform/WebRTCCertificateGenerator.h" | 15 #include "public/platform/WebRTCCertificateGenerator.h" |
14 | 16 |
15 namespace blink { | 17 namespace blink { |
16 | 18 |
17 ScriptWrappable* V8ScriptValueDeserializerForModules::readDOMObject( | 19 ScriptWrappable* V8ScriptValueDeserializerForModules::readDOMObject( |
18 SerializationTag tag) { | 20 SerializationTag tag) { |
19 // Give the core/ implementation a chance to try first. | 21 // Give the core/ implementation a chance to try first. |
20 // If it didn't recognize the kind of wrapper, try the modules types. | 22 // If it didn't recognize the kind of wrapper, try the modules types. |
21 if (ScriptWrappable* wrappable = | 23 if (ScriptWrappable* wrappable = |
22 V8ScriptValueDeserializer::readDOMObject(tag)) | 24 V8ScriptValueDeserializer::readDOMObject(tag)) |
23 return wrappable; | 25 return wrappable; |
24 | 26 |
25 switch (tag) { | 27 switch (tag) { |
26 case CryptoKeyTag: | 28 case CryptoKeyTag: |
27 return readCryptoKey(); | 29 return readCryptoKey(); |
| 30 case DOMFileSystemTag: { |
| 31 uint32_t rawType; |
| 32 String name; |
| 33 String rootURL; |
| 34 if (!readUint32(&rawType) || rawType > FileSystemTypeLast || |
| 35 !readUTF8String(&name) || !readUTF8String(&rootURL)) |
| 36 return nullptr; |
| 37 return DOMFileSystem::create(getScriptState()->getExecutionContext(), |
| 38 name, static_cast<FileSystemType>(rawType), |
| 39 KURL(ParsedURLString, rootURL)); |
| 40 } |
28 case RTCCertificateTag: { | 41 case RTCCertificateTag: { |
29 String pemPrivateKey; | 42 String pemPrivateKey; |
30 String pemCertificate; | 43 String pemCertificate; |
31 if (!readUTF8String(&pemPrivateKey) || !readUTF8String(&pemCertificate)) | 44 if (!readUTF8String(&pemPrivateKey) || !readUTF8String(&pemCertificate)) |
32 return nullptr; | 45 return nullptr; |
33 std::unique_ptr<WebRTCCertificateGenerator> certificateGenerator( | 46 std::unique_ptr<WebRTCCertificateGenerator> certificateGenerator( |
34 Platform::current()->createRTCCertificateGenerator()); | 47 Platform::current()->createRTCCertificateGenerator()); |
35 std::unique_ptr<WebRTCCertificate> certificate = | 48 std::unique_ptr<WebRTCCertificate> certificate = |
36 certificateGenerator->fromPEM(pemPrivateKey, pemCertificate); | 49 certificateGenerator->fromPEM(pemPrivateKey, pemCertificate); |
37 return new RTCCertificate(std::move(certificate)); | 50 return new RTCCertificate(std::move(certificate)); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 WebCryptoKey key = WebCryptoKey::createNull(); | 273 WebCryptoKey key = WebCryptoKey::createNull(); |
261 if (!Platform::current()->crypto()->deserializeKeyForClone( | 274 if (!Platform::current()->crypto()->deserializeKeyForClone( |
262 algorithm, keyType, extractable, usages, | 275 algorithm, keyType, extractable, usages, |
263 reinterpret_cast<const unsigned char*>(keyData), keyDataLength, key)) | 276 reinterpret_cast<const unsigned char*>(keyData), keyDataLength, key)) |
264 return nullptr; | 277 return nullptr; |
265 | 278 |
266 return CryptoKey::create(key); | 279 return CryptoKey::create(key); |
267 } | 280 } |
268 | 281 |
269 } // namespace blink | 282 } // namespace blink |
OLD | NEW |