| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/login/ownership_service.h" | 5 #include "chrome/browser/chromeos/login/ownership_service.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "chrome/browser/browser_thread.h" | 10 #include "chrome/browser/browser_thread.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 bool OwnershipService::IsAlreadyOwned() { | 30 bool OwnershipService::IsAlreadyOwned() { |
| 31 return file_util::PathExists(utils_->GetOwnerKeyFilePath()); | 31 return file_util::PathExists(utils_->GetOwnerKeyFilePath()); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void OwnershipService::StartLoadOwnerKeyAttempt() { | 34 void OwnershipService::StartLoadOwnerKeyAttempt() { |
| 35 BrowserThread::PostTask( | 35 BrowserThread::PostTask( |
| 36 BrowserThread::FILE, FROM_HERE, | 36 BrowserThread::FILE, FROM_HERE, |
| 37 NewRunnableFunction(&TryLoadOwnerKeyAttempt, this)); | 37 NewRunnableFunction(&TryLoadOwnerKeyAttempt, this)); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void OwnershipService::StartTakeOwnershipAttempt(const std::string& unused) { | |
| 41 BrowserThread::PostTask( | |
| 42 BrowserThread::FILE, FROM_HERE, | |
| 43 NewRunnableFunction(&OwnershipService::TryTakeOwnershipAttempt, this)); | |
| 44 } | |
| 45 | |
| 46 void OwnershipService::StartSigningAttempt(const std::string& data, | 40 void OwnershipService::StartSigningAttempt(const std::string& data, |
| 47 OwnerManager::Delegate* d) { | 41 OwnerManager::Delegate* d) { |
| 48 BrowserThread::ID thread_id; | 42 BrowserThread::ID thread_id; |
| 49 if (!BrowserThread::GetCurrentThreadIdentifier(&thread_id)) | 43 if (!BrowserThread::GetCurrentThreadIdentifier(&thread_id)) |
| 50 thread_id = BrowserThread::UI; | 44 thread_id = BrowserThread::UI; |
| 51 BrowserThread::PostTask( | 45 BrowserThread::PostTask( |
| 52 BrowserThread::FILE, FROM_HERE, | 46 BrowserThread::FILE, FROM_HERE, |
| 53 NewRunnableFunction(&OwnershipService::TrySigningAttempt, | 47 NewRunnableFunction(&OwnershipService::TrySigningAttempt, |
| 54 this, | 48 this, |
| 55 thread_id, | 49 thread_id, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 85 void OwnershipService::TryLoadOwnerKeyAttempt(OwnershipService* service) { | 79 void OwnershipService::TryLoadOwnerKeyAttempt(OwnershipService* service) { |
| 86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 80 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 87 if (!service->IsAlreadyOwned()) { | 81 if (!service->IsAlreadyOwned()) { |
| 88 VLOG(1) << "Device not yet owned"; | 82 VLOG(1) << "Device not yet owned"; |
| 89 return; | 83 return; |
| 90 } | 84 } |
| 91 service->manager()->LoadOwnerKey(); | 85 service->manager()->LoadOwnerKey(); |
| 92 } | 86 } |
| 93 | 87 |
| 94 // static | 88 // static |
| 95 void OwnershipService::TryTakeOwnershipAttempt(OwnershipService* service) { | |
| 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | |
| 97 if (service->IsAlreadyOwned()) { | |
| 98 VLOG(1) << "Device is already owned"; | |
| 99 return; | |
| 100 } | |
| 101 service->manager()->GenerateKeysAndExportPublic(); | |
| 102 } | |
| 103 | |
| 104 // static | |
| 105 void OwnershipService::TrySigningAttempt(OwnershipService* service, | 89 void OwnershipService::TrySigningAttempt(OwnershipService* service, |
| 106 const BrowserThread::ID thread_id, | 90 const BrowserThread::ID thread_id, |
| 107 const std::string& data, | 91 const std::string& data, |
| 108 OwnerManager::Delegate* d) { | 92 OwnerManager::Delegate* d) { |
| 109 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 93 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 110 if (!service->IsAlreadyOwned()) { | 94 if (!service->IsAlreadyOwned()) { |
| 111 LOG(ERROR) << "Device not yet owned"; | 95 LOG(ERROR) << "Device not yet owned"; |
| 112 BrowserThread::PostTask( | 96 BrowserThread::PostTask( |
| 113 thread_id, FROM_HERE, | 97 thread_id, FROM_HERE, |
| 114 NewRunnableFunction(&OwnershipService::FailAttempt, d)); | 98 NewRunnableFunction(&OwnershipService::FailAttempt, d)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 133 } | 117 } |
| 134 service->manager()->Verify(thread_id, data, signature, d); | 118 service->manager()->Verify(thread_id, data, signature, d); |
| 135 } | 119 } |
| 136 | 120 |
| 137 // static | 121 // static |
| 138 void OwnershipService::FailAttempt(OwnerManager::Delegate* d) { | 122 void OwnershipService::FailAttempt(OwnerManager::Delegate* d) { |
| 139 d->OnKeyOpComplete(OwnerManager::KEY_UNAVAILABLE, std::vector<uint8>()); | 123 d->OnKeyOpComplete(OwnerManager::KEY_UNAVAILABLE, std::vector<uint8>()); |
| 140 } | 124 } |
| 141 | 125 |
| 142 } // namespace chromeos | 126 } // namespace chromeos |
| OLD | NEW |