OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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. |
| 4 |
| 5 #ifndef COMPONENTS_OS_CRYPT_OS_CRYPT_MOCKER_LINUX_H_ |
| 6 #define COMPONENTS_OS_CRYPT_OS_CRYPT_MOCKER_LINUX_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "base/strings/string_piece.h" |
| 12 #include "components/os_crypt/key_storage_linux.h" |
| 13 |
| 14 // Holds and serves a password from memory. |
| 15 class OSCryptMockerLinux : public KeyStorageLinux { |
| 16 public: |
| 17 OSCryptMockerLinux() = default; |
| 18 ~OSCryptMockerLinux() override = default; |
| 19 |
| 20 // KeyStorageLinux |
| 21 std::string GetKey() override; |
| 22 |
| 23 // Set the password that OSCryptMockerLinux holds. |
| 24 void ResetTo(base::StringPiece new_key); |
| 25 |
| 26 // Get a pointer to the stored password. OSCryptMockerLinux owns the pointer. |
| 27 std::string* GetKeyPtr(); |
| 28 |
| 29 // Getter for the singleton. |
| 30 static OSCryptMockerLinux* GetInstance(); |
| 31 |
| 32 // Inject the singleton mock into OSCrypt. |
| 33 static void SetUpWithSingleton(); |
| 34 |
| 35 // Restore OSCrypt to its real behaviour. |
| 36 static void TearDown(); |
| 37 |
| 38 protected: |
| 39 // KeyStorageLinux |
| 40 bool Init() override; |
| 41 |
| 42 private: |
| 43 std::string key_; |
| 44 |
| 45 DISALLOW_COPY_AND_ASSIGN(OSCryptMockerLinux); |
| 46 }; |
| 47 |
| 48 #endif // COMPONENTS_OS_CRYPT_OS_CRYPT_MOCKER_LINUX_H_ |
OLD | NEW |