Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Side by Side Diff: chrome/browser/chromeos/login/enrollment/enterprise_enrollment_helper_impl.cc

Issue 1767443002: Add enterprise enrollment support for fake users. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Check instance before derefing it Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/saml/saml_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_);
106 started_ = true; 106 started_ = true;
107 DoEnrollUsingToken(token); 107 DoEnrollUsingToken(token);
108 } 108 }
109 109
110 void EnterpriseEnrollmentHelperImpl::ClearAuth(const base::Closure& callback) { 110 void EnterpriseEnrollmentHelperImpl::ClearAuth(const base::Closure& callback) {
111 // Do not revoke the additional token if enrollment has finished 111 // Do not revoke the additional token if enrollment has finished
112 // successfully. 112 // successfully.
113 if (!success_ && additional_token_.length()) 113 if (!success_ && additional_token_.length())
114 (new TokenRevoker())->Start(additional_token_); 114 (new TokenRevoker())->Start(additional_token_);
115 115
116 if (oauth_fetcher_) { 116 if (oauth_fetcher_) {
117 if (!oauth_fetcher_->oauth2_access_token().empty()) 117 if (!oauth_fetcher_->OAuth2AccessToken().empty())
118 (new TokenRevoker())->Start(oauth_fetcher_->oauth2_access_token()); 118 (new TokenRevoker())->Start(oauth_fetcher_->OAuth2AccessToken());
119 119
120 if (!oauth_fetcher_->oauth2_refresh_token().empty()) 120 if (!oauth_fetcher_->OAuth2RefreshToken().empty())
121 (new TokenRevoker())->Start(oauth_fetcher_->oauth2_refresh_token()); 121 (new TokenRevoker())->Start(oauth_fetcher_->OAuth2RefreshToken());
122 122
123 oauth_fetcher_.reset(); 123 oauth_fetcher_.reset();
124 } else if (oauth_token_.length()) { 124 } else if (oauth_token_.length()) {
125 // EnrollUsingToken was called. 125 // EnrollUsingToken was called.
126 (new TokenRevoker())->Start(oauth_token_); 126 (new TokenRevoker())->Start(oauth_token_);
127 } 127 }
128 128
129 chromeos::ProfileHelper::Get()->ClearSigninProfile( 129 chromeos::ProfileHelper::Get()->ClearSigninProfile(
130 base::Bind(&EnterpriseEnrollmentHelperImpl::OnSigninProfileCleared, 130 base::Bind(&EnterpriseEnrollmentHelperImpl::OnSigninProfileCleared,
131 weak_ptr_factory_.GetWeakPtr(), callback)); 131 weak_ptr_factory_.GetWeakPtr(), callback));
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 status_consumer()->OnAuthError(error); 203 status_consumer()->OnAuthError(error);
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_->OAuth2RefreshToken();
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
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
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/saml/saml_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698