| 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/policy/browser_policy_connector_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/message_loop/message_loop_proxy.h" | 14 #include "base/message_loop/message_loop_proxy.h" |
| 15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "base/prefs/pref_registry_simple.h" | 16 #include "base/prefs/pref_registry_simple.h" |
| 17 #include "base/sequenced_task_runner.h" | 17 #include "base/sequenced_task_runner.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "base/threading/sequenced_worker_pool.h" | 19 #include "base/threading/sequenced_worker_pool.h" |
| 20 #include "chrome/browser/chromeos/policy/app_pack_updater.h" | |
| 21 #include "chrome/browser/chromeos/policy/consumer_management_service.h" | 20 #include "chrome/browser/chromeos/policy/consumer_management_service.h" |
| 22 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h" | 21 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h" |
| 23 #include "chrome/browser/chromeos/policy/device_cloud_policy_invalidator.h" | 22 #include "chrome/browser/chromeos/policy/device_cloud_policy_invalidator.h" |
| 24 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" | 23 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" |
| 25 #include "chrome/browser/chromeos/policy/device_local_account.h" | 24 #include "chrome/browser/chromeos/policy/device_local_account.h" |
| 26 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" | 25 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" |
| 27 #include "chrome/browser/chromeos/policy/device_network_configuration_updater.h" | 26 #include "chrome/browser/chromeos/policy/device_network_configuration_updater.h" |
| 28 #include "chrome/browser/chromeos/policy/enrollment_config.h" | 27 #include "chrome/browser/chromeos/policy/enrollment_config.h" |
| 29 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" | 28 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" |
| 30 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" | 29 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 chromeos::CrosSettings::Get(), | 190 chromeos::CrosSettings::Get(), |
| 192 GetBackgroundTaskRunner(), | 191 GetBackgroundTaskRunner(), |
| 193 GetBackgroundTaskRunner(), | 192 GetBackgroundTaskRunner(), |
| 194 GetBackgroundTaskRunner(), | 193 GetBackgroundTaskRunner(), |
| 195 content::BrowserThread::GetMessageLoopProxyForThread( | 194 content::BrowserThread::GetMessageLoopProxyForThread( |
| 196 content::BrowserThread::IO), | 195 content::BrowserThread::IO), |
| 197 request_context)); | 196 request_context)); |
| 198 device_local_account_policy_service_->Connect(device_management_service()); | 197 device_local_account_policy_service_->Connect(device_management_service()); |
| 199 device_cloud_policy_invalidator_.reset(new DeviceCloudPolicyInvalidator); | 198 device_cloud_policy_invalidator_.reset(new DeviceCloudPolicyInvalidator); |
| 200 | 199 |
| 201 // request_context is NULL in unit tests. | |
| 202 if (request_context.get() && install_attributes_) { | |
| 203 app_pack_updater_.reset( | |
| 204 new AppPackUpdater(request_context.get(), install_attributes_.get())); | |
| 205 } | |
| 206 | |
| 207 SetTimezoneIfPolicyAvailable(); | 200 SetTimezoneIfPolicyAvailable(); |
| 208 | 201 |
| 209 network_configuration_updater_ = | 202 network_configuration_updater_ = |
| 210 DeviceNetworkConfigurationUpdater::CreateForDevicePolicy( | 203 DeviceNetworkConfigurationUpdater::CreateForDevicePolicy( |
| 211 GetPolicyService(), | 204 GetPolicyService(), |
| 212 chromeos::NetworkHandler::Get() | 205 chromeos::NetworkHandler::Get() |
| 213 ->managed_network_configuration_handler(), | 206 ->managed_network_configuration_handler(), |
| 214 chromeos::NetworkHandler::Get()->network_device_handler(), | 207 chromeos::NetworkHandler::Get()->network_device_handler(), |
| 215 chromeos::CrosSettings::Get()); | 208 chromeos::CrosSettings::Get()); |
| 216 } | 209 } |
| 217 | 210 |
| 218 void BrowserPolicyConnectorChromeOS::PreShutdown() { | 211 void BrowserPolicyConnectorChromeOS::PreShutdown() { |
| 219 // Let the |device_cloud_policy_invalidator_| unregister itself as an | 212 // Let the |device_cloud_policy_invalidator_| unregister itself as an |
| 220 // observer of per-Profile InvalidationServices and the device-global | 213 // observer of per-Profile InvalidationServices and the device-global |
| 221 // invalidation::TiclInvalidationService it may have created as an observer of | 214 // invalidation::TiclInvalidationService it may have created as an observer of |
| 222 // the DeviceOAuth2TokenService that is destroyed before Shutdown() is called. | 215 // the DeviceOAuth2TokenService that is destroyed before Shutdown() is called. |
| 223 device_cloud_policy_invalidator_.reset(); | 216 device_cloud_policy_invalidator_.reset(); |
| 224 } | 217 } |
| 225 | 218 |
| 226 void BrowserPolicyConnectorChromeOS::Shutdown() { | 219 void BrowserPolicyConnectorChromeOS::Shutdown() { |
| 227 // Verify that PreShutdown() has been called first. | 220 // Verify that PreShutdown() has been called first. |
| 228 DCHECK(!device_cloud_policy_invalidator_); | 221 DCHECK(!device_cloud_policy_invalidator_); |
| 229 | 222 |
| 230 // The AppPackUpdater may be observing the |device_cloud_policy_manager_|. | |
| 231 // Delete it first. | |
| 232 app_pack_updater_.reset(); | |
| 233 | |
| 234 network_configuration_updater_.reset(); | 223 network_configuration_updater_.reset(); |
| 235 | 224 |
| 236 if (device_local_account_policy_service_) | 225 if (device_local_account_policy_service_) |
| 237 device_local_account_policy_service_->Shutdown(); | 226 device_local_account_policy_service_->Shutdown(); |
| 238 | 227 |
| 239 if (device_cloud_policy_initializer_) | 228 if (device_cloud_policy_initializer_) |
| 240 device_cloud_policy_initializer_->Shutdown(); | 229 device_cloud_policy_initializer_->Shutdown(); |
| 241 | 230 |
| 242 if (device_cloud_policy_manager_) | 231 if (device_cloud_policy_manager_) |
| 243 device_cloud_policy_manager_->RemoveDeviceCloudPolicyManagerObserver(this); | 232 device_cloud_policy_manager_->RemoveDeviceCloudPolicyManagerObserver(this); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 if (install_attributes_ && | 267 if (install_attributes_ && |
| 279 (gaia::ExtractDomainName(gaia::CanonicalizeEmail(user_name)) == | 268 (gaia::ExtractDomainName(gaia::CanonicalizeEmail(user_name)) == |
| 280 install_attributes_->GetDomain() || | 269 install_attributes_->GetDomain() || |
| 281 policy::IsDeviceLocalAccountUser(user_name, NULL))) { | 270 policy::IsDeviceLocalAccountUser(user_name, NULL))) { |
| 282 return USER_AFFILIATION_MANAGED; | 271 return USER_AFFILIATION_MANAGED; |
| 283 } | 272 } |
| 284 | 273 |
| 285 return USER_AFFILIATION_NONE; | 274 return USER_AFFILIATION_NONE; |
| 286 } | 275 } |
| 287 | 276 |
| 288 AppPackUpdater* BrowserPolicyConnectorChromeOS::GetAppPackUpdater() { | |
| 289 return app_pack_updater_.get(); | |
| 290 } | |
| 291 | |
| 292 void BrowserPolicyConnectorChromeOS::SetUserPolicyDelegate( | 277 void BrowserPolicyConnectorChromeOS::SetUserPolicyDelegate( |
| 293 ConfigurationPolicyProvider* user_policy_provider) { | 278 ConfigurationPolicyProvider* user_policy_provider) { |
| 294 global_user_cloud_policy_provider_->SetDelegate(user_policy_provider); | 279 global_user_cloud_policy_provider_->SetDelegate(user_policy_provider); |
| 295 } | 280 } |
| 296 | 281 |
| 297 void BrowserPolicyConnectorChromeOS::SetConsumerManagementServiceForTesting( | 282 void BrowserPolicyConnectorChromeOS::SetConsumerManagementServiceForTesting( |
| 298 scoped_ptr<ConsumerManagementService> service) { | 283 scoped_ptr<ConsumerManagementService> service) { |
| 299 consumer_management_service_ = service.Pass(); | 284 consumer_management_service_ = service.Pass(); |
| 300 } | 285 } |
| 301 | 286 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 std::string timezone; | 335 std::string timezone; |
| 351 if (chromeos::CrosSettings::Get()->GetString(chromeos::kSystemTimezonePolicy, | 336 if (chromeos::CrosSettings::Get()->GetString(chromeos::kSystemTimezonePolicy, |
| 352 &timezone) && | 337 &timezone) && |
| 353 !timezone.empty()) { | 338 !timezone.empty()) { |
| 354 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( | 339 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( |
| 355 base::UTF8ToUTF16(timezone)); | 340 base::UTF8ToUTF16(timezone)); |
| 356 } | 341 } |
| 357 } | 342 } |
| 358 | 343 |
| 359 } // namespace policy | 344 } // namespace policy |
| OLD | NEW |