Index: components/os_crypt/key_storage_mock.cc |
diff --git a/components/os_crypt/key_storage_mock.cc b/components/os_crypt/key_storage_mock.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b485b60f4c4ea888e391ff9f843bc17ed6f7789e |
--- /dev/null |
+++ b/components/os_crypt/key_storage_mock.cc |
@@ -0,0 +1,26 @@ |
+// 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. |
+ |
+#include "components/os_crypt/key_storage_mock.h" |
+ |
+#include "base/base64.h" |
+#include "base/rand_util.h" |
+ |
+std::string KeyStorageMock::GetKey() { |
+ if (key_.empty()) |
+ base::Base64Encode(base::RandBytesAsString(16), &key_); |
+ return key_; |
+} |
+ |
+bool KeyStorageMock::Init() { |
+ return true; |
+} |
+ |
+void KeyStorageMock::ResetTo(base::StringPiece new_key) { |
+ key_ = new_key.as_string(); |
+} |
+ |
+std::string* KeyStorageMock::GetKeyPtr() { |
+ return &key_; |
+} |