Chromium Code Reviews| 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" | 20 #include "chrome/browser/chromeos/policy/consumer_enrollment_handler.h" |
|
bartfab (slow)
2014/12/15 16:08:40
Nit: Why are you adding this?
rkc
2014/12/15 20:45:58
Merge screwup. Fixed.
Done.
| |
| 21 #include "chrome/browser/chromeos/policy/consumer_management_service.h" | 21 #include "chrome/browser/chromeos/policy/consumer_management_service.h" |
| 22 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h" | 22 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h" |
| 23 #include "chrome/browser/chromeos/policy/device_cloud_policy_invalidator.h" | 23 #include "chrome/browser/chromeos/policy/device_cloud_policy_invalidator.h" |
| 24 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" | 24 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" |
| 25 #include "chrome/browser/chromeos/policy/device_local_account.h" | 25 #include "chrome/browser/chromeos/policy/device_local_account.h" |
| 26 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" | 26 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" |
| 27 #include "chrome/browser/chromeos/policy/device_network_configuration_updater.h" | 27 #include "chrome/browser/chromeos/policy/device_network_configuration_updater.h" |
| 28 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" | 28 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" |
| 29 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" | 29 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" |
| 30 #include "chrome/browser/chromeos/settings/cros_settings.h" | 30 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 chromeos::CrosSettings::Get(), | 190 chromeos::CrosSettings::Get(), |
| 191 GetBackgroundTaskRunner(), | 191 GetBackgroundTaskRunner(), |
| 192 GetBackgroundTaskRunner(), | 192 GetBackgroundTaskRunner(), |
| 193 GetBackgroundTaskRunner(), | 193 GetBackgroundTaskRunner(), |
| 194 content::BrowserThread::GetMessageLoopProxyForThread( | 194 content::BrowserThread::GetMessageLoopProxyForThread( |
| 195 content::BrowserThread::IO), | 195 content::BrowserThread::IO), |
| 196 request_context)); | 196 request_context)); |
| 197 device_local_account_policy_service_->Connect(device_management_service()); | 197 device_local_account_policy_service_->Connect(device_management_service()); |
| 198 device_cloud_policy_invalidator_.reset(new DeviceCloudPolicyInvalidator); | 198 device_cloud_policy_invalidator_.reset(new DeviceCloudPolicyInvalidator); |
| 199 | 199 |
| 200 // request_context is NULL in unit tests. | |
| 201 if (request_context.get() && install_attributes_) { | |
| 202 app_pack_updater_.reset( | |
| 203 new AppPackUpdater(request_context.get(), install_attributes_.get())); | |
| 204 } | |
| 205 | |
| 206 SetTimezoneIfPolicyAvailable(); | 200 SetTimezoneIfPolicyAvailable(); |
| 207 | 201 |
| 208 network_configuration_updater_ = | 202 network_configuration_updater_ = |
| 209 DeviceNetworkConfigurationUpdater::CreateForDevicePolicy( | 203 DeviceNetworkConfigurationUpdater::CreateForDevicePolicy( |
| 210 GetPolicyService(), | 204 GetPolicyService(), |
| 211 chromeos::NetworkHandler::Get() | 205 chromeos::NetworkHandler::Get() |
| 212 ->managed_network_configuration_handler(), | 206 ->managed_network_configuration_handler(), |
| 213 chromeos::NetworkHandler::Get()->network_device_handler(), | 207 chromeos::NetworkHandler::Get()->network_device_handler(), |
| 214 chromeos::CrosSettings::Get()); | 208 chromeos::CrosSettings::Get()); |
| 215 } | 209 } |
| 216 | 210 |
| 217 void BrowserPolicyConnectorChromeOS::PreShutdown() { | 211 void BrowserPolicyConnectorChromeOS::PreShutdown() { |
| 218 // Let the |device_cloud_policy_invalidator_| unregister itself as an | 212 // Let the |device_cloud_policy_invalidator_| unregister itself as an |
| 219 // observer of per-Profile InvalidationServices and the device-global | 213 // observer of per-Profile InvalidationServices and the device-global |
| 220 // invalidation::TiclInvalidationService it may have created as an observer of | 214 // invalidation::TiclInvalidationService it may have created as an observer of |
| 221 // the DeviceOAuth2TokenService that is destroyed before Shutdown() is called. | 215 // the DeviceOAuth2TokenService that is destroyed before Shutdown() is called. |
| 222 device_cloud_policy_invalidator_.reset(); | 216 device_cloud_policy_invalidator_.reset(); |
| 223 } | 217 } |
| 224 | 218 |
| 225 void BrowserPolicyConnectorChromeOS::Shutdown() { | 219 void BrowserPolicyConnectorChromeOS::Shutdown() { |
| 226 // Verify that PreShutdown() has been called first. | 220 // Verify that PreShutdown() has been called first. |
| 227 DCHECK(!device_cloud_policy_invalidator_); | 221 DCHECK(!device_cloud_policy_invalidator_); |
| 228 | 222 |
| 229 // The AppPackUpdater may be observing the |device_cloud_policy_manager_|. | |
| 230 // Delete it first. | |
| 231 app_pack_updater_.reset(); | |
| 232 | |
| 233 network_configuration_updater_.reset(); | 223 network_configuration_updater_.reset(); |
| 234 | 224 |
| 235 if (device_local_account_policy_service_) | 225 if (device_local_account_policy_service_) |
| 236 device_local_account_policy_service_->Shutdown(); | 226 device_local_account_policy_service_->Shutdown(); |
| 237 | 227 |
| 238 if (device_cloud_policy_initializer_) | 228 if (device_cloud_policy_initializer_) |
| 239 device_cloud_policy_initializer_->Shutdown(); | 229 device_cloud_policy_initializer_->Shutdown(); |
| 240 | 230 |
| 241 if (device_cloud_policy_manager_) | 231 if (device_cloud_policy_manager_) |
| 242 device_cloud_policy_manager_->RemoveDeviceCloudPolicyManagerObserver(this); | 232 device_cloud_policy_manager_->RemoveDeviceCloudPolicyManagerObserver(this); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 269 if (install_attributes_ && | 259 if (install_attributes_ && |
| 270 (gaia::ExtractDomainName(gaia::CanonicalizeEmail(user_name)) == | 260 (gaia::ExtractDomainName(gaia::CanonicalizeEmail(user_name)) == |
| 271 install_attributes_->GetDomain() || | 261 install_attributes_->GetDomain() || |
| 272 policy::IsDeviceLocalAccountUser(user_name, NULL))) { | 262 policy::IsDeviceLocalAccountUser(user_name, NULL))) { |
| 273 return USER_AFFILIATION_MANAGED; | 263 return USER_AFFILIATION_MANAGED; |
| 274 } | 264 } |
| 275 | 265 |
| 276 return USER_AFFILIATION_NONE; | 266 return USER_AFFILIATION_NONE; |
| 277 } | 267 } |
| 278 | 268 |
| 279 AppPackUpdater* BrowserPolicyConnectorChromeOS::GetAppPackUpdater() { | |
| 280 return app_pack_updater_.get(); | |
| 281 } | |
| 282 | |
| 283 void BrowserPolicyConnectorChromeOS::SetUserPolicyDelegate( | 269 void BrowserPolicyConnectorChromeOS::SetUserPolicyDelegate( |
| 284 ConfigurationPolicyProvider* user_policy_provider) { | 270 ConfigurationPolicyProvider* user_policy_provider) { |
| 285 global_user_cloud_policy_provider_->SetDelegate(user_policy_provider); | 271 global_user_cloud_policy_provider_->SetDelegate(user_policy_provider); |
| 286 } | 272 } |
| 287 | 273 |
| 288 void BrowserPolicyConnectorChromeOS::SetConsumerManagementServiceForTesting( | 274 void BrowserPolicyConnectorChromeOS::SetConsumerManagementServiceForTesting( |
| 289 scoped_ptr<ConsumerManagementService> service) { | 275 scoped_ptr<ConsumerManagementService> service) { |
| 290 consumer_management_service_ = service.Pass(); | 276 consumer_management_service_ = service.Pass(); |
| 291 } | 277 } |
| 292 | 278 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 std::string timezone; | 327 std::string timezone; |
| 342 if (chromeos::CrosSettings::Get()->GetString(chromeos::kSystemTimezonePolicy, | 328 if (chromeos::CrosSettings::Get()->GetString(chromeos::kSystemTimezonePolicy, |
| 343 &timezone) && | 329 &timezone) && |
| 344 !timezone.empty()) { | 330 !timezone.empty()) { |
| 345 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( | 331 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( |
| 346 base::UTF8ToUTF16(timezone)); | 332 base::UTF8ToUTF16(timezone)); |
| 347 } | 333 } |
| 348 } | 334 } |
| 349 | 335 |
| 350 } // namespace policy | 336 } // namespace policy |
| OLD | NEW |