| 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/user_cloud_policy_manager_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 !initial_policy_fetch_timeout.is_max(); | 111 !initial_policy_fetch_timeout.is_max(); |
| 112 if (wait_for_policy_fetch_ && allow_failed_policy_fetches_) { | 112 if (wait_for_policy_fetch_ && allow_failed_policy_fetches_) { |
| 113 policy_fetch_timeout_.Start( | 113 policy_fetch_timeout_.Start( |
| 114 FROM_HERE, | 114 FROM_HERE, |
| 115 initial_policy_fetch_timeout, | 115 initial_policy_fetch_timeout, |
| 116 base::Bind(&UserCloudPolicyManagerChromeOS::OnBlockingFetchTimeout, | 116 base::Bind(&UserCloudPolicyManagerChromeOS::OnBlockingFetchTimeout, |
| 117 base::Unretained(this))); | 117 base::Unretained(this))); |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 | 120 |
| 121 void UserCloudPolicyManagerChromeOS::ForceTimeoutForTest() { |
| 122 DCHECK(policy_fetch_timeout_.IsRunning()); |
| 123 // Stop the timer to mimic what happens when a real timer fires, then invoke |
| 124 // the timer callback directly. |
| 125 policy_fetch_timeout_.Stop(); |
| 126 OnBlockingFetchTimeout(); |
| 127 } |
| 128 |
| 121 UserCloudPolicyManagerChromeOS::~UserCloudPolicyManagerChromeOS() {} | 129 UserCloudPolicyManagerChromeOS::~UserCloudPolicyManagerChromeOS() {} |
| 122 | 130 |
| 123 void UserCloudPolicyManagerChromeOS::Connect( | 131 void UserCloudPolicyManagerChromeOS::Connect( |
| 124 PrefService* local_state, | 132 PrefService* local_state, |
| 125 DeviceManagementService* device_management_service, | 133 DeviceManagementService* device_management_service, |
| 126 scoped_refptr<net::URLRequestContextGetter> system_request_context) { | 134 scoped_refptr<net::URLRequestContextGetter> system_request_context) { |
| 127 DCHECK(device_management_service); | 135 DCHECK(device_management_service); |
| 128 DCHECK(local_state); | 136 DCHECK(local_state); |
| 129 local_state_ = local_state; | 137 local_state_ = local_state; |
| 130 // Note: |system_request_context| can be null for tests. | 138 // Note: |system_request_context| can be null for tests. |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 StartRefreshSchedulerIfReady(); | 304 StartRefreshSchedulerIfReady(); |
| 297 } | 305 } |
| 298 | 306 |
| 299 void UserCloudPolicyManagerChromeOS::OnStoreLoaded( | 307 void UserCloudPolicyManagerChromeOS::OnStoreLoaded( |
| 300 CloudPolicyStore* cloud_policy_store) { | 308 CloudPolicyStore* cloud_policy_store) { |
| 301 CloudPolicyManager::OnStoreLoaded(cloud_policy_store); | 309 CloudPolicyManager::OnStoreLoaded(cloud_policy_store); |
| 302 | 310 |
| 303 em::PolicyData const* const policy_data = cloud_policy_store->policy(); | 311 em::PolicyData const* const policy_data = cloud_policy_store->policy(); |
| 304 | 312 |
| 305 if (policy_data) { | 313 if (policy_data) { |
| 314 DCHECK(policy_data->has_username()); |
| 306 chromeos::AffiliationIDSet set_of_user_affiliation_ids( | 315 chromeos::AffiliationIDSet set_of_user_affiliation_ids( |
| 307 policy_data->user_affiliation_ids().begin(), | 316 policy_data->user_affiliation_ids().begin(), |
| 308 policy_data->user_affiliation_ids().end()); | 317 policy_data->user_affiliation_ids().end()); |
| 309 | 318 |
| 310 chromeos::ChromeUserManager::Get()->SetUserAffiliation( | 319 chromeos::ChromeUserManager::Get()->SetUserAffiliation( |
| 311 policy_data->username(), set_of_user_affiliation_ids); | 320 policy_data->username(), set_of_user_affiliation_ids); |
| 312 } | 321 } |
| 313 } | 322 } |
| 314 | 323 |
| 315 void UserCloudPolicyManagerChromeOS::GetChromePolicy(PolicyMap* policy_map) { | 324 void UserCloudPolicyManagerChromeOS::GetChromePolicy(PolicyMap* policy_map) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 // OnComponentCloudPolicyUpdated() once it's ready. | 457 // OnComponentCloudPolicyUpdated() once it's ready. |
| 449 return; | 458 return; |
| 450 } | 459 } |
| 451 | 460 |
| 452 core()->StartRefreshScheduler(); | 461 core()->StartRefreshScheduler(); |
| 453 core()->TrackRefreshDelayPref(local_state_, | 462 core()->TrackRefreshDelayPref(local_state_, |
| 454 policy_prefs::kUserPolicyRefreshRate); | 463 policy_prefs::kUserPolicyRefreshRate); |
| 455 } | 464 } |
| 456 | 465 |
| 457 } // namespace policy | 466 } // namespace policy |
| OLD | NEW |