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/login/owner_manager.h" | 5 #include "chrome/browser/chromeos/login/owner_manager.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
13 #include "chrome/browser/chromeos/boot_times_loader.h" | 13 #include "chrome/browser/chromeos/boot_times_loader.h" |
14 #include "chrome/browser/chromeos/login/signed_settings_temp_storage.h" | 14 #include "chrome/browser/chromeos/login/signed_settings_temp_storage.h" |
15 #include "content/browser/browser_thread.h" | 15 #include "content/browser/browser_thread.h" |
| 16 #include "chrome/common/chrome_notification_types.h" |
16 #include "content/common/notification_service.h" | 17 #include "content/common/notification_service.h" |
17 #include "content/common/notification_type.h" | |
18 | 18 |
19 namespace chromeos { | 19 namespace chromeos { |
20 | 20 |
21 OwnerManager::OwnerManager() | 21 OwnerManager::OwnerManager() |
22 : private_key_(NULL), | 22 : private_key_(NULL), |
23 public_key_(0), | 23 public_key_(0), |
24 utils_(OwnerKeyUtils::Create()) { | 24 utils_(OwnerKeyUtils::Create()) { |
25 } | 25 } |
26 | 26 |
27 OwnerManager::~OwnerManager() {} | 27 OwnerManager::~OwnerManager() {} |
28 | 28 |
29 void OwnerManager::UpdateOwnerKey(const BrowserThread::ID thread_id, | 29 void OwnerManager::UpdateOwnerKey(const BrowserThread::ID thread_id, |
30 const std::vector<uint8>& key, | 30 const std::vector<uint8>& key, |
31 KeyUpdateDelegate* d) { | 31 KeyUpdateDelegate* d) { |
32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
33 | 33 |
34 public_key_ = key; | 34 public_key_ = key; |
35 | 35 |
36 BrowserThread::PostTask( | 36 BrowserThread::PostTask( |
37 thread_id, FROM_HERE, | 37 thread_id, FROM_HERE, |
38 NewRunnableMethod(this, &OwnerManager::CallKeyUpdateDelegate, d)); | 38 NewRunnableMethod(this, &OwnerManager::CallKeyUpdateDelegate, d)); |
39 } | 39 } |
40 | 40 |
41 void OwnerManager::LoadOwnerKey() { | 41 void OwnerManager::LoadOwnerKey() { |
42 BootTimesLoader::Get()->AddLoginTimeMarker("LoadOwnerKeyStart", false); | 42 BootTimesLoader::Get()->AddLoginTimeMarker("LoadOwnerKeyStart", false); |
43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
44 VLOG(1) << "Loading owner key"; | 44 VLOG(1) << "Loading owner key"; |
45 NotificationType result = NotificationType::OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED; | 45 int result = chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED; |
46 | 46 |
47 // If |public_key_| isn't empty, we already have the key, so don't | 47 // If |public_key_| isn't empty, we already have the key, so don't |
48 // try to import again. | 48 // try to import again. |
49 if (public_key_.empty() && | 49 if (public_key_.empty() && |
50 !utils_->ImportPublicKey(utils_->GetOwnerKeyFilePath(), &public_key_)) { | 50 !utils_->ImportPublicKey(utils_->GetOwnerKeyFilePath(), &public_key_)) { |
51 result = NotificationType::OWNER_KEY_FETCH_ATTEMPT_FAILED; | 51 result = chrome::NOTIFICATION_OWNER_KEY_FETCH_ATTEMPT_FAILED; |
52 } | 52 } |
53 | 53 |
54 // Whether we loaded the public key or not, send a notification indicating | 54 // Whether we loaded the public key or not, send a notification indicating |
55 // that we're done with this attempt. | 55 // that we're done with this attempt. |
56 BrowserThread::PostTask( | 56 BrowserThread::PostTask( |
57 BrowserThread::UI, FROM_HERE, | 57 BrowserThread::UI, FROM_HERE, |
58 NewRunnableMethod(this, | 58 NewRunnableMethod(this, |
59 &OwnerManager::SendNotification, | 59 &OwnerManager::SendNotification, |
60 result, | 60 result, |
61 NotificationService::NoDetails())); | 61 NotificationService::NoDetails())); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 return_code = OPERATION_FAILED; | 133 return_code = OPERATION_FAILED; |
134 } | 134 } |
135 BrowserThread::PostTask( | 135 BrowserThread::PostTask( |
136 thread_id, FROM_HERE, | 136 thread_id, FROM_HERE, |
137 NewRunnableMethod(this, | 137 NewRunnableMethod(this, |
138 &OwnerManager::CallDelegate, | 138 &OwnerManager::CallDelegate, |
139 d, return_code, std::vector<uint8>())); | 139 d, return_code, std::vector<uint8>())); |
140 BootTimesLoader::Get()->AddLoginTimeMarker("VerifyEnd", false); | 140 BootTimesLoader::Get()->AddLoginTimeMarker("VerifyEnd", false); |
141 } | 141 } |
142 | 142 |
143 void OwnerManager::SendNotification(NotificationType type, | 143 void OwnerManager::SendNotification(int type, |
144 const NotificationDetails& details) { | 144 const NotificationDetails& details) { |
145 NotificationService::current()->Notify( | 145 NotificationService::current()->Notify( |
146 type, | 146 type, |
147 NotificationService::AllSources(), | 147 NotificationService::AllSources(), |
148 details); | 148 details); |
149 } | 149 } |
150 | 150 |
151 } // namespace chromeos | 151 } // namespace chromeos |
OLD | NEW |