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

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

Issue 418063002: EnrollmentScreen source code cosmetics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/login/enrollment/enrollment_screen.h" 5 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen.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/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 LOG(WARNING) << "Network error " << error.state(); 120 LOG(WARNING) << "Network error " << error.state();
121 return; 121 return;
122 case GoogleServiceAuthError::NUM_STATES: 122 case GoogleServiceAuthError::NUM_STATES:
123 break; 123 break;
124 } 124 }
125 125
126 NOTREACHED(); 126 NOTREACHED();
127 UMAFailure(policy::kMetricEnrollmentOtherFailed); 127 UMAFailure(policy::kMetricEnrollmentOtherFailed);
128 } 128 }
129 129
130 void EnrollmentScreen::OnOAuthTokenAvailable( 130 void EnrollmentScreen::OnOAuthTokenAvailable(const std::string& token) {
131 const std::string& token) {
132 RegisterForDevicePolicy(token); 131 RegisterForDevicePolicy(token);
133 } 132 }
134 133
135 void EnrollmentScreen::OnRetry() { 134 void EnrollmentScreen::OnRetry() {
136 actor_->ResetAuth(base::Bind(&EnrollmentScreen::ShowSigninScreen, 135 actor_->ResetAuth(base::Bind(&EnrollmentScreen::ShowSigninScreen,
137 weak_ptr_factory_.GetWeakPtr())); 136 weak_ptr_factory_.GetWeakPtr()));
138 } 137 }
139 138
140 void EnrollmentScreen::OnCancel() { 139 void EnrollmentScreen::OnCancel() {
141 if (enrollment_mode_ == EnrollmentScreenActor::ENROLLMENT_MODE_FORCED || 140 if (enrollment_mode_ == EnrollmentScreenActor::ENROLLMENT_MODE_FORCED ||
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 get_screen_observer()->OnExit( 174 get_screen_observer()->OnExit(
176 ScreenObserver::ENTERPRISE_AUTO_MAGIC_ENROLLMENT_COMPLETED); 175 ScreenObserver::ENTERPRISE_AUTO_MAGIC_ENROLLMENT_COMPLETED);
177 } else { 176 } else {
178 actor_->ResetAuth( 177 actor_->ResetAuth(
179 base::Bind(&ScreenObserver::OnExit, 178 base::Bind(&ScreenObserver::OnExit,
180 base::Unretained(get_screen_observer()), 179 base::Unretained(get_screen_observer()),
181 ScreenObserver::ENTERPRISE_ENROLLMENT_COMPLETED)); 180 ScreenObserver::ENTERPRISE_ENROLLMENT_COMPLETED));
182 } 181 }
183 } 182 }
184 183
185 void EnrollmentScreen::RegisterForDevicePolicy( 184 void EnrollmentScreen::RegisterForDevicePolicy(const std::string& token) {
186 const std::string& token) {
187 policy::BrowserPolicyConnectorChromeOS* connector = 185 policy::BrowserPolicyConnectorChromeOS* connector =
188 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 186 g_browser_process->platform_part()->browser_policy_connector_chromeos();
189 if (connector->IsEnterpriseManaged() && 187 if (connector->IsEnterpriseManaged() &&
190 connector->GetEnterpriseDomain() != gaia::ExtractDomainName(user_)) { 188 connector->GetEnterpriseDomain() != gaia::ExtractDomainName(user_)) {
191 LOG(ERROR) << "Trying to re-enroll to a different domain than " 189 LOG(ERROR) << "Trying to re-enroll to a different domain than "
192 << connector->GetEnterpriseDomain(); 190 << connector->GetEnterpriseDomain();
193 UMAFailure(policy::kMetricEnrollmentWrongUserError); 191 UMAFailure(policy::kMetricEnrollmentWrongUserError);
194 actor_->ShowUIError( 192 actor_->ShowUIError(
195 EnrollmentScreenActor::UI_ERROR_DOMAIN_MISMATCH); 193 EnrollmentScreenActor::UI_ERROR_DOMAIN_MISMATCH);
196 return; 194 return;
(...skipping 14 matching lines...) Expand all
211 base::Bind(&EnrollmentScreen::ReportEnrollmentStatus, 209 base::Bind(&EnrollmentScreen::ReportEnrollmentStatus,
212 weak_ptr_factory_.GetWeakPtr())); 210 weak_ptr_factory_.GetWeakPtr()));
213 } 211 }
214 212
215 void EnrollmentScreen::ShowEnrollmentStatusOnSuccess( 213 void EnrollmentScreen::ShowEnrollmentStatusOnSuccess(
216 const policy::EnrollmentStatus& status) { 214 const policy::EnrollmentStatus& status) {
217 actor_->ShowEnrollmentStatus(status); 215 actor_->ShowEnrollmentStatus(status);
218 StartupUtils::MarkOobeCompleted(); 216 StartupUtils::MarkOobeCompleted();
219 } 217 }
220 218
221 void EnrollmentScreen::ReportEnrollmentStatus( 219 void EnrollmentScreen::ReportEnrollmentStatus(policy::EnrollmentStatus status) {
222 policy::EnrollmentStatus status) {
223 bool success = status.status() == policy::EnrollmentStatus::STATUS_SUCCESS;
224 enrollment_failed_once_ |= !success;
225 if (status.status() == policy::EnrollmentStatus::STATUS_SUCCESS) { 220 if (status.status() == policy::EnrollmentStatus::STATUS_SUCCESS) {
226 StartupUtils::MarkDeviceRegistered( 221 StartupUtils::MarkDeviceRegistered(
227 base::Bind(&EnrollmentScreen::ShowEnrollmentStatusOnSuccess, 222 base::Bind(&EnrollmentScreen::ShowEnrollmentStatusOnSuccess,
228 weak_ptr_factory_.GetWeakPtr(), 223 weak_ptr_factory_.GetWeakPtr(),
229 status)); 224 status));
230 UMA(is_auto_enrollment() ? policy::kMetricEnrollmentAutoOK 225 UMA(is_auto_enrollment() ? policy::kMetricEnrollmentAutoOK
231 : policy::kMetricEnrollmentOK); 226 : policy::kMetricEnrollmentOK);
232 return; 227 return;
228 } else {
229 enrollment_failed_once_ = true;
233 } 230 }
234 actor_->ShowEnrollmentStatus(status); 231 actor_->ShowEnrollmentStatus(status);
235 232
236 switch (status.status()) { 233 switch (status.status()) {
237 case policy::EnrollmentStatus::STATUS_REGISTRATION_FAILED: 234 case policy::EnrollmentStatus::STATUS_REGISTRATION_FAILED:
238 case policy::EnrollmentStatus::STATUS_POLICY_FETCH_FAILED: 235 case policy::EnrollmentStatus::STATUS_POLICY_FETCH_FAILED:
239 switch (status.client_status()) { 236 switch (status.client_status()) {
240 case policy::DM_STATUS_SUCCESS: 237 case policy::DM_STATUS_SUCCESS:
241 case policy::DM_STATUS_REQUEST_INVALID: 238 case policy::DM_STATUS_REQUEST_INVALID:
242 case policy::DM_STATUS_SERVICE_DEVICE_NOT_FOUND: 239 case policy::DM_STATUS_SERVICE_DEVICE_NOT_FOUND:
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 sample = policy::kMetricEnrollmentAutoFailed; 314 sample = policy::kMetricEnrollmentAutoFailed;
318 UMA(sample); 315 UMA(sample);
319 } 316 }
320 317
321 void EnrollmentScreen::ShowSigninScreen() { 318 void EnrollmentScreen::ShowSigninScreen() {
322 actor_->Show(); 319 actor_->Show();
323 actor_->ShowSigninScreen(); 320 actor_->ShowSigninScreen();
324 } 321 }
325 322
326 } // namespace chromeos 323 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698