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

Unified Diff: Source/web/WebCryptoNormalize.cpp

Issue 295423004: Expose WebCrypto's algorithm normalization. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressed comments. 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 side-by-side diff with in-line comments
Download patch
Index: Source/web/WebCryptoNormalize.cpp
diff --git a/Source/web/WebSelector.cpp b/Source/web/WebCryptoNormalize.cpp
similarity index 64%
copy from Source/web/WebSelector.cpp
copy to Source/web/WebCryptoNormalize.cpp
index 939cb8a7b12e7a14376a7637c1bdcd1753eac7f5..f05f30e318752cf6c75505d2a8927331f5e46fab 100644
--- a/Source/web/WebSelector.cpp
+++ b/Source/web/WebCryptoNormalize.cpp
@@ -29,29 +29,34 @@
*/
#include "config.h"
-#include "public/web/WebSelector.h"
+#include "public/web/WebCryptoNormalize.h"
-#include "core/css/CSSSelectorList.h"
-#include "core/css/parser/BisonCSSParser.h"
+#include "bindings/v8/Dictionary.h"
+#include "modules/crypto/CryptoResultImpl.h"
+#include "modules/crypto/NormalizeAlgorithm.h"
+#include "platform/CryptoResult.h"
#include "public/platform/WebString.h"
+#include <v8.h>
using namespace WebCore;
namespace blink {
-WebString canonicalizeSelector(WebString webSelector, WebSelectorType restriction)
+
+WebCryptoAlgorithm normalizeCryptoAlgorithm(v8::Handle<v8::Object> algorithmObject, WebCryptoOperation operation, int* exceptionCode, WebString* errorDetails, v8::Isolate* isolate)
{
- BisonCSSParser parser(strictCSSParserContext());
- CSSSelectorList selectorList;
- parser.parseSelector(webSelector, selectorList);
-
- if (restriction == WebSelectorTypeCompound) {
- for (const CSSSelector* selector = selectorList.first(); selector; selector = selectorList.next(*selector)) {
- if (!selector->isCompound())
- return WebString();
- }
+ WebCore::Dictionary algorithmDictionary(algorithmObject, isolate);
+ if (!algorithmDictionary.isUndefinedOrNull() && !algorithmDictionary.isObject())
+ return WebCryptoAlgorithm();
+ WebCryptoAlgorithm algorithm;
+ WebCore::AlgorithmError error;
+ if (!normalizeAlgorithm(algorithmDictionary, operation, algorithm, &error)) {
+ *exceptionCode = WebCore::webCryptoErrorToExceptionCode(error.errorType);
+ *errorDetails = error.errorDetails;
+ return WebCryptoAlgorithm();
}
- return selectorList.selectorsText();
+
+ return algorithm;
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698