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

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: Address comments 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 if (status.HasErrorDetails()) 24
25 result->completeWithError(blink::WebString::fromUTF8(status.ToString())); 25 #if defined(WEBCRYPTO_HAS_ERROR_TYPE)
26 result->completeWithError(status.error_type(),
27 blink::WebString::fromUTF8(status.error_details()));
28 #else
29 // TODO(eroman): Delete once Blink changes have rolled into Chromium.
30 if (!status.error_details().empty())
31 result->completeWithError(
32 blink::WebString::fromUTF8(status.error_details()));
26 else 33 else
27 result->completeWithError(); 34 result->completeWithError();
35 #endif
28 } 36 }
29 37
30 bool IsAlgorithmAsymmetric(const blink::WebCryptoAlgorithm& algorithm) { 38 bool IsAlgorithmAsymmetric(const blink::WebCryptoAlgorithm& algorithm) {
31 // TODO(padolph): include all other asymmetric algorithms once they are 39 // TODO(padolph): include all other asymmetric algorithms once they are
32 // defined, e.g. EC and DH. 40 // defined, e.g. EC and DH.
33 return (algorithm.id() == blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5 || 41 return (algorithm.id() == blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5 ||
34 algorithm.id() == blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 || 42 algorithm.id() == blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 ||
35 algorithm.id() == blink::WebCryptoAlgorithmIdRsaOaep); 43 algorithm.id() == blink::WebCryptoAlgorithmIdRsaOaep);
36 } 44 }
37 45
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 } 281 }
274 282
275 bool WebCryptoImpl::serializeKeyForClone( 283 bool WebCryptoImpl::serializeKeyForClone(
276 const blink::WebCryptoKey& key, 284 const blink::WebCryptoKey& key,
277 blink::WebVector<unsigned char>& key_data) { 285 blink::WebVector<unsigned char>& key_data) {
278 Status status = webcrypto::SerializeKeyForClone(key, &key_data); 286 Status status = webcrypto::SerializeKeyForClone(key, &key_data);
279 return status.IsSuccess(); 287 return status.IsSuccess();
280 } 288 }
281 289
282 } // namespace content 290 } // namespace content
OLDNEW
« content/child/webcrypto/shared_crypto_unittest.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