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> | |
8 | |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
9 #include "base/logging.h" | 11 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
11 #include "base/metrics/sparse_histogram.h" | 13 #include "base/metrics/sparse_histogram.h" |
12 #include "base/sequenced_task_runner.h" | 14 #include "base/sequenced_task_runner.h" |
13 #include "base/values.h" | 15 #include "base/values.h" |
14 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/chromeos/login/helper.h" | 17 #include "chrome/browser/chromeos/login/helper.h" |
16 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 18 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
19 #include "chrome/browser/chromeos/login/users/chrome_user_manager_impl.h" | |
17 #include "chrome/browser/chromeos/policy/policy_oauth2_token_fetcher.h" | 20 #include "chrome/browser/chromeos/policy/policy_oauth2_token_fetcher.h" |
18 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h" | 21 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h" |
19 #include "chrome/browser/chromeos/policy/wildcard_login_checker.h" | 22 #include "chrome/browser/chromeos/policy/wildcard_login_checker.h" |
20 #include "chrome/browser/lifetime/application_lifetime.h" | 23 #include "chrome/browser/lifetime/application_lifetime.h" |
21 #include "chrome/common/chrome_content_client.h" | 24 #include "chrome/common/chrome_content_client.h" |
22 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" | 25 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" |
23 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" | 26 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" |
24 #include "components/policy/core/common/cloud/device_management_service.h" | 27 #include "components/policy/core/common/cloud/device_management_service.h" |
25 #include "components/policy/core/common/cloud/system_policy_request_context.h" | 28 #include "components/policy/core/common/cloud/system_policy_request_context.h" |
26 #include "components/policy/core/common/policy_map.h" | 29 #include "components/policy/core/common/policy_map.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 // TODO(mnissler): This only removes the user pod from the login screen, but | 66 // TODO(mnissler): This only removes the user pod from the login screen, but |
64 // the cryptohome remains. This is because deleting the cryptohome for a | 67 // the cryptohome remains. This is because deleting the cryptohome for a |
65 // logged-in session is not possible. Fix this either by delaying the | 68 // logged-in session is not possible. Fix this either by delaying the |
66 // cryptohome deletion operation or by getting rid of the in-session | 69 // cryptohome deletion operation or by getting rid of the in-session |
67 // wildcard check. | 70 // wildcard check. |
68 user_manager::UserManager::Get()->RemoveUserFromList(username); | 71 user_manager::UserManager::Get()->RemoveUserFromList(username); |
69 chrome::AttemptUserExit(); | 72 chrome::AttemptUserExit(); |
70 } | 73 } |
71 } | 74 } |
72 | 75 |
76 std::set<std::string> AffiliationIDsToSet(const em::PolicyData& policy_data) { | |
Mattias Nissler (ping if slow)
2015/07/29 20:08:13
No need to break out into a separate function.
peletskyi
2015/07/30 11:02:27
Done.
| |
77 std::set<std::string> set_of_ids; | |
78 for (int i = 0; i < policy_data.user_affiliation_ids_size(); ++i) { | |
79 set_of_ids.insert(policy_data.user_affiliation_ids(i)); | |
80 } | |
Mattias Nissler (ping if slow)
2015/07/29 20:08:13
You can just use std::set::insert as noted in the
peletskyi
2015/07/30 11:02:27
Done.
| |
81 return set_of_ids; | |
82 } | |
83 | |
73 } // namespace | 84 } // namespace |
74 | 85 |
75 UserCloudPolicyManagerChromeOS::UserCloudPolicyManagerChromeOS( | 86 UserCloudPolicyManagerChromeOS::UserCloudPolicyManagerChromeOS( |
76 scoped_ptr<CloudPolicyStore> store, | 87 scoped_ptr<CloudPolicyStore> store, |
77 scoped_ptr<CloudExternalDataManager> external_data_manager, | 88 scoped_ptr<CloudExternalDataManager> external_data_manager, |
78 const base::FilePath& component_policy_cache_path, | 89 const base::FilePath& component_policy_cache_path, |
79 bool wait_for_policy_fetch, | 90 bool wait_for_policy_fetch, |
80 base::TimeDelta initial_policy_fetch_timeout, | 91 base::TimeDelta initial_policy_fetch_timeout, |
81 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 92 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
82 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner, | 93 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner, |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 cloud_policy_client->status()); | 278 cloud_policy_client->status()); |
268 } | 279 } |
269 CancelWaitForPolicyFetch(); | 280 CancelWaitForPolicyFetch(); |
270 } | 281 } |
271 | 282 |
272 void UserCloudPolicyManagerChromeOS::OnComponentCloudPolicyUpdated() { | 283 void UserCloudPolicyManagerChromeOS::OnComponentCloudPolicyUpdated() { |
273 CloudPolicyManager::OnComponentCloudPolicyUpdated(); | 284 CloudPolicyManager::OnComponentCloudPolicyUpdated(); |
274 StartRefreshSchedulerIfReady(); | 285 StartRefreshSchedulerIfReady(); |
275 } | 286 } |
276 | 287 |
288 void UserCloudPolicyManagerChromeOS::OnStoreLoaded( | |
289 CloudPolicyStore* cloud_policy_store) { | |
290 CloudPolicyManager::OnStoreLoaded(cloud_policy_store); | |
291 | |
292 em::PolicyData const* const policy_data = cloud_policy_store->policy(); | |
293 if (policy_data && chromeos::ChromeUserManager::Get()) { | |
Mattias Nissler (ping if slow)
2015/07/29 20:08:13
Add a comment explaining when and why ChromeUserMa
peletskyi
2015/07/30 11:02:27
No case when ChromeUserManager is NULL found. Cond
| |
294 LOG(ERROR) << "Add user affiliation_ids for " << policy_data->username(); | |
295 chromeos::ChromeUserManager::Get()->SetUserAffiliation( | |
296 policy_data->username(), AffiliationIDsToSet(*policy_data)); | |
297 } | |
298 } | |
299 | |
277 void UserCloudPolicyManagerChromeOS::GetChromePolicy(PolicyMap* policy_map) { | 300 void UserCloudPolicyManagerChromeOS::GetChromePolicy(PolicyMap* policy_map) { |
278 CloudPolicyManager::GetChromePolicy(policy_map); | 301 CloudPolicyManager::GetChromePolicy(policy_map); |
279 | 302 |
280 // If the store has a verified policy blob received from the server then apply | 303 // If the store has a verified policy blob received from the server then apply |
281 // the defaults for policies that haven't been configured by the administrator | 304 // the defaults for policies that haven't been configured by the administrator |
282 // given that this is an enterprise user. | 305 // given that this is an enterprise user. |
283 if (!store()->has_policy()) | 306 if (!store()->has_policy()) |
284 return; | 307 return; |
285 SetEnterpriseUsersDefaults(policy_map); | 308 SetEnterpriseUsersDefaults(policy_map); |
286 } | 309 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
396 // OnComponentCloudPolicyUpdated() once it's ready. | 419 // OnComponentCloudPolicyUpdated() once it's ready. |
397 return; | 420 return; |
398 } | 421 } |
399 | 422 |
400 core()->StartRefreshScheduler(); | 423 core()->StartRefreshScheduler(); |
401 core()->TrackRefreshDelayPref(local_state_, | 424 core()->TrackRefreshDelayPref(local_state_, |
402 policy_prefs::kUserPolicyRefreshRate); | 425 policy_prefs::kUserPolicyRefreshRate); |
403 } | 426 } |
404 | 427 |
405 } // namespace policy | 428 } // namespace policy |
OLD | NEW |