| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/hash_tables.h" | 8 #include "base/hash_tables.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "chrome/browser/chromeos/cros/cros_library.h" | 10 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 } | 155 } |
| 156 | 156 |
| 157 void TpmCanAttemptOwnership() { | 157 void TpmCanAttemptOwnership() { |
| 158 chromeos::CryptohomeTpmCanAttemptOwnership(); | 158 chromeos::CryptohomeTpmCanAttemptOwnership(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void TpmClearStoredPassword() { | 161 void TpmClearStoredPassword() { |
| 162 chromeos::CryptohomeTpmClearStoredPassword(); | 162 chromeos::CryptohomeTpmClearStoredPassword(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 bool InstallAttributesGet(const std::string& name, std::string* value) { |
| 166 char* local_value; |
| 167 bool done = |
| 168 chromeos::CryptohomeInstallAttributesGet(name.c_str(), &local_value); |
| 169 if (done) { |
| 170 *value = local_value; |
| 171 chromeos::CryptohomeFreeString(local_value); |
| 172 } |
| 173 return done; |
| 174 } |
| 175 |
| 176 bool InstallAttributesSet(const std::string& name, const std::string& value) { |
| 177 return chromeos::CryptohomeInstallAttributesSet(name.c_str(), |
| 178 value.c_str()); |
| 179 } |
| 180 |
| 181 int InstallAttributesCount() { |
| 182 return chromeos::CryptohomeInstallAttributesCount(); |
| 183 } |
| 184 |
| 185 bool InstallAttributesFinalize() { |
| 186 return chromeos::CryptohomeInstallAttributesFinalize(); |
| 187 } |
| 188 |
| 189 bool InstallAttributesIsReady() { |
| 190 return chromeos::CryptohomeInstallAttributesIsReady(); |
| 191 } |
| 192 |
| 193 bool InstallAttributesIsSecure() { |
| 194 return chromeos::CryptohomeInstallAttributesIsSecure(); |
| 195 } |
| 196 |
| 197 bool InstallAttributesIsInvalid() { |
| 198 return chromeos::CryptohomeInstallAttributesIsInvalid(); |
| 199 } |
| 200 |
| 201 bool InstallAttributesIsFirstInstall() { |
| 202 return chromeos::CryptohomeInstallAttributesIsFirstInstall(); |
| 203 } |
| 204 |
| 165 private: | 205 private: |
| 166 static void Handler(const chromeos::CryptohomeAsyncCallStatus& event, | 206 static void Handler(const chromeos::CryptohomeAsyncCallStatus& event, |
| 167 void* cryptohome_library) { | 207 void* cryptohome_library) { |
| 168 CryptohomeLibraryImpl* library = | 208 CryptohomeLibraryImpl* library = |
| 169 reinterpret_cast<CryptohomeLibraryImpl*>(cryptohome_library); | 209 reinterpret_cast<CryptohomeLibraryImpl*>(cryptohome_library); |
| 170 library->Dispatch(event); | 210 library->Dispatch(event); |
| 171 } | 211 } |
| 172 | 212 |
| 173 void Init() { | 213 void Init() { |
| 174 cryptohome_connection_ = chromeos::CryptohomeMonitorSession(&Handler, this); | 214 cryptohome_connection_ = chromeos::CryptohomeMonitorSession(&Handler, this); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 | 365 |
| 326 bool TpmGetPassword(std::string* password) { | 366 bool TpmGetPassword(std::string* password) { |
| 327 *password = "Stub-TPM-password"; | 367 *password = "Stub-TPM-password"; |
| 328 return true; | 368 return true; |
| 329 } | 369 } |
| 330 | 370 |
| 331 void TpmCanAttemptOwnership() {} | 371 void TpmCanAttemptOwnership() {} |
| 332 | 372 |
| 333 void TpmClearStoredPassword() {} | 373 void TpmClearStoredPassword() {} |
| 334 | 374 |
| 375 bool InstallAttributesGet(const std::string& name, std::string* value) { |
| 376 if (install_attrs_.find(name) != install_attrs_.end()) { |
| 377 *value = install_attrs_[name]; |
| 378 return true; |
| 379 } |
| 380 return false; |
| 381 } |
| 382 |
| 383 bool InstallAttributesSet(const std::string& name, const std::string& value) { |
| 384 install_attrs_[name] = value; |
| 385 return true; |
| 386 } |
| 387 |
| 388 int InstallAttributesCount() { |
| 389 return install_attrs_.size(); |
| 390 } |
| 391 |
| 392 bool InstallAttributesFinalize() { |
| 393 locked_ = true; |
| 394 return true; |
| 395 } |
| 396 |
| 397 bool InstallAttributesIsReady() { |
| 398 return true; |
| 399 } |
| 400 |
| 401 bool InstallAttributesIsSecure() { |
| 402 return locked_; |
| 403 } |
| 404 |
| 405 bool InstallAttributesIsInvalid() { |
| 406 return false; |
| 407 } |
| 408 |
| 409 bool InstallAttributesIsFirstInstall() { |
| 410 return false; |
| 411 } |
| 412 |
| 335 private: | 413 private: |
| 336 static void DoStubCallback(Delegate* callback) { | 414 static void DoStubCallback(Delegate* callback) { |
| 337 if (callback) | 415 if (callback) |
| 338 callback->OnComplete(true, kCryptohomeMountErrorNone); | 416 callback->OnComplete(true, kCryptohomeMountErrorNone); |
| 339 } | 417 } |
| 418 |
| 419 std::map<std::string, std::string> install_attrs_; |
| 420 bool locked_; |
| 340 DISALLOW_COPY_AND_ASSIGN(CryptohomeLibraryStubImpl); | 421 DISALLOW_COPY_AND_ASSIGN(CryptohomeLibraryStubImpl); |
| 341 }; | 422 }; |
| 342 | 423 |
| 343 // static | 424 // static |
| 344 CryptohomeLibrary* CryptohomeLibrary::GetImpl(bool stub) { | 425 CryptohomeLibrary* CryptohomeLibrary::GetImpl(bool stub) { |
| 345 if (stub) | 426 if (stub) |
| 346 return new CryptohomeLibraryStubImpl(); | 427 return new CryptohomeLibraryStubImpl(); |
| 347 else | 428 else |
| 348 return new CryptohomeLibraryImpl(); | 429 return new CryptohomeLibraryImpl(); |
| 349 } | 430 } |
| 350 | 431 |
| 351 } // namespace chromeos | 432 } // namespace chromeos |
| OLD | NEW |