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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/modules/crypto/CryptoResultImpl.h ('k') | Source/platform/CryptoResult.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 m_promiseResolver->reject(DOMException::create(webCryptoErrorToException Code(errorType), errorDetails)); 108 m_promiseResolver->reject(DOMException::create(webCryptoErrorToException Code(errorType), errorDetails));
109 delete this; 109 delete this;
110 } 110 }
111 111
112 void completeWithBuffer(const blink::WebArrayBuffer& buffer) 112 void completeWithBuffer(const blink::WebArrayBuffer& buffer)
113 { 113 {
114 m_promiseResolver->resolve(PassRefPtr<ArrayBuffer>(buffer)); 114 m_promiseResolver->resolve(PassRefPtr<ArrayBuffer>(buffer));
115 delete this; 115 delete this;
116 } 116 }
117 117
118 void completeWithJson(const char* utf8Data, unsigned length)
119 {
120 ScriptState* scriptState = m_promiseResolver->scriptState();
121 ScriptState::Scope scope(scriptState);
122
123 v8::Handle<v8::String> jsonString = v8::String::NewFromUtf8(scriptState- >isolate(), utf8Data, v8::String::kInternalizedString, length);
124
125 v8::TryCatch exceptionCatcher;
126 v8::Handle<v8::Value> jsonDictionary = v8::JSON::Parse(jsonString);
127 if (exceptionCatcher.HasCaught() || jsonDictionary.IsEmpty()) {
128 ASSERT_NOT_REACHED();
129 m_promiseResolver->reject(DOMException::create(OperationError, "Fail ed inflating JWK JSON to object"));
130 } else {
131 m_promiseResolver->resolve(jsonDictionary);
132 }
133 delete this;
134 }
135
118 void completeWithBoolean(bool b) 136 void completeWithBoolean(bool b)
119 { 137 {
120 m_promiseResolver->resolve(b); 138 m_promiseResolver->resolve(b);
121 delete this; 139 delete this;
122 } 140 }
123 141
124 void completeWithKey(const blink::WebCryptoKey& key) 142 void completeWithKey(const blink::WebCryptoKey& key)
125 { 143 {
126 m_promiseResolver->resolve(Key::create(key)); 144 m_promiseResolver->resolve(Key::create(key));
127 delete this; 145 delete this;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 if (m_promiseState) 203 if (m_promiseState)
186 m_promiseState->completeWithError(errorType, errorDetails); 204 m_promiseState->completeWithError(errorType, errorDetails);
187 } 205 }
188 206
189 void CryptoResultImpl::completeWithBuffer(const blink::WebArrayBuffer& buffer) 207 void CryptoResultImpl::completeWithBuffer(const blink::WebArrayBuffer& buffer)
190 { 208 {
191 if (m_promiseState) 209 if (m_promiseState)
192 m_promiseState->completeWithBuffer(buffer); 210 m_promiseState->completeWithBuffer(buffer);
193 } 211 }
194 212
213 void CryptoResultImpl::completeWithJson(const char* utf8Data, unsigned length)
214 {
215 if (m_promiseState)
216 m_promiseState->completeWithJson(utf8Data, length);
217 }
218
195 void CryptoResultImpl::completeWithBoolean(bool b) 219 void CryptoResultImpl::completeWithBoolean(bool b)
196 { 220 {
197 if (m_promiseState) 221 if (m_promiseState)
198 m_promiseState->completeWithBoolean(b); 222 m_promiseState->completeWithBoolean(b);
199 } 223 }
200 224
201 void CryptoResultImpl::completeWithKey(const blink::WebCryptoKey& key) 225 void CryptoResultImpl::completeWithKey(const blink::WebCryptoKey& key)
202 { 226 {
203 if (m_promiseState) 227 if (m_promiseState)
204 m_promiseState->completeWithKey(key); 228 m_promiseState->completeWithKey(key);
205 } 229 }
206 230
207 void CryptoResultImpl::completeWithKeyPair(const blink::WebCryptoKey& publicKey, const blink::WebCryptoKey& privateKey) 231 void CryptoResultImpl::completeWithKeyPair(const blink::WebCryptoKey& publicKey, const blink::WebCryptoKey& privateKey)
208 { 232 {
209 if (m_promiseState) 233 if (m_promiseState)
210 m_promiseState->completeWithKeyPair(publicKey, privateKey); 234 m_promiseState->completeWithKeyPair(publicKey, privateKey);
211 } 235 }
212 236
213 CryptoResultImpl::CryptoResultImpl(ScriptState* scriptState) 237 CryptoResultImpl::CryptoResultImpl(ScriptState* scriptState)
214 : m_promiseState(PromiseState::create(scriptState)) 238 : m_promiseState(PromiseState::create(scriptState))
215 { 239 {
216 } 240 }
217 241
218 ScriptPromise CryptoResultImpl::promise() 242 ScriptPromise CryptoResultImpl::promise()
219 { 243 {
220 return m_promiseState->promise(); 244 return m_promiseState->promise();
221 } 245 }
222 246
223 } // namespace WebCore 247 } // namespace WebCore
OLDNEW
« 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