Index: components/os_crypt/key_storage_linux.h |
diff --git a/components/os_crypt/key_storage_linux.h b/components/os_crypt/key_storage_linux.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c6658a5f7c6f3e841feac334b2ff02529777175b |
--- /dev/null |
+++ b/components/os_crypt/key_storage_linux.h |
@@ -0,0 +1,52 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef COMPONENTS_OS_CRYPT_KEY_STORAGE_LINUX_H_ |
+#define COMPONENTS_OS_CRYPT_KEY_STORAGE_LINUX_H_ |
+ |
+#include <memory> |
+#include <string> |
+ |
+#include "base/macros.h" |
+ |
vabr (Chromium)
2016/05/13 15:10:18
nit: Normally, code in components is in a namespac
cfroussios
2016/05/13 17:09:11
Acknowledged.
|
+class KeyStorage { |
+ public: |
+ KeyStorage() = default; |
+ virtual ~KeyStorage() = default; |
+ |
+ // Gets the encryption key from the OS password-managing library. If a key is |
+ // not found, a new key will be generated, stored and returned. |
+ virtual std::string GetKey() = 0; |
+ |
+ // Load the service. False is returned if the service is not available. |
+ virtual bool Init() = 0; |
+ |
+ // Tries to load available services. Returns the first that succeeds or |
vabr (Chromium)
2016/05/13 15:10:18
nit: Please be careful with calling stuff a "servi
cfroussios
2016/05/13 17:09:11
Done.
|
+ // null if none succeed. |
+ static std::unique_ptr<KeyStorage> FindService(); |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(KeyStorage); |
+}; |
+ |
+class KeyStorageLibsecret : public KeyStorage { |
vabr (Chromium)
2016/05/13 15:10:18
Please separate the implementations of KeyStorage
cfroussios
2016/05/13 17:09:11
Specifically on the separation of mock from produc
|
+ public: |
+ std::string GetKey() override; |
vabr (Chromium)
2016/05/13 15:10:18
nit: We usually prefix the block with overrides wi
cfroussios
2016/05/13 17:09:12
Done.
|
+ bool Init() override; |
+}; |
+ |
+class KeyStorageMock : public KeyStorage { |
+ public: |
+ explicit KeyStorageMock(std::string in_key = ""); |
vabr (Chromium)
2016/05/13 15:10:18
Also, whenever you need to initialize an empty str
vabr (Chromium)
2016/05/13 15:10:18
Please use 2 constructors instead of the default a
cfroussios
2016/05/13 17:09:11
Done.
cfroussios
2016/05/13 17:09:11
Done.
|
+ |
+ std::string GetKey() override; |
vabr (Chromium)
2016/05/13 15:10:18
// KeyStorage
(See above why.)
cfroussios
2016/05/13 17:09:11
Done.
|
+ bool Init() override; |
+ |
+ void ResetTo(std::string); |
vabr (Chromium)
2016/05/13 15:10:18
nit: Please name the argument.
cfroussios
2016/05/13 17:09:12
Done.
|
+ |
+ private: |
+ std::string key; |
vabr (Chromium)
2016/05/13 15:10:18
nit: Trailing underscore: key_
cfroussios
2016/05/13 17:09:11
Done.
|
+}; |
+ |
+#endif // COMPONENTS_OS_CRYPT_KEY_STORAGE_LINUX_H_ |