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

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/enterprise_oauth_enrollment_screen_handler.cc

Issue 10408072: Rewrite of the EnrollEnterpriseDevice PyAuto automation hook for WebUI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: std::string -> const std::string& and style fixes Created 8 years, 7 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 | Annotate | Revision Log
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/ui/webui/chromeos/login/enterprise_oauth_enrollment_scr een_handler.h" 5 #include "chrome/browser/ui/webui/chromeos/login/enterprise_oauth_enrollment_scr een_handler.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/callback.h" 9 #include "base/callback.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 void EnterpriseOAuthEnrollmentScreenHandler::Hide() { 146 void EnterpriseOAuthEnrollmentScreenHandler::Hide() {
147 } 147 }
148 148
149 void EnterpriseOAuthEnrollmentScreenHandler::ShowConfirmationScreen() { 149 void EnterpriseOAuthEnrollmentScreenHandler::ShowConfirmationScreen() {
150 UMA(is_auto_enrollment_ ? policy::kMetricEnrollmentAutoOK : 150 UMA(is_auto_enrollment_ ? policy::kMetricEnrollmentAutoOK :
151 policy::kMetricEnrollmentOK); 151 policy::kMetricEnrollmentOK);
152 ShowStep(kEnrollmentStepSuccess); 152 ShowStep(kEnrollmentStepSuccess);
153 if (!is_auto_enrollment_ || enrollment_failed_once_) 153 if (!is_auto_enrollment_ || enrollment_failed_once_)
154 ResetAuth(); 154 ResetAuth();
155 NotifyObservers(true); 155 NotifyObservers(true, "");
156 } 156 }
157 157
158 void EnterpriseOAuthEnrollmentScreenHandler::ShowAuthError( 158 void EnterpriseOAuthEnrollmentScreenHandler::ShowAuthError(
159 const GoogleServiceAuthError& error) { 159 const GoogleServiceAuthError& error) {
160 switch (error.state()) { 160 switch (error.state()) {
161 case GoogleServiceAuthError::NONE: 161 case GoogleServiceAuthError::NONE:
162 case GoogleServiceAuthError::CAPTCHA_REQUIRED: 162 case GoogleServiceAuthError::CAPTCHA_REQUIRED:
163 case GoogleServiceAuthError::TWO_FACTOR: 163 case GoogleServiceAuthError::TWO_FACTOR:
164 case GoogleServiceAuthError::HOSTED_NOT_ALLOWED: 164 case GoogleServiceAuthError::HOSTED_NOT_ALLOWED:
165 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS: 165 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS:
(...skipping 13 matching lines...) Expand all
179 ShowNetworkEnrollmentError(); 179 ShowNetworkEnrollmentError();
180 return; 180 return;
181 } 181 }
182 UMAFailure(policy::kMetricEnrollmentOtherFailed); 182 UMAFailure(policy::kMetricEnrollmentOtherFailed);
183 NOTREACHED(); 183 NOTREACHED();
184 } 184 }
185 185
186 void EnterpriseOAuthEnrollmentScreenHandler::ShowAccountError() { 186 void EnterpriseOAuthEnrollmentScreenHandler::ShowAccountError() {
187 UMAFailure(policy::kMetricEnrollmentNotSupported); 187 UMAFailure(policy::kMetricEnrollmentNotSupported);
188 ShowError(IDS_ENTERPRISE_ENROLLMENT_ACCOUNT_ERROR, true); 188 ShowError(IDS_ENTERPRISE_ENROLLMENT_ACCOUNT_ERROR, true);
189 NotifyObservers(false);
190 } 189 }
191 190
192 void EnterpriseOAuthEnrollmentScreenHandler::ShowSerialNumberError() { 191 void EnterpriseOAuthEnrollmentScreenHandler::ShowSerialNumberError() {
193 UMAFailure(policy::kMetricEnrollmentInvalidSerialNumber); 192 UMAFailure(policy::kMetricEnrollmentInvalidSerialNumber);
194 ShowError(IDS_ENTERPRISE_ENROLLMENT_SERIAL_NUMBER_ERROR, true); 193 ShowError(IDS_ENTERPRISE_ENROLLMENT_SERIAL_NUMBER_ERROR, true);
195 NotifyObservers(false);
196 } 194 }
197 195
198 void EnterpriseOAuthEnrollmentScreenHandler::ShowEnrollmentModeError() { 196 void EnterpriseOAuthEnrollmentScreenHandler::ShowEnrollmentModeError() {
199 UMAFailure(policy::kMetricEnrollmentInvalidEnrollmentMode); 197 UMAFailure(policy::kMetricEnrollmentInvalidEnrollmentMode);
200 ShowError(IDS_ENTERPRISE_ENROLLMENT_MODE_ERROR, false); 198 ShowError(IDS_ENTERPRISE_ENROLLMENT_MODE_ERROR, false);
201 NotifyObservers(false);
202 } 199 }
203 200
204 void EnterpriseOAuthEnrollmentScreenHandler::ShowFatalAuthError() { 201 void EnterpriseOAuthEnrollmentScreenHandler::ShowFatalAuthError() {
205 UMAFailure(policy::kMetricEnrollmentLoginFailed); 202 UMAFailure(policy::kMetricEnrollmentLoginFailed);
206 ShowError(IDS_ENTERPRISE_ENROLLMENT_FATAL_AUTH_ERROR, false); 203 ShowError(IDS_ENTERPRISE_ENROLLMENT_FATAL_AUTH_ERROR, false);
207 NotifyObservers(false);
208 } 204 }
209 205
210 void EnterpriseOAuthEnrollmentScreenHandler::ShowFatalEnrollmentError() { 206 void EnterpriseOAuthEnrollmentScreenHandler::ShowFatalEnrollmentError() {
211 UMAFailure(policy::kMetricEnrollmentOtherFailed); 207 UMAFailure(policy::kMetricEnrollmentOtherFailed);
212 ShowError(IDS_ENTERPRISE_ENROLLMENT_FATAL_ENROLLMENT_ERROR, false); 208 ShowError(IDS_ENTERPRISE_ENROLLMENT_FATAL_ENROLLMENT_ERROR, false);
213 NotifyObservers(false);
214 } 209 }
215 210
216 void EnterpriseOAuthEnrollmentScreenHandler::ShowAutoEnrollmentError() { 211 void EnterpriseOAuthEnrollmentScreenHandler::ShowAutoEnrollmentError() {
217 UMAFailure(policy::kMetricEnrollmentAutoEnrollmentNotSupported); 212 UMAFailure(policy::kMetricEnrollmentAutoEnrollmentNotSupported);
218 // The reason for showing this error is that we have been trying to 213 // The reason for showing this error is that we have been trying to
219 // auto-enroll and this failed, so we have to verify whether auto-enrollment 214 // auto-enroll and this failed, so we have to verify whether auto-enrollment
220 // is on, and if so switch it off, update the UI accordingly and show the 215 // is on, and if so switch it off, update the UI accordingly and show the
221 // error message. 216 // error message.
222 std::string user; 217 std::string user;
223 is_auto_enrollment_ = controller_ && controller_->IsAutoEnrollment(&user); 218 is_auto_enrollment_ = controller_ && controller_->IsAutoEnrollment(&user);
224 base::FundamentalValue value(is_auto_enrollment_); 219 base::FundamentalValue value(is_auto_enrollment_);
225 web_ui()->CallJavascriptFunction( 220 web_ui()->CallJavascriptFunction(
226 "oobe.OAuthEnrollmentScreen.setIsAutoEnrollment", value); 221 "oobe.OAuthEnrollmentScreen.setIsAutoEnrollment", value);
227 222
228 ShowError(IDS_ENTERPRISE_AUTO_ENROLLMENT_ERROR, false); 223 ShowError(IDS_ENTERPRISE_AUTO_ENROLLMENT_ERROR, false);
229 NotifyObservers(false);
230 } 224 }
231 225
232 void EnterpriseOAuthEnrollmentScreenHandler::ShowNetworkEnrollmentError() { 226 void EnterpriseOAuthEnrollmentScreenHandler::ShowNetworkEnrollmentError() {
233 UMAFailure(policy::kMetricEnrollmentNetworkFailed); 227 UMAFailure(policy::kMetricEnrollmentNetworkFailed);
234 ShowError(IDS_ENTERPRISE_ENROLLMENT_NETWORK_ENROLLMENT_ERROR, true); 228 ShowError(IDS_ENTERPRISE_ENROLLMENT_NETWORK_ENROLLMENT_ERROR, true);
235 NotifyObservers(false);
236 }
237
238 void EnterpriseOAuthEnrollmentScreenHandler::SubmitTestCredentials(
239 const std::string& email,
240 const std::string& password) {
241 test_email_ = email;
242 test_password_ = password;
243 DoShow();
244 } 229 }
245 230
246 // EnterpriseOAuthEnrollmentScreenHandler BaseScreenHandler implementation ----- 231 // EnterpriseOAuthEnrollmentScreenHandler BaseScreenHandler implementation -----
247 232
248 void EnterpriseOAuthEnrollmentScreenHandler::Initialize() { 233 void EnterpriseOAuthEnrollmentScreenHandler::Initialize() {
249 if (show_on_init_) { 234 if (show_on_init_) {
250 Show(); 235 Show();
251 show_on_init_ = false; 236 show_on_init_ = false;
252 } 237 }
253 } 238 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 action_on_browsing_data_removed_ = 377 action_on_browsing_data_removed_ =
393 base::Bind(&EnterpriseOAuthEnrollmentScreenHandler::DoClose, 378 base::Bind(&EnterpriseOAuthEnrollmentScreenHandler::DoClose,
394 base::Unretained(this), 379 base::Unretained(this),
395 true); 380 true);
396 ResetAuth(); 381 ResetAuth();
397 } else { 382 } else {
398 // Not going back to sign-in, letting the initial sign-in resume instead. 383 // Not going back to sign-in, letting the initial sign-in resume instead.
399 // In that case, keep the profile data. 384 // In that case, keep the profile data.
400 DoClose(false); 385 DoClose(false);
401 } 386 }
387
388 NotifyObservers(false, "Oauth enrollment cancelled");
Mattias Nissler (ping if slow) 2012/05/25 13:17:22 Should be "OAuth" (capital A). Also, I feel a bit
craigdh 2012/05/25 23:24:47 Done. Including a string literal is certainly not
402 } 389 }
403 390
404 void EnterpriseOAuthEnrollmentScreenHandler::HandleCompleteLogin( 391 void EnterpriseOAuthEnrollmentScreenHandler::HandleCompleteLogin(
405 const base::ListValue* value) { 392 const base::ListValue* value) {
406 if (!controller_) { 393 if (!controller_) {
407 NOTREACHED(); 394 NOTREACHED();
408 return; 395 return;
409 } 396 }
410 397
411 std::string user; 398 std::string user;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 bool retry) { 447 bool retry) {
461 RevokeTokens(); 448 RevokeTokens();
462 enrollment_failed_once_ = true; 449 enrollment_failed_once_ = true;
463 450
464 const std::string message(l10n_util::GetStringUTF8(message_id)); 451 const std::string message(l10n_util::GetStringUTF8(message_id));
465 base::StringValue message_value(message); 452 base::StringValue message_value(message);
466 base::FundamentalValue retry_value(retry); 453 base::FundamentalValue retry_value(retry);
467 web_ui()->CallJavascriptFunction("oobe.OAuthEnrollmentScreen.showError", 454 web_ui()->CallJavascriptFunction("oobe.OAuthEnrollmentScreen.showError",
468 message_value, 455 message_value,
469 retry_value); 456 retry_value);
457 NotifyObservers(false, message);
470 } 458 }
471 459
472 void EnterpriseOAuthEnrollmentScreenHandler::ShowWorking(int message_id) { 460 void EnterpriseOAuthEnrollmentScreenHandler::ShowWorking(int message_id) {
473 const std::string message(l10n_util::GetStringUTF8(message_id)); 461 const std::string message(l10n_util::GetStringUTF8(message_id));
474 base::StringValue message_value(message); 462 base::StringValue message_value(message);
475 web_ui()->CallJavascriptFunction("oobe.OAuthEnrollmentScreen.showWorking", 463 web_ui()->CallJavascriptFunction("oobe.OAuthEnrollmentScreen.showWorking",
476 message_value); 464 message_value);
477 } 465 }
478 466
479 void EnterpriseOAuthEnrollmentScreenHandler::ResetAuth() { 467 void EnterpriseOAuthEnrollmentScreenHandler::ResetAuth() {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 controller_->OnConfirmationClosed(back_to_signin); 525 controller_->OnConfirmationClosed(back_to_signin);
538 } 526 }
539 527
540 void EnterpriseOAuthEnrollmentScreenHandler::UMAFailure(int sample) { 528 void EnterpriseOAuthEnrollmentScreenHandler::UMAFailure(int sample) {
541 if (is_auto_enrollment_) 529 if (is_auto_enrollment_)
542 sample = policy::kMetricEnrollmentAutoFailed; 530 sample = policy::kMetricEnrollmentAutoFailed;
543 UMA(sample); 531 UMA(sample);
544 } 532 }
545 533
546 } // namespace chromeos 534 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698