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 "core/dom/ExecutionContext.h" |
8 #include "modules/crypto/CryptoKey.h" | 9 #include "modules/crypto/CryptoKey.h" |
9 #include "modules/filesystem/DOMFileSystem.h" | 10 #include "modules/filesystem/DOMFileSystem.h" |
10 #include "modules/peerconnection/RTCCertificate.h" | 11 #include "modules/peerconnection/RTCCertificate.h" |
11 #include "platform/FileSystemType.h" | 12 #include "platform/FileSystemType.h" |
12 #include "public/platform/Platform.h" | 13 #include "public/platform/Platform.h" |
13 #include "public/platform/WebCrypto.h" | 14 #include "public/platform/WebCrypto.h" |
14 #include "public/platform/WebCryptoKeyAlgorithm.h" | 15 #include "public/platform/WebCryptoKeyAlgorithm.h" |
15 #include "public/platform/WebRTCCertificateGenerator.h" | 16 #include "public/platform/WebRTCCertificateGenerator.h" |
16 | 17 |
17 namespace blink { | 18 namespace blink { |
18 | 19 |
19 ScriptWrappable* V8ScriptValueDeserializerForModules::ReadDOMObject( | 20 ScriptWrappable* V8ScriptValueDeserializerForModules::ReadDOMObject( |
20 SerializationTag tag) { | 21 SerializationTag tag) { |
21 // Give the core/ implementation a chance to try first. | 22 // Give the core/ implementation a chance to try first. |
22 // If it didn't recognize the kind of wrapper, try the modules types. | 23 // If it didn't recognize the kind of wrapper, try the modules types. |
23 if (ScriptWrappable* wrappable = | 24 if (ScriptWrappable* wrappable = |
24 V8ScriptValueDeserializer::ReadDOMObject(tag)) | 25 V8ScriptValueDeserializer::ReadDOMObject(tag)) |
25 return wrappable; | 26 return wrappable; |
26 | 27 |
27 switch (tag) { | 28 switch (tag) { |
28 case kCryptoKeyTag: | 29 case kCryptoKeyTag: |
29 return ReadCryptoKey(); | 30 return ReadCryptoKey(); |
30 case kDOMFileSystemTag: { | 31 case kDOMFileSystemTag: { |
31 uint32_t raw_type; | 32 uint32_t raw_type; |
32 String name; | 33 String name; |
33 String root_url; | 34 String root_url; |
34 if (!ReadUint32(&raw_type) || raw_type > kFileSystemTypeLast || | 35 if (!ReadUint32(&raw_type) || raw_type > kFileSystemTypeLast || |
35 !ReadUTF8String(&name) || !ReadUTF8String(&root_url)) | 36 !ReadUTF8String(&name) || !ReadUTF8String(&root_url)) |
36 return nullptr; | 37 return nullptr; |
37 return DOMFileSystem::Create(GetScriptState()->GetExecutionContext(), | 38 return DOMFileSystem::Create(ExecutionContext::From(GetScriptState()), |
38 name, static_cast<FileSystemType>(raw_type), | 39 name, static_cast<FileSystemType>(raw_type), |
39 KURL(kParsedURLString, root_url)); | 40 KURL(kParsedURLString, root_url)); |
40 } | 41 } |
41 case kRTCCertificateTag: { | 42 case kRTCCertificateTag: { |
42 String pem_private_key; | 43 String pem_private_key; |
43 String pem_certificate; | 44 String pem_certificate; |
44 if (!ReadUTF8String(&pem_private_key) || | 45 if (!ReadUTF8String(&pem_private_key) || |
45 !ReadUTF8String(&pem_certificate)) | 46 !ReadUTF8String(&pem_certificate)) |
46 return nullptr; | 47 return nullptr; |
47 std::unique_ptr<WebRTCCertificateGenerator> certificate_generator( | 48 std::unique_ptr<WebRTCCertificateGenerator> certificate_generator( |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 if (!Platform::Current()->Crypto()->DeserializeKeyForClone( | 281 if (!Platform::Current()->Crypto()->DeserializeKeyForClone( |
281 algorithm, key_type, extractable, usages, | 282 algorithm, key_type, extractable, usages, |
282 reinterpret_cast<const unsigned char*>(key_data), key_data_length, | 283 reinterpret_cast<const unsigned char*>(key_data), key_data_length, |
283 key)) | 284 key)) |
284 return nullptr; | 285 return nullptr; |
285 | 286 |
286 return CryptoKey::Create(key); | 287 return CryptoKey::Create(key); |
287 } | 288 } |
288 | 289 |
289 } // namespace blink | 290 } // namespace blink |
OLD | NEW |