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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 "Enterprise.UserPolicyChromeOS.InitialFetch.DelayOAuth2Token"; | 48 "Enterprise.UserPolicyChromeOS.InitialFetch.DelayOAuth2Token"; |
49 const char kUMAInitialFetchDelayPolicyFetch[] = | 49 const char kUMAInitialFetchDelayPolicyFetch[] = |
50 "Enterprise.UserPolicyChromeOS.InitialFetch.DelayPolicyFetch"; | 50 "Enterprise.UserPolicyChromeOS.InitialFetch.DelayPolicyFetch"; |
51 const char kUMAInitialFetchDelayTotal[] = | 51 const char kUMAInitialFetchDelayTotal[] = |
52 "Enterprise.UserPolicyChromeOS.InitialFetch.DelayTotal"; | 52 "Enterprise.UserPolicyChromeOS.InitialFetch.DelayTotal"; |
53 const char kUMAInitialFetchOAuth2Error[] = | 53 const char kUMAInitialFetchOAuth2Error[] = |
54 "Enterprise.UserPolicyChromeOS.InitialFetch.OAuth2Error"; | 54 "Enterprise.UserPolicyChromeOS.InitialFetch.OAuth2Error"; |
55 const char kUMAInitialFetchOAuth2NetworkError[] = | 55 const char kUMAInitialFetchOAuth2NetworkError[] = |
56 "Enterprise.UserPolicyChromeOS.InitialFetch.OAuth2NetworkError"; | 56 "Enterprise.UserPolicyChromeOS.InitialFetch.OAuth2NetworkError"; |
57 | 57 |
58 void OnWildcardCheckCompleted(const std::string& username, | 58 void OnWildcardCheckCompleted(const user_manager::UserID& user_id, |
59 WildcardLoginChecker::Result result) { | 59 WildcardLoginChecker::Result result) { |
60 if (result == WildcardLoginChecker::RESULT_BLOCKED) { | 60 if (result == WildcardLoginChecker::RESULT_BLOCKED) { |
61 LOG(ERROR) << "Online wildcard login check failed, terminating session."; | 61 LOG(ERROR) << "Online wildcard login check failed, terminating session."; |
62 | 62 |
63 // TODO(mnissler): This only removes the user pod from the login screen, but | 63 // 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 | 64 // the cryptohome remains. This is because deleting the cryptohome for a |
65 // logged-in session is not possible. Fix this either by delaying the | 65 // logged-in session is not possible. Fix this either by delaying the |
66 // cryptohome deletion operation or by getting rid of the in-session | 66 // cryptohome deletion operation or by getting rid of the in-session |
67 // wildcard check. | 67 // wildcard check. |
68 user_manager::UserManager::Get()->RemoveUserFromList(username); | 68 user_manager::UserManager::Get()->RemoveUserFromList(user_id); |
69 chrome::AttemptUserExit(); | 69 chrome::AttemptUserExit(); |
70 } | 70 } |
71 } | 71 } |
72 | 72 |
73 } // namespace | 73 } // namespace |
74 | 74 |
75 UserCloudPolicyManagerChromeOS::UserCloudPolicyManagerChromeOS( | 75 UserCloudPolicyManagerChromeOS::UserCloudPolicyManagerChromeOS( |
76 scoped_ptr<CloudPolicyStore> store, | 76 scoped_ptr<CloudPolicyStore> store, |
77 scoped_ptr<CloudExternalDataManager> external_data_manager, | 77 scoped_ptr<CloudExternalDataManager> external_data_manager, |
78 const base::FilePath& component_policy_cache_path, | 78 const base::FilePath& component_policy_cache_path, |
79 bool wait_for_policy_fetch, | 79 bool wait_for_policy_fetch, |
80 base::TimeDelta initial_policy_fetch_timeout, | 80 base::TimeDelta initial_policy_fetch_timeout, |
81 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 81 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
82 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner, | 82 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner, |
83 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner) | 83 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner) |
84 : CloudPolicyManager(dm_protocol::kChromeUserPolicyType, | 84 : CloudPolicyManager(dm_protocol::kChromeUserPolicyType, |
85 std::string(), | 85 std::string(), |
86 store.get(), | 86 store.get(), |
87 task_runner, | 87 task_runner, |
88 file_task_runner, | 88 file_task_runner, |
89 io_task_runner), | 89 io_task_runner), |
90 store_(store.Pass()), | 90 store_(store.Pass()), |
91 external_data_manager_(external_data_manager.Pass()), | 91 external_data_manager_(external_data_manager.Pass()), |
| 92 wildcard_user_id_(std::string(), std::string()), |
92 component_policy_cache_path_(component_policy_cache_path), | 93 component_policy_cache_path_(component_policy_cache_path), |
93 wait_for_policy_fetch_(wait_for_policy_fetch), | 94 wait_for_policy_fetch_(wait_for_policy_fetch), |
94 policy_fetch_timeout_(false, false) { | 95 policy_fetch_timeout_(false, false) { |
95 time_init_started_ = base::Time::Now(); | 96 time_init_started_ = base::Time::Now(); |
96 if (wait_for_policy_fetch_ && !initial_policy_fetch_timeout.is_max()) { | 97 if (wait_for_policy_fetch_ && !initial_policy_fetch_timeout.is_max()) { |
97 policy_fetch_timeout_.Start( | 98 policy_fetch_timeout_.Start( |
98 FROM_HERE, | 99 FROM_HERE, |
99 initial_policy_fetch_timeout, | 100 initial_policy_fetch_timeout, |
100 base::Bind(&UserCloudPolicyManagerChromeOS::OnBlockingFetchTimeout, | 101 base::Bind(&UserCloudPolicyManagerChromeOS::OnBlockingFetchTimeout, |
101 base::Unretained(this))); | 102 base::Unretained(this))); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 OnInitializationCompleted(service()); | 140 OnInitializationCompleted(service()); |
140 } else { | 141 } else { |
141 service()->AddObserver(this); | 142 service()->AddObserver(this); |
142 } | 143 } |
143 } | 144 } |
144 | 145 |
145 void UserCloudPolicyManagerChromeOS::OnAccessTokenAvailable( | 146 void UserCloudPolicyManagerChromeOS::OnAccessTokenAvailable( |
146 const std::string& access_token) { | 147 const std::string& access_token) { |
147 access_token_ = access_token; | 148 access_token_ = access_token; |
148 | 149 |
149 if (!wildcard_username_.empty()) { | 150 if (!wildcard_user_id_.empty()) { |
150 wildcard_login_checker_.reset(new WildcardLoginChecker()); | 151 wildcard_login_checker_.reset(new WildcardLoginChecker()); |
151 wildcard_login_checker_->StartWithAccessToken( | 152 wildcard_login_checker_->StartWithAccessToken( |
152 access_token, | 153 access_token, |
153 base::Bind(&OnWildcardCheckCompleted, wildcard_username_)); | 154 base::Bind(&OnWildcardCheckCompleted, wildcard_user_id_)); |
154 } | 155 } |
155 | 156 |
156 if (service() && service()->IsInitializationComplete() && | 157 if (service() && service()->IsInitializationComplete() && |
157 client() && !client()->is_registered()) { | 158 client() && !client()->is_registered()) { |
158 OnOAuth2PolicyTokenFetched( | 159 OnOAuth2PolicyTokenFetched( |
159 access_token, GoogleServiceAuthError(GoogleServiceAuthError::NONE)); | 160 access_token, GoogleServiceAuthError(GoogleServiceAuthError::NONE)); |
160 } | 161 } |
161 } | 162 } |
162 | 163 |
163 bool UserCloudPolicyManagerChromeOS::IsClientRegistered() const { | 164 bool UserCloudPolicyManagerChromeOS::IsClientRegistered() const { |
164 return client() && client()->is_registered(); | 165 return client() && client()->is_registered(); |
165 } | 166 } |
166 | 167 |
167 void UserCloudPolicyManagerChromeOS::EnableWildcardLoginCheck( | 168 void UserCloudPolicyManagerChromeOS::EnableWildcardLoginCheck( |
168 const std::string& username) { | 169 const user_manager::UserID& user_id) { |
169 DCHECK(access_token_.empty()); | 170 DCHECK(access_token_.empty()); |
170 wildcard_username_ = username; | 171 wildcard_user_id_ = user_id; |
171 } | 172 } |
172 | 173 |
173 void UserCloudPolicyManagerChromeOS::Shutdown() { | 174 void UserCloudPolicyManagerChromeOS::Shutdown() { |
174 if (client()) | 175 if (client()) |
175 client()->RemoveObserver(this); | 176 client()->RemoveObserver(this); |
176 if (service()) | 177 if (service()) |
177 service()->RemoveObserver(this); | 178 service()->RemoveObserver(this); |
178 token_fetcher_.reset(); | 179 token_fetcher_.reset(); |
179 external_data_manager_->Disconnect(); | 180 external_data_manager_->Disconnect(); |
180 CloudPolicyManager::Shutdown(); | 181 CloudPolicyManager::Shutdown(); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 // OnComponentCloudPolicyUpdated() once it's ready. | 399 // OnComponentCloudPolicyUpdated() once it's ready. |
399 return; | 400 return; |
400 } | 401 } |
401 | 402 |
402 core()->StartRefreshScheduler(); | 403 core()->StartRefreshScheduler(); |
403 core()->TrackRefreshDelayPref(local_state_, | 404 core()->TrackRefreshDelayPref(local_state_, |
404 policy_prefs::kUserPolicyRefreshRate); | 405 policy_prefs::kUserPolicyRefreshRate); |
405 } | 406 } |
406 | 407 |
407 } // namespace policy | 408 } // namespace policy |
OLD | NEW |