OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ownership/owner_settings_service_chromeos.h" | 5 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 crypto::RSAPrivateKey::FindFromPublicKeyInfo(public_key)); | 115 crypto::RSAPrivateKey::FindFromPublicKeyInfo(public_key)); |
116 bool is_owner = key.get() != NULL; | 116 bool is_owner = key.get() != NULL; |
117 return is_owner; | 117 return is_owner; |
118 } | 118 } |
119 | 119 |
120 // Checks whether NSS slots with private key are mounted or | 120 // Checks whether NSS slots with private key are mounted or |
121 // not. Responds via |callback|. | 121 // not. Responds via |callback|. |
122 void DoesPrivateKeyExistAsync( | 122 void DoesPrivateKeyExistAsync( |
123 const scoped_refptr<OwnerKeyUtil>& owner_key_util, | 123 const scoped_refptr<OwnerKeyUtil>& owner_key_util, |
124 const OwnerSettingsServiceChromeOS::IsOwnerCallback& callback) { | 124 const OwnerSettingsServiceChromeOS::IsOwnerCallback& callback) { |
125 if (!owner_key_util) { | 125 if (!owner_key_util.get()) { |
126 callback.Run(false); | 126 callback.Run(false); |
127 return; | 127 return; |
128 } | 128 } |
129 scoped_refptr<base::TaskRunner> task_runner = | 129 scoped_refptr<base::TaskRunner> task_runner = |
130 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( | 130 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( |
131 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); | 131 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); |
132 base::PostTaskAndReplyWithResult( | 132 base::PostTaskAndReplyWithResult( |
133 task_runner.get(), | 133 task_runner.get(), |
134 FROM_HERE, | 134 FROM_HERE, |
135 base::Bind(&DoesPrivateKeyExistAsyncHelper, owner_key_util), | 135 base::Bind(&DoesPrivateKeyExistAsyncHelper, owner_key_util), |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 SessionManagerOperation* operation, | 297 SessionManagerOperation* operation, |
298 DeviceSettingsService::Status status) { | 298 DeviceSettingsService::Status status) { |
299 DCHECK_EQ(operation, pending_operations_.front()); | 299 DCHECK_EQ(operation, pending_operations_.front()); |
300 | 300 |
301 DeviceSettingsService* service = GetDeviceSettingsService(); | 301 DeviceSettingsService* service = GetDeviceSettingsService(); |
302 if (status == DeviceSettingsService::STORE_SUCCESS) { | 302 if (status == DeviceSettingsService::STORE_SUCCESS) { |
303 service->set_policy_data(operation->policy_data().Pass()); | 303 service->set_policy_data(operation->policy_data().Pass()); |
304 service->set_device_settings(operation->device_settings().Pass()); | 304 service->set_device_settings(operation->device_settings().Pass()); |
305 } | 305 } |
306 | 306 |
307 if ((operation->public_key() && !public_key_) || | 307 if ((operation->public_key().get() && !public_key_.get()) || |
308 (operation->public_key() && public_key_ && | 308 (operation->public_key().get() && public_key_.get() && |
309 operation->public_key()->data() != public_key_->data())) { | 309 operation->public_key()->data() != public_key_->data())) { |
310 // Public part changed so we need to reload private part too. | 310 // Public part changed so we need to reload private part too. |
311 ReloadKeypair(); | 311 ReloadKeypair(); |
312 content::NotificationService::current()->Notify( | 312 content::NotificationService::current()->Notify( |
313 chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED, | 313 chrome::NOTIFICATION_OWNERSHIP_STATUS_CHANGED, |
314 content::Source<OwnerSettingsServiceChromeOS>(this), | 314 content::Source<OwnerSettingsServiceChromeOS>(this), |
315 content::NotificationService::NoDetails()); | 315 content::NotificationService::NoDetails()); |
316 } | 316 } |
317 service->OnSignAndStoreOperationCompleted(status); | 317 service->OnSignAndStoreOperationCompleted(status); |
318 if (!callback.is_null()) | 318 if (!callback.is_null()) |
319 callback.Run(); | 319 callback.Run(); |
320 | 320 |
321 pending_operations_.pop_front(); | 321 pending_operations_.pop_front(); |
322 delete operation; | 322 delete operation; |
323 StartNextOperation(); | 323 StartNextOperation(); |
324 } | 324 } |
325 | 325 |
326 } // namespace chromeos | 326 } // namespace chromeos |
OLD | NEW |