| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ScriptValueSerializerForModules.h" | 5 #include "bindings/modules/v8/ScriptValueSerializerForModules.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/SerializationTag.h" | 7 #include "bindings/core/v8/SerializationTag.h" |
| 8 #include "bindings/core/v8/V8Binding.h" | 8 #include "bindings/core/v8/V8Binding.h" |
| 9 #include "bindings/modules/v8/V8CryptoKey.h" | 9 #include "bindings/modules/v8/V8CryptoKey.h" |
| 10 #include "bindings/modules/v8/V8DOMFileSystem.h" | 10 #include "bindings/modules/v8/V8DOMFileSystem.h" |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 String name; | 369 String name; |
| 370 String url; | 370 String url; |
| 371 if (!doReadUint32(&type)) | 371 if (!doReadUint32(&type)) |
| 372 return false; | 372 return false; |
| 373 if (!readWebCoreString(&name)) | 373 if (!readWebCoreString(&name)) |
| 374 return false; | 374 return false; |
| 375 if (!readWebCoreString(&url)) | 375 if (!readWebCoreString(&url)) |
| 376 return false; | 376 return false; |
| 377 DOMFileSystem* fs = DOMFileSystem::create(getScriptState()->getExecutionCont
ext(), name, static_cast<FileSystemType>(type), KURL(ParsedURLString, url)); | 377 DOMFileSystem* fs = DOMFileSystem::create(getScriptState()->getExecutionCont
ext(), name, static_cast<FileSystemType>(type), KURL(ParsedURLString, url)); |
| 378 *value = toV8(fs, getScriptState()->context()->Global(), isolate()); | 378 *value = toV8(fs, getScriptState()->context()->Global(), isolate()); |
| 379 return !value->IsEmpty(); | 379 return true; |
| 380 } | 380 } |
| 381 | 381 |
| 382 bool SerializedScriptValueReaderForModules::readCryptoKey(v8::Local<v8::Value>*
value) | 382 bool SerializedScriptValueReaderForModules::readCryptoKey(v8::Local<v8::Value>*
value) |
| 383 { | 383 { |
| 384 uint32_t rawKeyType; | 384 uint32_t rawKeyType; |
| 385 if (!doReadUint32(&rawKeyType)) | 385 if (!doReadUint32(&rawKeyType)) |
| 386 return false; | 386 return false; |
| 387 | 387 |
| 388 WebCryptoKeyAlgorithm algorithm; | 388 WebCryptoKeyAlgorithm algorithm; |
| 389 WebCryptoKeyType type = WebCryptoKeyTypeSecret; | 389 WebCryptoKeyType type = WebCryptoKeyTypeSecret; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 return false; | 426 return false; |
| 427 | 427 |
| 428 const uint8_t* keyData = allocate(keyDataLength); | 428 const uint8_t* keyData = allocate(keyDataLength); |
| 429 WebCryptoKey key = WebCryptoKey::createNull(); | 429 WebCryptoKey key = WebCryptoKey::createNull(); |
| 430 if (!Platform::current()->crypto()->deserializeKeyForClone( | 430 if (!Platform::current()->crypto()->deserializeKeyForClone( |
| 431 algorithm, type, extractable, usages, keyData, keyDataLength, key)) { | 431 algorithm, type, extractable, usages, keyData, keyDataLength, key)) { |
| 432 return false; | 432 return false; |
| 433 } | 433 } |
| 434 | 434 |
| 435 *value = toV8(CryptoKey::create(key), getScriptState()->context()->Global(),
isolate()); | 435 *value = toV8(CryptoKey::create(key), getScriptState()->context()->Global(),
isolate()); |
| 436 return !value->IsEmpty(); | 436 return true; |
| 437 } | 437 } |
| 438 | 438 |
| 439 bool SerializedScriptValueReaderForModules::readRTCCertificate(v8::Local<v8::Val
ue>* value) | 439 bool SerializedScriptValueReaderForModules::readRTCCertificate(v8::Local<v8::Val
ue>* value) |
| 440 { | 440 { |
| 441 String pemPrivateKey; | 441 String pemPrivateKey; |
| 442 if (!readWebCoreString(&pemPrivateKey)) | 442 if (!readWebCoreString(&pemPrivateKey)) |
| 443 return false; | 443 return false; |
| 444 String pemCertificate; | 444 String pemCertificate; |
| 445 if (!readWebCoreString(&pemCertificate)) | 445 if (!readWebCoreString(&pemCertificate)) |
| 446 return false; | 446 return false; |
| 447 | 447 |
| 448 std::unique_ptr<WebRTCCertificateGenerator> certificateGenerator = wrapUniqu
e( | 448 std::unique_ptr<WebRTCCertificateGenerator> certificateGenerator = wrapUniqu
e( |
| 449 Platform::current()->createRTCCertificateGenerator()); | 449 Platform::current()->createRTCCertificateGenerator()); |
| 450 | 450 |
| 451 std::unique_ptr<WebRTCCertificate> certificate( | 451 std::unique_ptr<WebRTCCertificate> certificate( |
| 452 certificateGenerator->fromPEM( | 452 certificateGenerator->fromPEM( |
| 453 pemPrivateKey, | 453 pemPrivateKey, |
| 454 pemCertificate)); | 454 pemCertificate)); |
| 455 RTCCertificate* jsCertificate = new RTCCertificate(std::move(certificate)); | 455 RTCCertificate* jsCertificate = new RTCCertificate(std::move(certificate)); |
| 456 | 456 |
| 457 *value = toV8(jsCertificate, getScriptState()->context()->Global(), isolate(
)); | 457 *value = toV8(jsCertificate, getScriptState()->context()->Global(), isolate(
)); |
| 458 return !value->IsEmpty(); | 458 return true; |
| 459 } | 459 } |
| 460 | 460 |
| 461 bool SerializedScriptValueReaderForModules::doReadHmacKey(WebCryptoKeyAlgorithm&
algorithm, WebCryptoKeyType& type) | 461 bool SerializedScriptValueReaderForModules::doReadHmacKey(WebCryptoKeyAlgorithm&
algorithm, WebCryptoKeyType& type) |
| 462 { | 462 { |
| 463 uint32_t lengthBytes; | 463 uint32_t lengthBytes; |
| 464 if (!doReadUint32(&lengthBytes)) | 464 if (!doReadUint32(&lengthBytes)) |
| 465 return false; | 465 return false; |
| 466 WebCryptoAlgorithmId hash; | 466 WebCryptoAlgorithmId hash; |
| 467 if (!doReadAlgorithmId(hash)) | 467 if (!doReadAlgorithmId(hash)) |
| 468 return false; | 468 return false; |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 : ScriptValueDeserializer(reader, messagePorts, arrayBufferContents, imageBi
tmapContents) | 681 : ScriptValueDeserializer(reader, messagePorts, arrayBufferContents, imageBi
tmapContents) |
| 682 { | 682 { |
| 683 } | 683 } |
| 684 | 684 |
| 685 bool ScriptValueDeserializerForModules::read(v8::Local<v8::Value>* value) | 685 bool ScriptValueDeserializerForModules::read(v8::Local<v8::Value>* value) |
| 686 { | 686 { |
| 687 return toSerializedScriptValueReaderForModules(reader()).read(value, *this); | 687 return toSerializedScriptValueReaderForModules(reader()).read(value, *this); |
| 688 } | 688 } |
| 689 | 689 |
| 690 } // namespace blink | 690 } // namespace blink |
| OLD | NEW |