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

Unified 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, 7 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 side-by-side diff with in-line comments
Download patch
Index: Source/web/WebScriptBindings.cpp
diff --git a/Source/web/WebScriptBindings.cpp b/Source/web/WebScriptBindings.cpp
index 4377db6edd6a1f95dea7034983fa8f1a24557854..1452ed22126fa6b707be7a6ae39cbc0a49ced4f3 100644
--- a/Source/web/WebScriptBindings.cpp
+++ b/Source/web/WebScriptBindings.cpp
@@ -31,8 +31,14 @@
#include "config.h"
#include "public/web/WebScriptBindings.h"
+#include "bindings/v8/Dictionary.h"
#include "bindings/v8/V8Binding.h"
+#include "modules/crypto/CryptoResultImpl.h"
+#include "modules/crypto/NormalizeAlgorithm.h"
+#include "platform/CryptoResult.h"
+#include "public/platform/WebCryptoAlgorithm.h"
#include "public/platform/WebString.h"
+#include <v8.h>
using namespace WebCore;
@@ -48,4 +54,20 @@ WebString WebScriptBindings::toWebString(v8::Handle<v8::String> v8String)
return v8StringToWebCoreString<String>(v8String, Externalize);
}
+WebCryptoAlgorithm WebScriptBindings::normalizeCryptoAlgorithm(v8::Handle<v8::Object> algorithmObject, AlgorithmOperation operation, int* exceptionCode, WebString* errorDetails, v8::Isolate* isolate)
+{
+ Dictionary algorithmDictionary = Dictionary(algorithmObject, isolate);
+ if (!algorithmDictionary.isUndefinedOrNull() && !algorithmDictionary.isObject())
+ return WebCryptoAlgorithm();
+ WebCryptoAlgorithm algorithm;
+ AlgorithmError error;
+ if (!normalizeAlgorithm(algorithmDictionary, operation, algorithm, &error)) {
+ *exceptionCode = webCryptoErrorToExceptionCode(error.errorType);
+ *errorDetails = error.errorDetails;
+ return WebCryptoAlgorithm();
+ }
+
+ return algorithm;
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698