Adds shutdown when FrameTreeServer goes away
[chromium-blink-merge.git] / components / os_crypt / os_crypt.h
bloba75ccf9a882b05c3dde9e7a161b19dab5dee7ff2
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_OS_CRYPT_OS_CRYPT_H_
6 #define COMPONENTS_OS_CRYPT_OS_CRYPT_H_
8 #include <string>
10 #include "base/strings/string16.h"
12 // The OSCrypt class gives access to simple encryption and decryption of
13 // strings. Note that on Mac, access to the system Keychain is required and
14 // these calls can block the current thread to collect user input.
15 class OSCrypt {
16 public:
17 // Encrypt a string16. The output (second argument) is really an array of
18 // bytes, but we're passing it back as a std::string.
19 static bool EncryptString16(const base::string16& plaintext,
20 std::string* ciphertext);
22 // Decrypt an array of bytes obtained with EncryptString16 back into a
23 // string16. Note that the input (first argument) is a std::string, so you
24 // need to first get your (binary) data into a string.
25 static bool DecryptString16(const std::string& ciphertext,
26 base::string16* plaintext);
28 // Encrypt a string.
29 static bool EncryptString(const std::string& plaintext,
30 std::string* ciphertext);
32 // Decrypt an array of bytes obtained with EnctryptString back into a string.
33 // Note that the input (first argument) is a std::string, so you need to first
34 // get your (binary) data into a string.
35 static bool DecryptString(const std::string& ciphertext,
36 std::string* plaintext);
38 #if defined(OS_MACOSX)
39 // For unit testing purposes we instruct the Encryptor to use a mock Keychain
40 // on the Mac. The default is to use the real Keychain.
41 static void UseMockKeychain(bool use_mock);
42 #endif
44 private:
45 DISALLOW_IMPLICIT_CONSTRUCTORS(OSCrypt);
48 #endif // COMPONENTS_OS_CRYPT_OS_CRYPT_H_