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

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

Issue 14208014: Simplify adding callbacks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | 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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "chrome/browser/browsing_data/browsing_data_helper.h" 10 #include "chrome/browser/browsing_data/browsing_data_helper.h"
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 callbacks_to_run.swap(auth_reset_callbacks_); 370 callbacks_to_run.swap(auth_reset_callbacks_);
371 for (std::vector<base::Closure>::iterator callback(callbacks_to_run.begin()); 371 for (std::vector<base::Closure>::iterator callback(callbacks_to_run.begin());
372 callback != callbacks_to_run.end(); ++callback) { 372 callback != callbacks_to_run.end(); ++callback) {
373 callback->Run(); 373 callback->Run();
374 } 374 }
375 } 375 }
376 376
377 // EnterpriseOAuthEnrollmentScreenHandler, private ----------------------------- 377 // EnterpriseOAuthEnrollmentScreenHandler, private -----------------------------
378 378
379 void EnterpriseOAuthEnrollmentScreenHandler::HandleClose( 379 void EnterpriseOAuthEnrollmentScreenHandler::HandleClose(
380 const base::ListValue* value) { 380 const std::string& reason) {
381 std::string reason;
382 CHECK_EQ(1U, value->GetSize());
383 CHECK(value->GetString(0, &reason));
384
385 if (!controller_) { 381 if (!controller_) {
386 NOTREACHED(); 382 NOTREACHED();
387 return; 383 return;
388 } 384 }
389 385
390 if (reason == "cancel" || reason == "autocancel") 386 if (reason == "cancel" || reason == "autocancel")
391 controller_->OnCancel(); 387 controller_->OnCancel();
392 else if (reason == "done") 388 else if (reason == "done")
393 controller_->OnConfirmationClosed(); 389 controller_->OnConfirmationClosed();
394 else 390 else
395 NOTREACHED(); 391 NOTREACHED();
396 392
397 RevokeTokens(); 393 RevokeTokens();
398 } 394 }
399 395
400 void EnterpriseOAuthEnrollmentScreenHandler::HandleCompleteLogin( 396 void EnterpriseOAuthEnrollmentScreenHandler::HandleCompleteLogin(
401 const base::ListValue* value) { 397 const std::string& user) {
402 if (!controller_) { 398 if (!controller_) {
403 NOTREACHED(); 399 NOTREACHED();
404 return; 400 return;
405 } 401 }
406
407 std::string user;
408 if (!value->GetString(0, &user)) {
409 NOTREACHED() << "Invalid user parameter from UI.";
410 return;
411 }
412
413 controller_->OnLoginDone(gaia::SanitizeEmail(user)); 402 controller_->OnLoginDone(gaia::SanitizeEmail(user));
414 } 403 }
415 404
416 void EnterpriseOAuthEnrollmentScreenHandler::HandleRetry( 405 void EnterpriseOAuthEnrollmentScreenHandler::HandleRetry() {
417 const base::ListValue* value) {
418 if (!controller_) { 406 if (!controller_) {
419 NOTREACHED(); 407 NOTREACHED();
420 return; 408 return;
421 } 409 }
422
423 controller_->OnRetry(); 410 controller_->OnRetry();
424 } 411 }
425 412
426 void EnterpriseOAuthEnrollmentScreenHandler::ShowStep(const char* step) { 413 void EnterpriseOAuthEnrollmentScreenHandler::ShowStep(const char* step) {
427 base::StringValue step_value(step); 414 base::StringValue step_value(step);
428 CallJS("oobe.OAuthEnrollmentScreen.showStep", 415 CallJS("oobe.OAuthEnrollmentScreen.showStep",
429 step_value); 416 step_value);
430 } 417 }
431 418
432 void EnterpriseOAuthEnrollmentScreenHandler::ShowError(int message_id, 419 void EnterpriseOAuthEnrollmentScreenHandler::ShowError(int message_id,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 screen_data.SetBoolean("is_auto_enrollment", is_auto_enrollment_); 476 screen_data.SetBoolean("is_auto_enrollment", is_auto_enrollment_);
490 if (!test_email_.empty()) { 477 if (!test_email_.empty()) {
491 screen_data.SetString("test_email", test_email_); 478 screen_data.SetString("test_email", test_email_);
492 screen_data.SetString("test_password", test_password_); 479 screen_data.SetString("test_password", test_password_);
493 } 480 }
494 481
495 ShowScreen(OobeUI::kScreenOobeEnrollment, &screen_data); 482 ShowScreen(OobeUI::kScreenOobeEnrollment, &screen_data);
496 } 483 }
497 484
498 } // namespace chromeos 485 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698