1 // Copyright 2014 The Chromium Authors 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 CRYPTO_SCOPED_TEST_NSS_CHROMEOS_USER_H_ 6 #define CRYPTO_SCOPED_TEST_NSS_CHROMEOS_USER_H_ 7 8 #include <string> 9 10 #include "base/files/scoped_temp_dir.h" 11 #include "crypto/crypto_export.h" 12 13 namespace crypto { 14 15 // Opens a persistent NSS software database in a temporary directory for the 16 // user with |username_hash|. This database will be used for both the user's 17 // public and private slot. 18 class CRYPTO_EXPORT ScopedTestNSSChromeOSUser { 19 public: 20 // Opens the software database and sets the public slot for the user. The 21 // private slot will not be initialized until FinishInit() is called. 22 explicit ScopedTestNSSChromeOSUser(const std::string& username_hash); 23 24 ScopedTestNSSChromeOSUser(const ScopedTestNSSChromeOSUser&) = delete; 25 ScopedTestNSSChromeOSUser& operator=(const ScopedTestNSSChromeOSUser&) = 26 delete; 27 28 ~ScopedTestNSSChromeOSUser(); 29 username_hash()30 std::string username_hash() const { return username_hash_; } constructed_successfully()31 bool constructed_successfully() const { return constructed_successfully_; } 32 33 // Completes initialization of user. Causes any waiting private slot callbacks 34 // to run, see GetPrivateSlotForChromeOSUser(). 35 void FinishInit(); 36 37 private: 38 const std::string username_hash_; 39 base::ScopedTempDir temp_dir_; 40 bool constructed_successfully_; 41 }; 42 43 } // namespace crypto 44 45 #endif // CRYPTO_SCOPED_TEST_NSS_CHROMEOS_USER_H_ 46