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

Side by Side Diff: Source/modules/crypto/NormalizeAlgorithm.cpp

Issue 19724003: Revert "Transition modules/** to use ExceptionState" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 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/NormalizeAlgorithm.h ('k') | Source/modules/crypto/SubtleCrypto.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 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "modules/crypto/NormalizeAlgorithm.h" 32 #include "modules/crypto/NormalizeAlgorithm.h"
33 33
34 #include "bindings/v8/Dictionary.h" 34 #include "bindings/v8/Dictionary.h"
35 #include "bindings/v8/ExceptionState.h"
36 #include "core/dom/ExceptionCode.h" 35 #include "core/dom/ExceptionCode.h"
37 #include "public/platform/WebCryptoAlgorithm.h" 36 #include "public/platform/WebCryptoAlgorithm.h"
38 #include "public/platform/WebCryptoAlgorithmParams.h" 37 #include "public/platform/WebCryptoAlgorithmParams.h"
39 #include "wtf/ArrayBuffer.h" 38 #include "wtf/ArrayBuffer.h"
40 #include "wtf/ArrayBufferView.h" 39 #include "wtf/ArrayBufferView.h"
41 #include "wtf/HashMap.h" 40 #include "wtf/HashMap.h"
42 #include "wtf/Uint8Array.h" 41 #include "wtf/Uint8Array.h"
43 #include "wtf/Vector.h" 42 #include "wtf/Vector.h"
44 #include "wtf/text/StringHash.h" 43 #include "wtf/text/StringHash.h"
45 44
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 } 186 }
188 ASSERT_NOT_REACHED(); 187 ASSERT_NOT_REACHED();
189 return nullptr; 188 return nullptr;
190 } 189 }
191 190
192 } // namespace 191 } // namespace
193 192
194 // FIXME: Throw the correct exception types! 193 // FIXME: Throw the correct exception types!
195 // This implementation corresponds with: 194 // This implementation corresponds with:
196 // http://www.w3.org/TR/WebCryptoAPI/#algorithm-normalizing-rules 195 // http://www.w3.org/TR/WebCryptoAPI/#algorithm-normalizing-rules
197 bool normalizeAlgorithm(const Dictionary& raw, AlgorithmOperation op, WebKit::We bCryptoAlgorithm& algorithm, ExceptionState& es) 196 bool normalizeAlgorithm(const Dictionary& raw, AlgorithmOperation op, WebKit::We bCryptoAlgorithm& algorithm, ExceptionCode& ec)
198 { 197 {
199 String algorithmName; 198 String algorithmName;
200 if (!raw.get("name", algorithmName)) { 199 if (!raw.get("name", algorithmName)) {
201 es.throwDOMException(NotSupportedError); 200 ec = NotSupportedError;
202 return false; 201 return false;
203 } 202 }
204 203
205 if (!algorithmName.containsOnlyASCII()) { 204 if (!algorithmName.containsOnlyASCII()) {
206 es.throwDOMException(SyntaxError); 205 ec = SyntaxError;
207 return false; 206 return false;
208 } 207 }
209 208
210 const AlgorithmInfo* info = AlgorithmRegistry::lookupAlgorithmByName(algorit hmName); 209 const AlgorithmInfo* info = AlgorithmRegistry::lookupAlgorithmByName(algorit hmName);
211 if (!info) { 210 if (!info) {
212 es.throwDOMException(NotSupportedError); 211 ec = NotSupportedError;
213 return false; 212 return false;
214 } 213 }
215 214
216 if (info->paramsForOperation[op] == UnsupportedOp) { 215 if (info->paramsForOperation[op] == UnsupportedOp) {
217 es.throwDOMException(NotSupportedError); 216 ec = NotSupportedError;
218 return false; 217 return false;
219 } 218 }
220 219
221 WebKit::WebCryptoAlgorithmParamsType paramsType = static_cast<WebKit::WebCry ptoAlgorithmParamsType>(info->paramsForOperation[op]); 220 WebKit::WebCryptoAlgorithmParamsType paramsType = static_cast<WebKit::WebCry ptoAlgorithmParamsType>(info->paramsForOperation[op]);
222 OwnPtr<WebKit::WebCryptoAlgorithmParams> params = parseAlgorithmParams(raw, paramsType); 221 OwnPtr<WebKit::WebCryptoAlgorithmParams> params = parseAlgorithmParams(raw, paramsType);
223 222
224 if (!params && paramsType != WebKit::WebCryptoAlgorithmParamsTypeNone) { 223 if (!params && paramsType != WebKit::WebCryptoAlgorithmParamsTypeNone) {
225 es.throwDOMException(NotSupportedError); 224 ec = NotSupportedError;
226 return false; 225 return false;
227 } 226 }
228 227
229 algorithm = WebKit::WebCryptoAlgorithm(info->algorithmId, info->algorithmNam e, params.release()); 228 algorithm = WebKit::WebCryptoAlgorithm(info->algorithmId, info->algorithmNam e, params.release());
230 return true; 229 return true;
231 } 230 }
232 231
233 } // namespace WebCore 232 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/crypto/NormalizeAlgorithm.h ('k') | Source/modules/crypto/SubtleCrypto.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698