OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 13 matching lines...) Expand all Loading... | |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "public/web/WebScriptBindings.h" | 32 #include "public/web/WebScriptBindings.h" |
33 | 33 |
34 #include "bindings/v8/Dictionary.h" | |
34 #include "bindings/v8/V8Binding.h" | 35 #include "bindings/v8/V8Binding.h" |
36 #include "modules/crypto/CryptoResultImpl.h" | |
37 #include "modules/crypto/NormalizeAlgorithm.h" | |
38 #include "platform/CryptoResult.h" | |
39 #include "public/platform/WebCryptoAlgorithm.h" | |
35 #include "public/platform/WebString.h" | 40 #include "public/platform/WebString.h" |
41 #include <v8.h> | |
36 | 42 |
37 using namespace WebCore; | 43 using namespace WebCore; |
38 | 44 |
39 namespace blink { | 45 namespace blink { |
40 | 46 |
41 v8::Local<v8::String> WebScriptBindings::toV8String(const WebString& string, v8: :Isolate* isolate) | 47 v8::Local<v8::String> WebScriptBindings::toV8String(const WebString& string, v8: :Isolate* isolate) |
42 { | 48 { |
43 return v8String(isolate, string); | 49 return v8String(isolate, string); |
44 } | 50 } |
45 | 51 |
46 WebString WebScriptBindings::toWebString(v8::Handle<v8::String> v8String) | 52 WebString WebScriptBindings::toWebString(v8::Handle<v8::String> v8String) |
47 { | 53 { |
48 return v8StringToWebCoreString<String>(v8String, Externalize); | 54 return v8StringToWebCoreString<String>(v8String, Externalize); |
49 } | 55 } |
50 | 56 |
57 WebCryptoAlgorithm WebScriptBindings::normalizeCryptoAlgorithm(v8::Handle<v8::Ob ject> algorithmObject, AlgorithmOperation operation, int* exceptionCode, WebStri ng* errorDetails, v8::Isolate* isolate) | |
58 { | |
59 Dictionary algorithmDictionary = Dictionary(algorithmObject, isolate); | |
60 v8::TryCatch block; | |
pneubeck (no reviews)
2014/05/29 12:52:56
ignore this line, I will remove it once I have acc
| |
61 if (!algorithmDictionary.isUndefinedOrNull() && !algorithmDictionary.isObjec t()) | |
62 return WebCryptoAlgorithm(); | |
63 WebCryptoAlgorithm algorithm; | |
64 WebCore::AlgorithmError error; | |
65 if (!WebCore::normalizeAlgorithm(algorithmDictionary, operation, algorithm, &error)) { | |
66 *exceptionCode = toExceptionCode(error.errorType); | |
67 *errorDetails = error.errorDetails; | |
68 return WebCryptoAlgorithm(); | |
69 } | |
70 | |
71 return algorithm; | |
72 } | |
73 | |
51 } // namespace blink | 74 } // namespace blink |
OLD | NEW |