| 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/policy/device_cloud_policy_manager_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/files/file_path.h" |
| 15 #include "base/logging.h" | 16 #include "base/logging.h" |
| 16 #include "base/macros.h" | 17 #include "base/macros.h" |
| 17 #include "base/memory/ptr_util.h" | 18 #include "base/memory/ptr_util.h" |
| 19 #include "base/path_service.h" |
| 18 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
| 21 #include "base/sys_info.h" |
| 19 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 20 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/chromeos/attestation/attestation_policy_observer.h" | 24 #include "chrome/browser/chromeos/attestation/attestation_policy_observer.h" |
| 22 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.h" | 25 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.h" |
| 23 #include "chrome/browser/chromeos/login/startup_utils.h" | 26 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 24 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" | 27 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" |
| 25 #include "chrome/browser/chromeos/policy/device_status_collector.h" | 28 #include "chrome/browser/chromeos/policy/device_status_collector.h" |
| 26 #include "chrome/browser/chromeos/policy/heartbeat_scheduler.h" | 29 #include "chrome/browser/chromeos/policy/heartbeat_scheduler.h" |
| 27 #include "chrome/browser/chromeos/policy/remote_commands/device_commands_factory
_chromeos.h" | 30 #include "chrome/browser/chromeos/policy/remote_commands/device_commands_factory
_chromeos.h" |
| 28 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" | 31 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" |
| 29 #include "chrome/browser/chromeos/policy/status_uploader.h" | 32 #include "chrome/browser/chromeos/policy/status_uploader.h" |
| 30 #include "chrome/browser/chromeos/policy/system_log_uploader.h" | 33 #include "chrome/browser/chromeos/policy/system_log_uploader.h" |
| 31 #include "chrome/browser/chromeos/settings/install_attributes.h" | 34 #include "chrome/browser/chromeos/settings/install_attributes.h" |
| 32 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
| 33 #include "chromeos/chromeos_constants.h" | 36 #include "chromeos/chromeos_constants.h" |
| 37 #include "chromeos/chromeos_paths.h" |
| 34 #include "chromeos/chromeos_switches.h" | 38 #include "chromeos/chromeos_switches.h" |
| 35 #include "chromeos/system/statistics_provider.h" | 39 #include "chromeos/system/statistics_provider.h" |
| 36 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 40 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
| 37 #include "components/policy/core/common/cloud/cloud_policy_service.h" | 41 #include "components/policy/core/common/cloud/cloud_policy_service.h" |
| 38 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 42 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
| 39 #include "components/policy/core/common/remote_commands/remote_commands_factory.
h" | 43 #include "components/policy/core/common/remote_commands/remote_commands_factory.
h" |
| 44 #include "components/policy/core/common/schema_registry.h" |
| 40 #include "components/policy/proto/device_management_backend.pb.h" | 45 #include "components/policy/proto/device_management_backend.pb.h" |
| 41 #include "components/prefs/pref_registry_simple.h" | 46 #include "components/prefs/pref_registry_simple.h" |
| 42 #include "components/prefs/pref_service.h" | 47 #include "components/prefs/pref_service.h" |
| 43 #include "content/public/browser/browser_thread.h" | 48 #include "content/public/browser/browser_thread.h" |
| 44 #include "crypto/sha2.h" | 49 #include "crypto/sha2.h" |
| 50 #include "net/url_request/url_request_context_getter.h" |
| 45 #include "url/gurl.h" | 51 #include "url/gurl.h" |
| 46 | 52 |
| 47 using content::BrowserThread; | 53 using content::BrowserThread; |
| 48 | 54 |
| 49 namespace em = enterprise_management; | 55 namespace em = enterprise_management; |
| 50 | 56 |
| 51 namespace policy { | 57 namespace policy { |
| 52 | 58 |
| 53 namespace { | 59 namespace { |
| 54 | 60 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 local_state_->SetBoolean(prefs::kDeviceEnrollmentCanExit, false); | 188 local_state_->SetBoolean(prefs::kDeviceEnrollmentCanExit, false); |
| 183 } | 189 } |
| 184 } | 190 } |
| 185 | 191 |
| 186 void DeviceCloudPolicyManagerChromeOS::Shutdown() { | 192 void DeviceCloudPolicyManagerChromeOS::Shutdown() { |
| 187 status_uploader_.reset(); | 193 status_uploader_.reset(); |
| 188 syslog_uploader_.reset(); | 194 syslog_uploader_.reset(); |
| 189 heartbeat_scheduler_.reset(); | 195 heartbeat_scheduler_.reset(); |
| 190 state_keys_update_subscription_.reset(); | 196 state_keys_update_subscription_.reset(); |
| 191 CloudPolicyManager::Shutdown(); | 197 CloudPolicyManager::Shutdown(); |
| 198 signin_profile_forwarding_schema_registry_.reset(); |
| 192 } | 199 } |
| 193 | 200 |
| 194 // static | 201 // static |
| 195 void DeviceCloudPolicyManagerChromeOS::RegisterPrefs( | 202 void DeviceCloudPolicyManagerChromeOS::RegisterPrefs( |
| 196 PrefRegistrySimple* registry) { | 203 PrefRegistrySimple* registry) { |
| 197 registry->RegisterStringPref(prefs::kDeviceEnrollmentRequisition, | 204 registry->RegisterStringPref(prefs::kDeviceEnrollmentRequisition, |
| 198 std::string()); | 205 std::string()); |
| 199 registry->RegisterBooleanPref(prefs::kDeviceEnrollmentAutoStart, false); | 206 registry->RegisterBooleanPref(prefs::kDeviceEnrollmentAutoStart, false); |
| 200 registry->RegisterBooleanPref(prefs::kDeviceEnrollmentCanExit, true); | 207 registry->RegisterBooleanPref(prefs::kDeviceEnrollmentCanExit, true); |
| 201 registry->RegisterDictionaryPref(prefs::kServerBackedDeviceState); | 208 registry->RegisterDictionaryPref(prefs::kServerBackedDeviceState); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 229 | 236 |
| 230 void DeviceCloudPolicyManagerChromeOS::StartConnection( | 237 void DeviceCloudPolicyManagerChromeOS::StartConnection( |
| 231 std::unique_ptr<CloudPolicyClient> client_to_connect, | 238 std::unique_ptr<CloudPolicyClient> client_to_connect, |
| 232 chromeos::InstallAttributes* install_attributes) { | 239 chromeos::InstallAttributes* install_attributes) { |
| 233 CHECK(!service()); | 240 CHECK(!service()); |
| 234 | 241 |
| 235 // Set state keys here so the first policy fetch submits them to the server. | 242 // Set state keys here so the first policy fetch submits them to the server. |
| 236 if (ForcedReEnrollmentEnabled()) | 243 if (ForcedReEnrollmentEnabled()) |
| 237 client_to_connect->SetStateKeysToUpload(state_keys_broker_->state_keys()); | 244 client_to_connect->SetStateKeysToUpload(state_keys_broker_->state_keys()); |
| 238 | 245 |
| 246 if (is_component_policy_enabled_) { |
| 247 base::FilePath component_policy_cache_dir; |
| 248 CHECK(PathService::Get(chromeos::DIR_SIGNIN_PROFILE_COMPONENT_POLICY, |
| 249 &component_policy_cache_dir)); |
| 250 CHECK(signin_profile_forwarding_schema_registry_); |
| 251 CreateComponentCloudPolicyService( |
| 252 dm_protocol::kChromeSigninExtensionPolicyType, |
| 253 component_policy_cache_dir, g_browser_process->system_request_context(), |
| 254 client_to_connect.get(), |
| 255 signin_profile_forwarding_schema_registry_.get()); |
| 256 } |
| 257 |
| 239 core()->Connect(std::move(client_to_connect)); | 258 core()->Connect(std::move(client_to_connect)); |
| 240 core()->StartRefreshScheduler(); | 259 core()->StartRefreshScheduler(); |
| 260 core()->RefreshSoon(); |
| 241 core()->StartRemoteCommandsService(std::unique_ptr<RemoteCommandsFactory>( | 261 core()->StartRemoteCommandsService(std::unique_ptr<RemoteCommandsFactory>( |
| 242 new DeviceCommandsFactoryChromeOS())); | 262 new DeviceCommandsFactoryChromeOS())); |
| 243 core()->TrackRefreshDelayPref(local_state_, | 263 core()->TrackRefreshDelayPref(local_state_, |
| 244 prefs::kDevicePolicyRefreshRate); | 264 prefs::kDevicePolicyRefreshRate); |
| 245 attestation_policy_observer_.reset( | 265 attestation_policy_observer_.reset( |
| 246 new chromeos::attestation::AttestationPolicyObserver(client())); | 266 new chromeos::attestation::AttestationPolicyObserver(client())); |
| 247 | 267 |
| 248 // Enable device reporting and status monitoring for enterprise enrolled | 268 // Enable device reporting and status monitoring for enterprise enrolled |
| 249 // devices. We want to create these objects for enrolled devices, even if | 269 // devices. We want to create these objects for enrolled devices, even if |
| 250 // monitoring is currently inactive, in case monitoring is turned back on in | 270 // monitoring is currently inactive, in case monitoring is turned back on in |
| (...skipping 25 matching lines...) Expand all Loading... |
| 276 | 296 |
| 277 void DeviceCloudPolicyManagerChromeOS::Disconnect() { | 297 void DeviceCloudPolicyManagerChromeOS::Disconnect() { |
| 278 status_uploader_.reset(); | 298 status_uploader_.reset(); |
| 279 syslog_uploader_.reset(); | 299 syslog_uploader_.reset(); |
| 280 heartbeat_scheduler_.reset(); | 300 heartbeat_scheduler_.reset(); |
| 281 core()->Disconnect(); | 301 core()->Disconnect(); |
| 282 | 302 |
| 283 NotifyDisconnected(); | 303 NotifyDisconnected(); |
| 284 } | 304 } |
| 285 | 305 |
| 306 void DeviceCloudPolicyManagerChromeOS::SetSigninProfileSchemaRegistry( |
| 307 SchemaRegistry* schema_registry) { |
| 308 DCHECK(!signin_profile_forwarding_schema_registry_); |
| 309 signin_profile_forwarding_schema_registry_.reset( |
| 310 new ForwardingSchemaRegistry(schema_registry)); |
| 311 } |
| 312 |
| 286 void DeviceCloudPolicyManagerChromeOS::OnStateKeysUpdated() { | 313 void DeviceCloudPolicyManagerChromeOS::OnStateKeysUpdated() { |
| 287 if (client() && ForcedReEnrollmentEnabled()) | 314 if (client() && ForcedReEnrollmentEnabled()) |
| 288 client()->SetStateKeysToUpload(state_keys_broker_->state_keys()); | 315 client()->SetStateKeysToUpload(state_keys_broker_->state_keys()); |
| 289 } | 316 } |
| 290 | 317 |
| 291 void DeviceCloudPolicyManagerChromeOS::InitializeRequisition() { | 318 void DeviceCloudPolicyManagerChromeOS::InitializeRequisition() { |
| 292 // OEM statistics are only loaded when OOBE is not completed. | 319 // OEM statistics are only loaded when OOBE is not completed. |
| 293 if (chromeos::StartupUtils::IsOobeCompleted()) | 320 if (chromeos::StartupUtils::IsOobeCompleted()) |
| 294 return; | 321 return; |
| 295 | 322 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 base::MakeUnique<DeviceStatusCollector>( | 363 base::MakeUnique<DeviceStatusCollector>( |
| 337 local_state_, chromeos::system::StatisticsProvider::GetInstance(), | 364 local_state_, chromeos::system::StatisticsProvider::GetInstance(), |
| 338 DeviceStatusCollector::VolumeInfoFetcher(), | 365 DeviceStatusCollector::VolumeInfoFetcher(), |
| 339 DeviceStatusCollector::CPUStatisticsFetcher(), | 366 DeviceStatusCollector::CPUStatisticsFetcher(), |
| 340 DeviceStatusCollector::CPUTempFetcher(), | 367 DeviceStatusCollector::CPUTempFetcher(), |
| 341 DeviceStatusCollector::AndroidStatusFetcher()), | 368 DeviceStatusCollector::AndroidStatusFetcher()), |
| 342 task_runner_)); | 369 task_runner_)); |
| 343 } | 370 } |
| 344 | 371 |
| 345 } // namespace policy | 372 } // namespace policy |
| OLD | NEW |