OLD | NEW |
1 // Copyright (c) 2011 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" |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 typedef base::hash_map<int, Delegate*> CallbackMap; | 238 typedef base::hash_map<int, Delegate*> CallbackMap; |
239 mutable CallbackMap callback_map_; | 239 mutable CallbackMap callback_map_; |
240 | 240 |
241 void* cryptohome_connection_; | 241 void* cryptohome_connection_; |
242 | 242 |
243 DISALLOW_COPY_AND_ASSIGN(CryptohomeLibraryImpl); | 243 DISALLOW_COPY_AND_ASSIGN(CryptohomeLibraryImpl); |
244 }; | 244 }; |
245 | 245 |
246 class CryptohomeLibraryStubImpl : public CryptohomeLibrary { | 246 class CryptohomeLibraryStubImpl : public CryptohomeLibrary { |
247 public: | 247 public: |
248 CryptohomeLibraryStubImpl() {} | 248 CryptohomeLibraryStubImpl() |
| 249 : locked_(false) {} |
249 virtual ~CryptohomeLibraryStubImpl() {} | 250 virtual ~CryptohomeLibraryStubImpl() {} |
250 | 251 |
251 bool CheckKey(const std::string& user_email, const std::string& passhash) { | 252 bool CheckKey(const std::string& user_email, const std::string& passhash) { |
252 return true; | 253 return true; |
253 } | 254 } |
254 | 255 |
255 bool AsyncCheckKey(const std::string& user_email, | 256 bool AsyncCheckKey(const std::string& user_email, |
256 const std::string& passhash, | 257 const std::string& passhash, |
257 Delegate* callback) { | 258 Delegate* callback) { |
258 BrowserThread::PostTask( | 259 BrowserThread::PostTask( |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 bool InstallAttributesFinalize() { | 393 bool InstallAttributesFinalize() { |
393 locked_ = true; | 394 locked_ = true; |
394 return true; | 395 return true; |
395 } | 396 } |
396 | 397 |
397 bool InstallAttributesIsReady() { | 398 bool InstallAttributesIsReady() { |
398 return true; | 399 return true; |
399 } | 400 } |
400 | 401 |
401 bool InstallAttributesIsSecure() { | 402 bool InstallAttributesIsSecure() { |
402 return locked_; | 403 return false; |
403 } | 404 } |
404 | 405 |
405 bool InstallAttributesIsInvalid() { | 406 bool InstallAttributesIsInvalid() { |
406 return false; | 407 return false; |
407 } | 408 } |
408 | 409 |
409 bool InstallAttributesIsFirstInstall() { | 410 bool InstallAttributesIsFirstInstall() { |
410 return false; | 411 return !locked_; |
411 } | 412 } |
412 | 413 |
413 private: | 414 private: |
414 static void DoStubCallback(Delegate* callback) { | 415 static void DoStubCallback(Delegate* callback) { |
415 if (callback) | 416 if (callback) |
416 callback->OnComplete(true, kCryptohomeMountErrorNone); | 417 callback->OnComplete(true, kCryptohomeMountErrorNone); |
417 } | 418 } |
418 | 419 |
419 std::map<std::string, std::string> install_attrs_; | 420 std::map<std::string, std::string> install_attrs_; |
420 bool locked_; | 421 bool locked_; |
421 DISALLOW_COPY_AND_ASSIGN(CryptohomeLibraryStubImpl); | 422 DISALLOW_COPY_AND_ASSIGN(CryptohomeLibraryStubImpl); |
422 }; | 423 }; |
423 | 424 |
424 // static | 425 // static |
425 CryptohomeLibrary* CryptohomeLibrary::GetImpl(bool stub) { | 426 CryptohomeLibrary* CryptohomeLibrary::GetImpl(bool stub) { |
426 if (stub) | 427 if (stub) |
427 return new CryptohomeLibraryStubImpl(); | 428 return new CryptohomeLibraryStubImpl(); |
428 else | 429 else |
429 return new CryptohomeLibraryImpl(); | 430 return new CryptohomeLibraryImpl(); |
430 } | 431 } |
431 | 432 |
432 } // namespace chromeos | 433 } // namespace chromeos |
OLD | NEW |