Chromium Code Reviews| 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 policy_fetch_timeout_.Stop(); | |
|
pmarko
2016/11/29 14:03:34
nit: I think stopping the timer would not be stric
Andrew T Wilson (Slow)
2016/11/30 10:02:34
Agreed, but I'm trying to mimic the behavior of a
| |
| 124 this->OnBlockingFetchTimeout(); | |
|
emaxx
2016/11/29 16:21:15
nit: Is "this->" really needed here?
Andrew T Wilson (Slow)
2016/11/30 10:02:34
No, you are just seeing the artifacts of a rusty m
| |
| 125 } | |
| 126 | |
| 121 UserCloudPolicyManagerChromeOS::~UserCloudPolicyManagerChromeOS() {} | 127 UserCloudPolicyManagerChromeOS::~UserCloudPolicyManagerChromeOS() {} |
| 122 | 128 |
| 123 void UserCloudPolicyManagerChromeOS::Connect( | 129 void UserCloudPolicyManagerChromeOS::Connect( |
| 124 PrefService* local_state, | 130 PrefService* local_state, |
| 125 DeviceManagementService* device_management_service, | 131 DeviceManagementService* device_management_service, |
| 126 scoped_refptr<net::URLRequestContextGetter> system_request_context) { | 132 scoped_refptr<net::URLRequestContextGetter> system_request_context) { |
| 127 DCHECK(device_management_service); | 133 DCHECK(device_management_service); |
| 128 DCHECK(local_state); | 134 DCHECK(local_state); |
| 129 local_state_ = local_state; | 135 local_state_ = local_state; |
| 130 // Note: |system_request_context| can be null for tests. | 136 // Note: |system_request_context| can be null for tests. |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 296 StartRefreshSchedulerIfReady(); | 302 StartRefreshSchedulerIfReady(); |
| 297 } | 303 } |
| 298 | 304 |
| 299 void UserCloudPolicyManagerChromeOS::OnStoreLoaded( | 305 void UserCloudPolicyManagerChromeOS::OnStoreLoaded( |
| 300 CloudPolicyStore* cloud_policy_store) { | 306 CloudPolicyStore* cloud_policy_store) { |
| 301 CloudPolicyManager::OnStoreLoaded(cloud_policy_store); | 307 CloudPolicyManager::OnStoreLoaded(cloud_policy_store); |
| 302 | 308 |
| 303 em::PolicyData const* const policy_data = cloud_policy_store->policy(); | 309 em::PolicyData const* const policy_data = cloud_policy_store->policy(); |
| 304 | 310 |
| 305 if (policy_data) { | 311 if (policy_data) { |
| 312 DCHECK(policy_data->has_username()); | |
| 306 chromeos::AffiliationIDSet set_of_user_affiliation_ids( | 313 chromeos::AffiliationIDSet set_of_user_affiliation_ids( |
| 307 policy_data->user_affiliation_ids().begin(), | 314 policy_data->user_affiliation_ids().begin(), |
| 308 policy_data->user_affiliation_ids().end()); | 315 policy_data->user_affiliation_ids().end()); |
| 309 | 316 |
| 310 chromeos::ChromeUserManager::Get()->SetUserAffiliation( | 317 chromeos::ChromeUserManager::Get()->SetUserAffiliation( |
| 311 policy_data->username(), set_of_user_affiliation_ids); | 318 policy_data->username(), set_of_user_affiliation_ids); |
| 312 } | 319 } |
| 313 } | 320 } |
| 314 | 321 |
| 315 void UserCloudPolicyManagerChromeOS::GetChromePolicy(PolicyMap* policy_map) { | 322 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. | 455 // OnComponentCloudPolicyUpdated() once it's ready. |
| 449 return; | 456 return; |
| 450 } | 457 } |
| 451 | 458 |
| 452 core()->StartRefreshScheduler(); | 459 core()->StartRefreshScheduler(); |
| 453 core()->TrackRefreshDelayPref(local_state_, | 460 core()->TrackRefreshDelayPref(local_state_, |
| 454 policy_prefs::kUserPolicyRefreshRate); | 461 policy_prefs::kUserPolicyRefreshRate); |
| 455 } | 462 } |
| 456 | 463 |
| 457 } // namespace policy | 464 } // namespace policy |
| OLD | NEW |