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

Side by Side Diff: content/child/webcrypto/webcrypto_impl.cc

Issue 243433006: [webcrypto] Set the error type for failures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/child/webcrypto/webcrypto_impl.h" 5 #include "content/child/webcrypto/webcrypto_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "content/child/webcrypto/crypto_data.h" 9 #include "content/child/webcrypto/crypto_data.h"
10 #include "content/child/webcrypto/shared_crypto.h" 10 #include "content/child/webcrypto/shared_crypto.h"
11 #include "content/child/webcrypto/status.h" 11 #include "content/child/webcrypto/status.h"
12 #include "content/child/webcrypto/webcrypto_util.h" 12 #include "content/child/webcrypto/webcrypto_util.h"
13 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" 13 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h"
14 #include "third_party/WebKit/public/platform/WebString.h" 14 #include "third_party/WebKit/public/platform/WebString.h"
15 15
16 namespace content { 16 namespace content {
17 17
18 using webcrypto::Status; 18 using webcrypto::Status;
19 19
20 namespace { 20 namespace {
21 21
22 void CompleteWithError(const Status& status, blink::WebCryptoResult* result) { 22 void CompleteWithError(const Status& status, blink::WebCryptoResult* result) {
23 DCHECK(status.IsError()); 23 DCHECK(status.IsError());
24
25 #if defined(WEBCRYPTO_HAS_ERROR_TYPE)
26 result->completeWithError(status.error_type(),
27 blink::WebString::fromUTF8(status.ToString()));
28 #else
29 // TODO(eroman): Delete once Blink changes have rolled into Chromium.
24 if (status.HasErrorDetails()) 30 if (status.HasErrorDetails())
25 result->completeWithError(blink::WebString::fromUTF8(status.ToString())); 31 result->completeWithError(blink::WebString::fromUTF8(status.ToString()));
26 else 32 else
27 result->completeWithError(); 33 result->completeWithError();
34 #endif
28 } 35 }
29 36
30 bool IsAlgorithmAsymmetric(const blink::WebCryptoAlgorithm& algorithm) { 37 bool IsAlgorithmAsymmetric(const blink::WebCryptoAlgorithm& algorithm) {
31 // TODO(padolph): include all other asymmetric algorithms once they are 38 // TODO(padolph): include all other asymmetric algorithms once they are
32 // defined, e.g. EC and DH. 39 // defined, e.g. EC and DH.
33 return (algorithm.id() == blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5 || 40 return (algorithm.id() == blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5 ||
34 algorithm.id() == blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 || 41 algorithm.id() == blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 ||
35 algorithm.id() == blink::WebCryptoAlgorithmIdRsaOaep); 42 algorithm.id() == blink::WebCryptoAlgorithmIdRsaOaep);
36 } 43 }
37 44
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 } 280 }
274 281
275 bool WebCryptoImpl::serializeKeyForClone( 282 bool WebCryptoImpl::serializeKeyForClone(
276 const blink::WebCryptoKey& key, 283 const blink::WebCryptoKey& key,
277 blink::WebVector<unsigned char>& key_data) { 284 blink::WebVector<unsigned char>& key_data) {
278 Status status = webcrypto::SerializeKeyForClone(key, &key_data); 285 Status status = webcrypto::SerializeKeyForClone(key, &key_data);
279 return status.IsSuccess(); 286 return status.IsSuccess();
280 } 287 }
281 288
282 } // namespace content 289 } // namespace content
OLDNEW
« content/child/webcrypto/platform_crypto_nss.cc ('K') | « content/child/webcrypto/status.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698