| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | 5 #include "chrome/browser/chromeos/cros/cryptohome_library.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 virtual ~CryptohomeLibraryImpl() { | 29 virtual ~CryptohomeLibraryImpl() { |
| 30 } | 30 } |
| 31 | 31 |
| 32 virtual bool IsMounted() OVERRIDE { | 32 virtual bool IsMounted() OVERRIDE { |
| 33 bool result = false; | 33 bool result = false; |
| 34 DBusThreadManager::Get()->GetCryptohomeClient()->IsMounted(&result); | 34 DBusThreadManager::Get()->GetCryptohomeClient()->IsMounted(&result); |
| 35 return result; | 35 return result; |
| 36 } | 36 } |
| 37 | 37 |
| 38 virtual bool TpmIsReady() OVERRIDE { | |
| 39 bool result = false; | |
| 40 DBusThreadManager::Get()->GetCryptohomeClient()->TpmIsReady(&result); | |
| 41 return result; | |
| 42 } | |
| 43 | |
| 44 virtual bool TpmIsEnabled() OVERRIDE { | 38 virtual bool TpmIsEnabled() OVERRIDE { |
| 45 bool result = false; | 39 bool result = false; |
| 46 DBusThreadManager::Get()->GetCryptohomeClient()->CallTpmIsEnabledAndBlock( | 40 DBusThreadManager::Get()->GetCryptohomeClient()->CallTpmIsEnabledAndBlock( |
| 47 &result); | 41 &result); |
| 48 return result; | 42 return result; |
| 49 } | 43 } |
| 50 | 44 |
| 51 virtual bool TpmIsOwned() OVERRIDE { | 45 virtual bool TpmIsOwned() OVERRIDE { |
| 52 bool result = false; | 46 bool result = false; |
| 53 DBusThreadManager::Get()->GetCryptohomeClient()->TpmIsOwned(&result); | 47 DBusThreadManager::Get()->GetCryptohomeClient()->TpmIsOwned(&result); |
| 54 return result; | 48 return result; |
| 55 } | 49 } |
| 56 | 50 |
| 57 virtual bool TpmIsBeingOwned() OVERRIDE { | 51 virtual bool TpmIsBeingOwned() OVERRIDE { |
| 58 bool result = false; | 52 bool result = false; |
| 59 DBusThreadManager::Get()->GetCryptohomeClient()->TpmIsBeingOwned(&result); | 53 DBusThreadManager::Get()->GetCryptohomeClient()->TpmIsBeingOwned(&result); |
| 60 return result; | 54 return result; |
| 61 } | 55 } |
| 62 | 56 |
| 63 virtual bool TpmGetPassword(std::string* password) OVERRIDE { | |
| 64 return DBusThreadManager::Get()->GetCryptohomeClient()-> | |
| 65 TpmGetPassword(password); | |
| 66 } | |
| 67 | |
| 68 virtual void TpmCanAttemptOwnership() OVERRIDE { | 57 virtual void TpmCanAttemptOwnership() OVERRIDE { |
| 69 DBusThreadManager::Get()->GetCryptohomeClient()->TpmCanAttemptOwnership(); | 58 DBusThreadManager::Get()->GetCryptohomeClient()->TpmCanAttemptOwnership(); |
| 70 } | 59 } |
| 71 | 60 |
| 72 virtual void TpmClearStoredPassword() OVERRIDE { | 61 virtual void TpmClearStoredPassword() OVERRIDE { |
| 73 DBusThreadManager::Get()->GetCryptohomeClient()->TpmClearStoredPassword(); | 62 DBusThreadManager::Get()->GetCryptohomeClient()->TpmClearStoredPassword(); |
| 74 } | 63 } |
| 75 | 64 |
| 76 virtual bool InstallAttributesGet( | 65 virtual bool InstallAttributesGet( |
| 77 const std::string& name, std::string* value) OVERRIDE { | 66 const std::string& name, std::string* value) OVERRIDE { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 class CryptohomeLibraryStubImpl : public CryptohomeLibrary { | 140 class CryptohomeLibraryStubImpl : public CryptohomeLibrary { |
| 152 public: | 141 public: |
| 153 CryptohomeLibraryStubImpl() | 142 CryptohomeLibraryStubImpl() |
| 154 : locked_(false) {} | 143 : locked_(false) {} |
| 155 virtual ~CryptohomeLibraryStubImpl() {} | 144 virtual ~CryptohomeLibraryStubImpl() {} |
| 156 | 145 |
| 157 virtual bool IsMounted() OVERRIDE { | 146 virtual bool IsMounted() OVERRIDE { |
| 158 return true; | 147 return true; |
| 159 } | 148 } |
| 160 | 149 |
| 161 // Tpm begin ready after 20-th call. | |
| 162 virtual bool TpmIsReady() OVERRIDE { | |
| 163 static int counter = 0; | |
| 164 return ++counter > 20; | |
| 165 } | |
| 166 | |
| 167 virtual bool TpmIsEnabled() OVERRIDE { | 150 virtual bool TpmIsEnabled() OVERRIDE { |
| 168 return true; | 151 return true; |
| 169 } | 152 } |
| 170 | 153 |
| 171 virtual bool TpmIsOwned() OVERRIDE { | 154 virtual bool TpmIsOwned() OVERRIDE { |
| 172 return true; | 155 return true; |
| 173 } | 156 } |
| 174 | 157 |
| 175 virtual bool TpmIsBeingOwned() OVERRIDE { | 158 virtual bool TpmIsBeingOwned() OVERRIDE { |
| 176 return true; | 159 return true; |
| 177 } | 160 } |
| 178 | 161 |
| 179 virtual bool TpmGetPassword(std::string* password) OVERRIDE { | |
| 180 *password = "Stub-TPM-password"; | |
| 181 return true; | |
| 182 } | |
| 183 | |
| 184 virtual void TpmCanAttemptOwnership() OVERRIDE {} | 162 virtual void TpmCanAttemptOwnership() OVERRIDE {} |
| 185 | 163 |
| 186 virtual void TpmClearStoredPassword() OVERRIDE {} | 164 virtual void TpmClearStoredPassword() OVERRIDE {} |
| 187 | 165 |
| 188 virtual bool InstallAttributesGet( | 166 virtual bool InstallAttributesGet( |
| 189 const std::string& name, std::string* value) OVERRIDE { | 167 const std::string& name, std::string* value) OVERRIDE { |
| 190 if (install_attrs_.find(name) != install_attrs_.end()) { | 168 if (install_attrs_.find(name) != install_attrs_.end()) { |
| 191 *value = install_attrs_[name]; | 169 *value = install_attrs_[name]; |
| 192 return true; | 170 return true; |
| 193 } | 171 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 CryptohomeLibrary* CryptohomeLibrary::GetImpl(bool stub) { | 212 CryptohomeLibrary* CryptohomeLibrary::GetImpl(bool stub) { |
| 235 CryptohomeLibrary* impl; | 213 CryptohomeLibrary* impl; |
| 236 if (stub) | 214 if (stub) |
| 237 impl = new CryptohomeLibraryStubImpl(); | 215 impl = new CryptohomeLibraryStubImpl(); |
| 238 else | 216 else |
| 239 impl = new CryptohomeLibraryImpl(); | 217 impl = new CryptohomeLibraryImpl(); |
| 240 return impl; | 218 return impl; |
| 241 } | 219 } |
| 242 | 220 |
| 243 } // namespace chromeos | 221 } // namespace chromeos |
| OLD | NEW |