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

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: 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 9abbd577dfd17a6cd27ee2c64089114ffc58c1d5..9feeb3d57a3017540df6cafe3e0a3cafadf21a46 100644
--- a/Source/modules/crypto/CryptoResultImpl.cpp
+++ b/Source/modules/crypto/CryptoResultImpl.cpp
@@ -116,6 +116,26 @@ void CryptoResultImpl::completeWithBuffer(const blink::WebArrayBuffer& buffer)
m_resolver->resolve(PassRefPtr<ArrayBuffer>(buffer));
}
+void CryptoResultImpl::completeWithJson(const char* utf8Data, unsigned length)
+{
+ if (m_resolver) {
+ ScriptState* scriptState = m_resolver->scriptState();
+ ScriptState::Scope scope(scriptState);
+
+ v8::Handle<v8::String> jsonString = v8AtomicString(scriptState->isolate(), utf8Data, length);
abarth-chromium 2014/06/17 05:03:05 Why atomic?
eroman 2014/06/17 17:58:02 Thanks for pointing this out! I had a misundersta
eroman 2014/06/17 18:06:56 Done.
+
+ v8::TryCatch exceptionCatcher;
+ v8::Handle<v8::Value> jsonDictionary = v8::JSON::Parse(jsonString);
+ if (exceptionCatcher.HasCaught() || jsonDictionary.IsEmpty()) {
+ ASSERT_NOT_REACHED();
+ m_resolver->reject(DOMException::create(OperationError, "Failed inflating JWK JSON to object"));
+ return;
+ }
+
+ m_resolver->resolve(jsonDictionary);
+ }
+}
+
void CryptoResultImpl::completeWithBoolean(bool b)
{
if (m_resolver)
« 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