| OLD | NEW |
| 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 "base/values.h" |
| 10 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 11 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 11 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 12 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 12 #include "chrome/browser/net/gaia/gaia_oauth_fetcher.h" | 13 #include "chrome/browser/net/gaia/gaia_oauth_fetcher.h" |
| 13 #include "chrome/browser/policy/cloud/message_util.h" | 14 #include "chrome/browser/policy/cloud/message_util.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 16 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| 16 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 17 #include "google_apis/gaia/gaia_auth_util.h" | 18 #include "google_apis/gaia/gaia_auth_util.h" |
| 18 #include "google_apis/gaia/gaia_constants.h" | 19 #include "google_apis/gaia/gaia_constants.h" |
| 19 #include "google_apis/gaia/gaia_switches.h" | 20 #include "google_apis/gaia/gaia_switches.h" |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 callbacks_to_run.swap(auth_reset_callbacks_); | 371 callbacks_to_run.swap(auth_reset_callbacks_); |
| 371 for (std::vector<base::Closure>::iterator callback(callbacks_to_run.begin()); | 372 for (std::vector<base::Closure>::iterator callback(callbacks_to_run.begin()); |
| 372 callback != callbacks_to_run.end(); ++callback) { | 373 callback != callbacks_to_run.end(); ++callback) { |
| 373 callback->Run(); | 374 callback->Run(); |
| 374 } | 375 } |
| 375 } | 376 } |
| 376 | 377 |
| 377 // EnterpriseOAuthEnrollmentScreenHandler, private ----------------------------- | 378 // EnterpriseOAuthEnrollmentScreenHandler, private ----------------------------- |
| 378 | 379 |
| 379 void EnterpriseOAuthEnrollmentScreenHandler::HandleClose( | 380 void EnterpriseOAuthEnrollmentScreenHandler::HandleClose( |
| 380 const base::ListValue* value) { | 381 const std::string& reason) { |
| 381 std::string reason; | |
| 382 CHECK_EQ(1U, value->GetSize()); | |
| 383 CHECK(value->GetString(0, &reason)); | |
| 384 | |
| 385 if (!controller_) { | 382 if (!controller_) { |
| 386 NOTREACHED(); | 383 NOTREACHED(); |
| 387 return; | 384 return; |
| 388 } | 385 } |
| 389 | 386 |
| 390 if (reason == "cancel" || reason == "autocancel") | 387 if (reason == "cancel" || reason == "autocancel") |
| 391 controller_->OnCancel(); | 388 controller_->OnCancel(); |
| 392 else if (reason == "done") | 389 else if (reason == "done") |
| 393 controller_->OnConfirmationClosed(); | 390 controller_->OnConfirmationClosed(); |
| 394 else | 391 else |
| 395 NOTREACHED(); | 392 NOTREACHED(); |
| 396 | 393 |
| 397 RevokeTokens(); | 394 RevokeTokens(); |
| 398 } | 395 } |
| 399 | 396 |
| 400 void EnterpriseOAuthEnrollmentScreenHandler::HandleCompleteLogin( | 397 void EnterpriseOAuthEnrollmentScreenHandler::HandleCompleteLogin( |
| 401 const base::ListValue* value) { | 398 const std::string& user) { |
| 402 if (!controller_) { | 399 if (!controller_) { |
| 403 NOTREACHED(); | 400 NOTREACHED(); |
| 404 return; | 401 return; |
| 405 } | 402 } |
| 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)); | 403 controller_->OnLoginDone(gaia::SanitizeEmail(user)); |
| 414 } | 404 } |
| 415 | 405 |
| 416 void EnterpriseOAuthEnrollmentScreenHandler::HandleRetry( | 406 void EnterpriseOAuthEnrollmentScreenHandler::HandleRetry() { |
| 417 const base::ListValue* value) { | |
| 418 if (!controller_) { | 407 if (!controller_) { |
| 419 NOTREACHED(); | 408 NOTREACHED(); |
| 420 return; | 409 return; |
| 421 } | 410 } |
| 422 | |
| 423 controller_->OnRetry(); | 411 controller_->OnRetry(); |
| 424 } | 412 } |
| 425 | 413 |
| 426 void EnterpriseOAuthEnrollmentScreenHandler::ShowStep(const char* step) { | 414 void EnterpriseOAuthEnrollmentScreenHandler::ShowStep(const char* step) { |
| 427 base::StringValue step_value(step); | 415 base::StringValue step_value(step); |
| 428 CallJS("oobe.OAuthEnrollmentScreen.showStep", | 416 CallJS("oobe.OAuthEnrollmentScreen.showStep", |
| 429 step_value); | 417 step_value); |
| 430 } | 418 } |
| 431 | 419 |
| 432 void EnterpriseOAuthEnrollmentScreenHandler::ShowError(int message_id, | 420 void EnterpriseOAuthEnrollmentScreenHandler::ShowError(int message_id, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 screen_data.SetBoolean("is_auto_enrollment", is_auto_enrollment_); | 477 screen_data.SetBoolean("is_auto_enrollment", is_auto_enrollment_); |
| 490 if (!test_email_.empty()) { | 478 if (!test_email_.empty()) { |
| 491 screen_data.SetString("test_email", test_email_); | 479 screen_data.SetString("test_email", test_email_); |
| 492 screen_data.SetString("test_password", test_password_); | 480 screen_data.SetString("test_password", test_password_); |
| 493 } | 481 } |
| 494 | 482 |
| 495 ShowScreen(OobeUI::kScreenOobeEnrollment, &screen_data); | 483 ShowScreen(OobeUI::kScreenOobeEnrollment, &screen_data); |
| 496 } | 484 } |
| 497 | 485 |
| 498 } // namespace chromeos | 486 } // namespace chromeos |
| OLD | NEW |