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" |
11 #include "base/metrics/sparse_histogram.h" | 11 #include "base/metrics/sparse_histogram.h" |
12 #include "base/sequenced_task_runner.h" | 12 #include "base/sequenced_task_runner.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/chromeos/login/helper.h" | 15 #include "chrome/browser/chromeos/login/helper.h" |
16 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | |
17 #include "chrome/browser/chromeos/login/startup_utils.h" | |
16 #include "chrome/browser/chromeos/policy/policy_oauth2_token_fetcher.h" | 18 #include "chrome/browser/chromeos/policy/policy_oauth2_token_fetcher.h" |
17 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h" | 19 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h" |
18 #include "chrome/browser/chromeos/policy/wildcard_login_checker.h" | 20 #include "chrome/browser/chromeos/policy/wildcard_login_checker.h" |
19 #include "chrome/browser/lifetime/application_lifetime.h" | 21 #include "chrome/browser/lifetime/application_lifetime.h" |
20 #include "chrome/common/chrome_content_client.h" | 22 #include "chrome/common/chrome_content_client.h" |
21 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" | 23 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" |
22 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" | 24 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" |
23 #include "components/policy/core/common/cloud/device_management_service.h" | 25 #include "components/policy/core/common/cloud/device_management_service.h" |
24 #include "components/policy/core/common/cloud/system_policy_request_context.h" | 26 #include "components/policy/core/common/cloud/system_policy_request_context.h" |
25 #include "components/policy/core/common/policy_map.h" | 27 #include "components/policy/core/common/policy_map.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 // In that case, the signin Profile is used to authenticate a Gaia request to | 207 // In that case, the signin Profile is used to authenticate a Gaia request to |
206 // fetch a refresh token, and then the policy token is fetched. | 208 // fetch a refresh token, and then the policy token is fetched. |
207 // | 209 // |
208 // If |wait_for_policy_fetch_| is false then the UserCloudPolicyTokenForwarder | 210 // If |wait_for_policy_fetch_| is false then the UserCloudPolicyTokenForwarder |
209 // service will eventually call OnAccessTokenAvailable() once an access token | 211 // service will eventually call OnAccessTokenAvailable() once an access token |
210 // is available. That call may have already happened while waiting for | 212 // is available. That call may have already happened while waiting for |
211 // initialization of the CloudPolicyService, so in that case check if an | 213 // initialization of the CloudPolicyService, so in that case check if an |
212 // access token is already available. | 214 // access token is already available. |
213 if (!client()->is_registered()) { | 215 if (!client()->is_registered()) { |
214 if (wait_for_policy_fetch_) { | 216 if (wait_for_policy_fetch_) { |
215 FetchPolicyOAuthTokenUsingSigninContext(); | 217 if (chromeos::StartupUtils::IsWebviewSigninEnabled()) { |
218 OnAccessTokenAvailable(chromeos::UserSessionManager::GetInstance() | |
219 ->user_context() | |
220 .GetAccessToken()); | |
xiyuan
2015/04/27 16:33:27
The AT in user context just have oauth login scrop
achuithb
2015/04/27 17:54:36
Yup, we need this for the wildcard login check. I
| |
221 } else { | |
222 FetchPolicyOAuthTokenUsingSigninContext(); | |
223 } | |
216 } else if (!access_token_.empty()) { | 224 } else if (!access_token_.empty()) { |
217 OnAccessTokenAvailable(access_token_); | 225 OnAccessTokenAvailable(access_token_); |
218 } | 226 } |
219 } | 227 } |
220 | 228 |
221 if (!wait_for_policy_fetch_) { | 229 if (!wait_for_policy_fetch_) { |
222 // If this isn't blocking on a policy fetch then | 230 // If this isn't blocking on a policy fetch then |
223 // CloudPolicyManager::OnStoreLoaded() already published the cached policy. | 231 // CloudPolicyManager::OnStoreLoaded() already published the cached policy. |
224 // Start the refresh scheduler now, which will eventually refresh the | 232 // Start the refresh scheduler now, which will eventually refresh the |
225 // cached policy or make the first fetch once the OAuth2 token is | 233 // cached policy or make the first fetch once the OAuth2 token is |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
386 // OnComponentCloudPolicyUpdated() once it's ready. | 394 // OnComponentCloudPolicyUpdated() once it's ready. |
387 return; | 395 return; |
388 } | 396 } |
389 | 397 |
390 core()->StartRefreshScheduler(); | 398 core()->StartRefreshScheduler(); |
391 core()->TrackRefreshDelayPref(local_state_, | 399 core()->TrackRefreshDelayPref(local_state_, |
392 policy_prefs::kUserPolicyRefreshRate); | 400 policy_prefs::kUserPolicyRefreshRate); |
393 } | 401 } |
394 | 402 |
395 } // namespace policy | 403 } // namespace policy |
OLD | NEW |