| Index: chrome/browser/chromeos/cros/cryptohome_library.cc
|
| diff --git a/chrome/browser/chromeos/cros/cryptohome_library.cc b/chrome/browser/chromeos/cros/cryptohome_library.cc
|
| index 6ac8432a9749b425ffcf67875f266732a57adf5f..dcdf4566008d3819acc4b9d15cd8d02e5dae46bd 100644
|
| --- a/chrome/browser/chromeos/cros/cryptohome_library.cc
|
| +++ b/chrome/browser/chromeos/cros/cryptohome_library.cc
|
| @@ -9,41 +9,100 @@
|
|
|
| namespace chromeos {
|
|
|
| -bool CryptohomeLibraryImpl::CheckKey(const std::string& user_email,
|
| - const std::string& passhash) {
|
| - return chromeos::CryptohomeCheckKey(user_email.c_str(), passhash.c_str());
|
| -}
|
| +// This class handles the interaction with the ChromeOS cryptohome library APIs.
|
| +class CryptohomeLibraryImpl: public CryptohomeLibrary {
|
| + public:
|
| + CryptohomeLibraryImpl() {}
|
| + virtual ~CryptohomeLibraryImpl() {}
|
|
|
| -bool CryptohomeLibraryImpl::MigrateKey(const std::string& user_email,
|
| - const std::string& old_hash,
|
| - const std::string& new_hash) {
|
| - return chromeos::CryptohomeMigrateKey(user_email.c_str(),
|
| - old_hash.c_str(),
|
| - new_hash.c_str());
|
| -}
|
| + bool CheckKey(const std::string& user_email, const std::string& passhash) {
|
| + return chromeos::CryptohomeCheckKey(user_email.c_str(), passhash.c_str());
|
| + }
|
|
|
| -bool CryptohomeLibraryImpl::Remove(const std::string& user_email) {
|
| - return chromeos::CryptohomeRemove(user_email.c_str());
|
| -}
|
| + bool MigrateKey(const std::string& user_email,
|
| + const std::string& old_hash,
|
| + const std::string& new_hash) {
|
| + return chromeos::CryptohomeMigrateKey(user_email.c_str(), old_hash.c_str(),
|
| + new_hash.c_str());
|
| + }
|
|
|
| -bool CryptohomeLibraryImpl::Mount(const std::string& user_email,
|
| - const std::string& passhash,
|
| - int* error_code) {
|
| - return chromeos::CryptohomeMountAllowFail(user_email.c_str(),
|
| - passhash.c_str(),
|
| - error_code);
|
| -}
|
| + bool Remove(const std::string& user_email) {
|
| + return chromeos::CryptohomeRemove(user_email.c_str());
|
| + }
|
|
|
| -bool CryptohomeLibraryImpl::MountForBwsi(int* error_code) {
|
| - return chromeos::CryptohomeMountGuest(error_code);
|
| -}
|
| + bool Mount(const std::string& user_email,
|
| + const std::string& passhash,
|
| + int* error_code) {
|
| + return chromeos::CryptohomeMountAllowFail(user_email.c_str(),
|
| + passhash.c_str(), error_code);
|
| + }
|
|
|
| -bool CryptohomeLibraryImpl::IsMounted() {
|
| - return chromeos::CryptohomeIsMounted();
|
| -}
|
| + bool MountForBwsi(int* error_code) {
|
| + return chromeos::CryptohomeMountGuest(error_code);
|
| + }
|
| +
|
| + bool IsMounted() {
|
| + return chromeos::CryptohomeIsMounted();
|
| + }
|
| +
|
| + CryptohomeBlob GetSystemSalt() {
|
| + return chromeos::CryptohomeGetSystemSalt();
|
| + }
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(CryptohomeLibraryImpl);
|
| +};
|
| +
|
| +class CryptohomeLibraryStubImpl: public CryptohomeLibrary {
|
| + public:
|
| + CryptohomeLibraryStubImpl() {}
|
| + virtual ~CryptohomeLibraryStubImpl() {}
|
| +
|
| + bool CheckKey(const std::string& user_email, const std::string& passhash) {
|
| + return true;
|
| + }
|
| +
|
| + bool MigrateKey(const std::string& user_email,
|
| + const std::string& old_hash,
|
| + const std::string& new_hash) {
|
| + return true;
|
| + }
|
| +
|
| + bool Remove(const std::string& user_email) {
|
| + return true;
|
| + }
|
| +
|
| + bool Mount(const std::string& user_email,
|
| + const std::string& passhash,
|
| + int* error_code) {
|
| + return true;
|
| + }
|
| +
|
| + bool MountForBwsi(int* error_code) {
|
| + return true;
|
| + }
|
| +
|
| + bool IsMounted() {
|
| + return true;
|
| + }
|
| +
|
| + CryptohomeBlob GetSystemSalt() {
|
| + CryptohomeBlob salt = CryptohomeBlob();
|
| + salt.push_back(0);
|
| + salt.push_back(0);
|
| + return salt;
|
| + }
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(CryptohomeLibraryStubImpl);
|
| +};
|
|
|
| -CryptohomeBlob CryptohomeLibraryImpl::GetSystemSalt() {
|
| - return chromeos::CryptohomeGetSystemSalt();
|
| +// static
|
| +CryptohomeLibrary* CryptohomeLibrary::GetImpl(bool stub) {
|
| + if (stub)
|
| + return new CryptohomeLibraryStubImpl();
|
| + else
|
| + return new CryptohomeLibraryImpl();
|
| }
|
|
|
| -} // namespace chromeos
|
| +} // namespace chromeos
|
|
|