OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/settings/device_settings_service.h" | 5 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/chromeos/settings/owner_key_util.h" | 12 #include "chrome/browser/chromeos/settings/owner_key_util.h" |
13 #include "chrome/browser/chromeos/settings/session_manager_operation.h" | 13 #include "chrome/browser/chromeos/settings/session_manager_operation.h" |
14 #include "chrome/browser/policy/proto/chromeos/chrome_device_policy.pb.h" | 14 #include "chrome/browser/policy/proto/chromeos/chrome_device_policy.pb.h" |
15 #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h" | 15 #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h" |
16 #include "chromeos/network/network_handler.h" | |
16 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
17 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
18 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
19 #include "crypto/rsa_private_key.h" | 20 #include "crypto/rsa_private_key.h" |
20 | 21 |
21 namespace em = enterprise_management; | 22 namespace em = enterprise_management; |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 // Delay between load retries when there was a validation error. | 26 // Delay between load retries when there was a validation error. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 DeviceSettingsService* DeviceSettingsService::Get() { | 69 DeviceSettingsService* DeviceSettingsService::Get() { |
69 CHECK(g_device_settings_service); | 70 CHECK(g_device_settings_service); |
70 return g_device_settings_service; | 71 return g_device_settings_service; |
71 } | 72 } |
72 | 73 |
73 DeviceSettingsService::DeviceSettingsService() | 74 DeviceSettingsService::DeviceSettingsService() |
74 : session_manager_client_(NULL), | 75 : session_manager_client_(NULL), |
75 weak_factory_(this), | 76 weak_factory_(this), |
76 store_status_(STORE_SUCCESS), | 77 store_status_(STORE_SUCCESS), |
77 load_retries_left_(kMaxLoadRetries) { | 78 load_retries_left_(kMaxLoadRetries) { |
79 if (NetworkHandler::IsInitialized()) | |
Mattias Nissler (ping if slow)
2013/07/25 08:56:24
I'm a bit uncomfortable about the fact that we now
pneubeck (no reviews)
2013/07/25 09:08:43
CertLoader itself doesn't depend on any of the oth
stevenjb
2013/07/25 17:02:27
OK, I'll make CertLoader its own singleton. I agre
| |
80 NetworkHandler::Get()->cert_loader()->AddObserver(this); | |
78 } | 81 } |
79 | 82 |
80 DeviceSettingsService::~DeviceSettingsService() { | 83 DeviceSettingsService::~DeviceSettingsService() { |
81 DCHECK(pending_operations_.empty()); | 84 DCHECK(pending_operations_.empty()); |
85 if (NetworkHandler::IsInitialized()) | |
86 NetworkHandler::Get()->cert_loader()->RemoveObserver(this); | |
82 } | 87 } |
83 | 88 |
84 void DeviceSettingsService::SetSessionManager( | 89 void DeviceSettingsService::SetSessionManager( |
85 SessionManagerClient* session_manager_client, | 90 SessionManagerClient* session_manager_client, |
86 scoped_refptr<OwnerKeyUtil> owner_key_util) { | 91 scoped_refptr<OwnerKeyUtil> owner_key_util) { |
87 DCHECK(session_manager_client); | 92 DCHECK(session_manager_client); |
88 DCHECK(owner_key_util.get()); | 93 DCHECK(owner_key_util.get()); |
89 DCHECK(!session_manager_client_); | 94 DCHECK(!session_manager_client_); |
90 DCHECK(!owner_key_util_.get()); | 95 DCHECK(!owner_key_util_.get()); |
91 | 96 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 | 206 |
202 void DeviceSettingsService::PropertyChangeComplete(bool success) { | 207 void DeviceSettingsService::PropertyChangeComplete(bool success) { |
203 if (!success) { | 208 if (!success) { |
204 LOG(ERROR) << "Policy update failed."; | 209 LOG(ERROR) << "Policy update failed."; |
205 return; | 210 return; |
206 } | 211 } |
207 | 212 |
208 EnsureReload(false); | 213 EnsureReload(false); |
209 } | 214 } |
210 | 215 |
216 void DeviceSettingsService::OnCertificatesLoaded( | |
217 const net::CertificateList& cert_list, | |
218 bool initial_load) { | |
219 // CertLoader initializes the TPM and NSS database which is necessary to | |
220 // determine ownership. Force a reload once we know these are initialized. | |
221 EnsureReload(true); | |
222 } | |
223 | |
211 void DeviceSettingsService::Enqueue(SessionManagerOperation* operation) { | 224 void DeviceSettingsService::Enqueue(SessionManagerOperation* operation) { |
212 pending_operations_.push_back(operation); | 225 pending_operations_.push_back(operation); |
213 if (pending_operations_.front() == operation) | 226 if (pending_operations_.front() == operation) |
214 StartNextOperation(); | 227 StartNextOperation(); |
215 } | 228 } |
216 | 229 |
217 void DeviceSettingsService::EnqueueLoad(bool force_key_load) { | 230 void DeviceSettingsService::EnqueueLoad(bool force_key_load) { |
218 SessionManagerOperation* operation = | 231 SessionManagerOperation* operation = |
219 new LoadSettingsOperation( | 232 new LoadSettingsOperation( |
220 base::Bind(&DeviceSettingsService::HandleCompletedOperation, | 233 base::Bind(&DeviceSettingsService::HandleCompletedOperation, |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 | 330 |
318 ScopedTestDeviceSettingsService::ScopedTestDeviceSettingsService() { | 331 ScopedTestDeviceSettingsService::ScopedTestDeviceSettingsService() { |
319 DeviceSettingsService::Initialize(); | 332 DeviceSettingsService::Initialize(); |
320 } | 333 } |
321 | 334 |
322 ScopedTestDeviceSettingsService::~ScopedTestDeviceSettingsService() { | 335 ScopedTestDeviceSettingsService::~ScopedTestDeviceSettingsService() { |
323 DeviceSettingsService::Shutdown(); | 336 DeviceSettingsService::Shutdown(); |
324 } | 337 } |
325 | 338 |
326 } // namespace chromeos | 339 } // namespace chromeos |
OLD | NEW |