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

Unified Diff: Source/modules/crypto/CryptoResultImpl.cpp

Issue 338993002: [webcrypto] exportKey() now returns dictionary when format='jwk' (CL 2 of 2). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase and fix rsa-oaep-key-manipulation.html 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
« no previous file with comments | « Source/modules/crypto/CryptoResultImpl.h ('k') | Source/platform/CryptoResult.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/crypto/CryptoResultImpl.cpp
diff --git a/Source/modules/crypto/CryptoResultImpl.cpp b/Source/modules/crypto/CryptoResultImpl.cpp
index 3870fa7f9f5ac5597718894e163be1e004990d13..84d98137f1bafaf0433024db9b5f1a901de2696f 100644
--- a/Source/modules/crypto/CryptoResultImpl.cpp
+++ b/Source/modules/crypto/CryptoResultImpl.cpp
@@ -115,6 +115,24 @@ public:
delete this;
}
+ void completeWithJson(const char* utf8Data, unsigned length)
+ {
+ ScriptState* scriptState = m_promiseResolver->scriptState();
+ ScriptState::Scope scope(scriptState);
+
+ v8::Handle<v8::String> jsonString = v8::String::NewFromUtf8(scriptState->isolate(), utf8Data, v8::String::kInternalizedString, length);
+
+ v8::TryCatch exceptionCatcher;
+ v8::Handle<v8::Value> jsonDictionary = v8::JSON::Parse(jsonString);
+ if (exceptionCatcher.HasCaught() || jsonDictionary.IsEmpty()) {
+ ASSERT_NOT_REACHED();
+ m_promiseResolver->reject(DOMException::create(OperationError, "Failed inflating JWK JSON to object"));
+ } else {
+ m_promiseResolver->resolve(jsonDictionary);
+ }
+ delete this;
+ }
+
void completeWithBoolean(bool b)
{
m_promiseResolver->resolve(b);
@@ -192,6 +210,12 @@ void CryptoResultImpl::completeWithBuffer(const blink::WebArrayBuffer& buffer)
m_promiseState->completeWithBuffer(buffer);
}
+void CryptoResultImpl::completeWithJson(const char* utf8Data, unsigned length)
+{
+ if (m_promiseState)
+ m_promiseState->completeWithJson(utf8Data, length);
+}
+
void CryptoResultImpl::completeWithBoolean(bool b)
{
if (m_promiseState)
« no previous file with comments | « Source/modules/crypto/CryptoResultImpl.h ('k') | Source/platform/CryptoResult.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698