Vectorize website settings icons in omnibox
[chromium-blink-merge.git] / components / webcrypto / generate_key_result.h
blob4c2fe203760b5ec96fed819ece692fe9f14ebb10
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_WEBCRYPTO_GENERATE_KEY_RESULT_H_
6 #define COMPONENTS_WEBCRYPTO_GENERATE_KEY_RESULT_H_
8 #include "third_party/WebKit/public/platform/WebCrypto.h"
10 namespace webcrypto {
12 // This is the result object when generating keys. It encapsulates either a
13 // secret key, or a public/private key pair.
14 class GenerateKeyResult {
15 public:
16 enum Type {
17 // An empty (or "null") result.
18 TYPE_NULL,
20 // The result is a secret key, accessible through secret_key()
21 TYPE_SECRET_KEY,
23 // The result is a public/private key pair, accessible through public_key()
24 // and private_key()
25 TYPE_PUBLIC_PRIVATE_KEY_PAIR
28 // Initializes a "null" instance.
29 GenerateKeyResult();
31 Type type() const;
33 const blink::WebCryptoKey& secret_key() const;
34 const blink::WebCryptoKey& public_key() const;
35 const blink::WebCryptoKey& private_key() const;
37 void AssignSecretKey(const blink::WebCryptoKey& key);
38 void AssignKeyPair(const blink::WebCryptoKey& public_key,
39 const blink::WebCryptoKey& private_key);
41 // Sends the key(s) to the Blink result. Should not be called for "null"
42 // results.
43 void Complete(blink::WebCryptoResult* out) const;
45 private:
46 Type type_;
48 blink::WebCryptoKey secret_key_;
49 blink::WebCryptoKey public_key_;
50 blink::WebCryptoKey private_key_;
53 } // namespace webcrypto
55 #endif // COMPONENTS_WEBCRYPTO_GENERATE_KEY_RESULT_H_