| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/login/enrollment/enterprise_enrollment_helper_
impl.h" | 5 #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_helper_
impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 EnterpriseEnrollmentHelperImpl::~EnterpriseEnrollmentHelperImpl() { | 85 EnterpriseEnrollmentHelperImpl::~EnterpriseEnrollmentHelperImpl() { |
| 86 DCHECK(g_browser_process->IsShuttingDown() || !started_ || | 86 DCHECK(g_browser_process->IsShuttingDown() || !started_ || |
| 87 (finished_ && (success_ || auth_data_cleared_))); | 87 (finished_ && (success_ || auth_data_cleared_))); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void EnterpriseEnrollmentHelperImpl::EnrollUsingAuthCode( | 90 void EnterpriseEnrollmentHelperImpl::EnrollUsingAuthCode( |
| 91 const std::string& auth_code, | 91 const std::string& auth_code, |
| 92 bool fetch_additional_token) { | 92 bool fetch_additional_token) { |
| 93 DCHECK(!started_); | 93 DCHECK(!started_); |
| 94 started_ = true; | 94 started_ = true; |
| 95 oauth_fetcher_.reset(new policy::PolicyOAuth2TokenFetcher()); | 95 oauth_fetcher_.reset(policy::PolicyOAuth2TokenFetcher::CreateInstance()); |
| 96 oauth_fetcher_->StartWithAuthCode( | 96 oauth_fetcher_->StartWithAuthCode( |
| 97 auth_code, g_browser_process->system_request_context(), | 97 auth_code, g_browser_process->system_request_context(), |
| 98 base::Bind(&EnterpriseEnrollmentHelperImpl::OnTokenFetched, | 98 base::Bind(&EnterpriseEnrollmentHelperImpl::OnTokenFetched, |
| 99 weak_ptr_factory_.GetWeakPtr(), | 99 weak_ptr_factory_.GetWeakPtr(), |
| 100 fetch_additional_token /* is_additional_token */)); | 100 fetch_additional_token /* is_additional_token */)); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void EnterpriseEnrollmentHelperImpl::EnrollUsingToken( | 103 void EnterpriseEnrollmentHelperImpl::EnrollUsingToken( |
| 104 const std::string& token) { | 104 const std::string& token) { |
| 105 DCHECK(!started_); | 105 DCHECK(!started_); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 return; | 204 return; |
| 205 } | 205 } |
| 206 | 206 |
| 207 if (!is_additional_token) { | 207 if (!is_additional_token) { |
| 208 DoEnrollUsingToken(token); | 208 DoEnrollUsingToken(token); |
| 209 return; | 209 return; |
| 210 } | 210 } |
| 211 | 211 |
| 212 additional_token_ = token; | 212 additional_token_ = token; |
| 213 std::string refresh_token = oauth_fetcher_->oauth2_refresh_token(); | 213 std::string refresh_token = oauth_fetcher_->oauth2_refresh_token(); |
| 214 oauth_fetcher_.reset(new policy::PolicyOAuth2TokenFetcher()); | 214 oauth_fetcher_.reset(policy::PolicyOAuth2TokenFetcher::CreateInstance()); |
| 215 oauth_fetcher_->StartWithRefreshToken( | 215 oauth_fetcher_->StartWithRefreshToken( |
| 216 refresh_token, g_browser_process->system_request_context(), | 216 refresh_token, g_browser_process->system_request_context(), |
| 217 base::Bind(&EnterpriseEnrollmentHelperImpl::OnTokenFetched, | 217 base::Bind(&EnterpriseEnrollmentHelperImpl::OnTokenFetched, |
| 218 weak_ptr_factory_.GetWeakPtr(), | 218 weak_ptr_factory_.GetWeakPtr(), |
| 219 false /* is_additional_token */)); | 219 false /* is_additional_token */)); |
| 220 } | 220 } |
| 221 | 221 |
| 222 void EnterpriseEnrollmentHelperImpl::OnEnrollmentFinished( | 222 void EnterpriseEnrollmentHelperImpl::OnEnrollmentFinished( |
| 223 policy::EnrollmentStatus status) { | 223 policy::EnrollmentStatus status) { |
| 224 ReportEnrollmentStatus(status); | 224 ReportEnrollmentStatus(status); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 EnrollmentUMA(sample, enrollment_config_.mode); | 408 EnrollmentUMA(sample, enrollment_config_.mode); |
| 409 } | 409 } |
| 410 | 410 |
| 411 void EnterpriseEnrollmentHelperImpl::OnSigninProfileCleared( | 411 void EnterpriseEnrollmentHelperImpl::OnSigninProfileCleared( |
| 412 const base::Closure& callback) { | 412 const base::Closure& callback) { |
| 413 auth_data_cleared_ = true; | 413 auth_data_cleared_ = true; |
| 414 callback.Run(); | 414 callback.Run(); |
| 415 } | 415 } |
| 416 | 416 |
| 417 } // namespace chromeos | 417 } // namespace chromeos |
| OLD | NEW |