Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(507)

Side by Side Diff: Source/web/WebScriptBindings.cpp

Issue 295423004: Expose WebCrypto's algorithm normalization. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased, minor cleanups. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 if (!algorithmDictionary.isUndefinedOrNull() && !algorithmDictionary.isObjec t())
61 return WebCryptoAlgorithm();
62 WebCryptoAlgorithm algorithm;
63 AlgorithmError error;
64 if (!normalizeAlgorithm(algorithmDictionary, operation, algorithm, &error)) {
65 *exceptionCode = webCryptoErrorToExceptionCode(error.errorType);
66 *errorDetails = error.errorDetails;
67 return WebCryptoAlgorithm();
68 }
69
70 return algorithm;
71 }
72
51 } // namespace blink 73 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698