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/policy/user_policy_signin_service.h" | 5 #include "chrome/browser/policy/user_policy_signin_service.h" |
6 | 6 |
7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/policy/browser_policy_connector.h" | 8 #include "chrome/browser/policy/browser_policy_connector.h" |
9 #include "chrome/browser/policy/cloud_policy_service.h" | 9 #include "chrome/browser/policy/cloud_policy_service.h" |
10 #include "chrome/browser/policy/user_cloud_policy_manager.h" | 10 #include "chrome/browser/policy/user_cloud_policy_manager.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 // Make sure we've initialized the DeviceManagementService. It's OK to | 122 // Make sure we've initialized the DeviceManagementService. It's OK to |
123 // call this multiple times so we do it every time we initialize the | 123 // call this multiple times so we do it every time we initialize the |
124 // UserCloudPolicyManager. | 124 // UserCloudPolicyManager. |
125 g_browser_process->browser_policy_connector()-> | 125 g_browser_process->browser_policy_connector()-> |
126 ScheduleServiceInitialization( | 126 ScheduleServiceInitialization( |
127 kPolicyServiceInitializationDelayMilliseconds); | 127 kPolicyServiceInitializationDelayMilliseconds); |
128 // If there is no cached DMToken then we can detect this below (or when | 128 // If there is no cached DMToken then we can detect this below (or when |
129 // the OnInitializationCompleted() callback is invoked. | 129 // the OnInitializationCompleted() callback is invoked. |
130 policy::DeviceManagementService* service = g_browser_process-> | 130 policy::DeviceManagementService* service = g_browser_process-> |
131 browser_policy_connector()->device_management_service(); | 131 browser_policy_connector()->device_management_service(); |
132 manager_->Initialize(g_browser_process->local_state(), | 132 manager_->Initialize(g_browser_process->local_state(), service); |
133 service, | |
134 policy::USER_AFFILIATION_NONE); | |
135 DCHECK(manager_->cloud_policy_service()); | 133 DCHECK(manager_->cloud_policy_service()); |
136 manager_->cloud_policy_service()->AddObserver(this); | 134 manager_->cloud_policy_service()->AddObserver(this); |
137 } | 135 } |
138 | 136 |
139 // If the CloudPolicyService is initialized, but the CloudPolicyClient still | 137 // If the CloudPolicyService is initialized, but the CloudPolicyClient still |
140 // needs to be registered, kick off registration. | 138 // needs to be registered, kick off registration. |
141 if (manager_->cloud_policy_service()->IsInitializationComplete() && | 139 if (manager_->cloud_policy_service()->IsInitializationComplete() && |
142 !manager_->IsClientRegistered()) { | 140 !manager_->IsClientRegistered()) { |
143 RegisterCloudPolicyService(); | 141 RegisterCloudPolicyService(); |
144 } | 142 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 gaia_urls->oauth2_chrome_client_secret(), | 182 gaia_urls->oauth2_chrome_client_secret(), |
185 token, | 183 token, |
186 scopes); | 184 scopes); |
187 } | 185 } |
188 | 186 |
189 void UserPolicySigninService::OnGetTokenFailure( | 187 void UserPolicySigninService::OnGetTokenFailure( |
190 const GoogleServiceAuthError& error) { | 188 const GoogleServiceAuthError& error) { |
191 DLOG(WARNING) << "Could not fetch access token for " | 189 DLOG(WARNING) << "Could not fetch access token for " |
192 << kServiceScopeChromeOSDeviceManagement; | 190 << kServiceScopeChromeOSDeviceManagement; |
193 oauth2_access_token_fetcher_.reset(); | 191 oauth2_access_token_fetcher_.reset(); |
194 manager_->CancelWaitForPolicyFetch(); | |
195 } | 192 } |
196 | 193 |
197 void UserPolicySigninService::OnGetTokenSuccess( | 194 void UserPolicySigninService::OnGetTokenSuccess( |
198 const std::string& access_token, | 195 const std::string& access_token, |
199 const base::Time& expiration_time) { | 196 const base::Time& expiration_time) { |
200 // Pass along the new access token to the CloudPolicyClient. | 197 // Pass along the new access token to the CloudPolicyClient. |
201 DVLOG(1) << "Fetched new scoped OAuth token:" << access_token; | 198 DVLOG(1) << "Fetched new scoped OAuth token:" << access_token; |
202 manager_->RegisterClient(access_token); | 199 manager_->RegisterClient(access_token); |
203 oauth2_access_token_fetcher_.reset(); | 200 oauth2_access_token_fetcher_.reset(); |
204 } | 201 } |
205 | 202 |
206 } // namespace policy | 203 } // namespace policy |
OLD | NEW |