OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/gaia_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/guid.h" | 8 #include "base/guid.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 210 |
211 params.SetBoolean("forceReload", context.force_reload); | 211 params.SetBoolean("forceReload", context.force_reload); |
212 params.SetBoolean("isLocal", context.is_local); | 212 params.SetBoolean("isLocal", context.is_local); |
213 params.SetBoolean("passwordChanged", context.password_changed); | 213 params.SetBoolean("passwordChanged", context.password_changed); |
214 params.SetBoolean("isShowUsers", context.show_users); | 214 params.SetBoolean("isShowUsers", context.show_users); |
215 params.SetBoolean("useOffline", context.use_offline); | 215 params.SetBoolean("useOffline", context.use_offline); |
216 params.SetString("gaiaId", context.gaia_id); | 216 params.SetString("gaiaId", context.gaia_id); |
217 params.SetString("email", context.email); | 217 params.SetString("email", context.email); |
218 params.SetBoolean("isEnrollingConsumerManagement", | 218 params.SetBoolean("isEnrollingConsumerManagement", |
219 is_enrolling_consumer_management); | 219 is_enrolling_consumer_management); |
| 220 params.SetString("gapsCookie", context.gaps_cookie); |
220 | 221 |
221 UpdateAuthParams(¶ms, | 222 UpdateAuthParams(¶ms, |
222 context.has_users, | 223 context.has_users, |
223 is_enrolling_consumer_management); | 224 is_enrolling_consumer_management); |
224 | 225 |
225 if (!context.use_offline) { | 226 if (!context.use_offline) { |
226 const std::string app_locale = g_browser_process->GetApplicationLocale(); | 227 const std::string app_locale = g_browser_process->GetApplicationLocale(); |
227 if (!app_locale.empty()) | 228 if (!app_locale.empty()) |
228 params.SetString("hl", app_locale); | 229 params.SetString("hl", app_locale); |
229 } else { | 230 } else { |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 NetworkError::ERROR_REASON_FRAME_ERROR; | 488 NetworkError::ERROR_REASON_FRAME_ERROR; |
488 frame_state_ = FRAME_STATE_ERROR; | 489 frame_state_ = FRAME_STATE_ERROR; |
489 UpdateState(error_reason); | 490 UpdateState(error_reason); |
490 } | 491 } |
491 | 492 |
492 void GaiaScreenHandler::HandleCompleteAuthentication( | 493 void GaiaScreenHandler::HandleCompleteAuthentication( |
493 const std::string& gaia_id, | 494 const std::string& gaia_id, |
494 const std::string& email, | 495 const std::string& email, |
495 const std::string& password, | 496 const std::string& password, |
496 const std::string& auth_code, | 497 const std::string& auth_code, |
497 bool using_saml) { | 498 bool using_saml, |
| 499 const std::string& gaps_cookie) { |
498 if (!Delegate()) | 500 if (!Delegate()) |
499 return; | 501 return; |
500 | 502 |
501 RecordGAIAFlowTypeHistogram(); | 503 RecordGAIAFlowTypeHistogram(); |
502 | 504 |
503 DCHECK(!email.empty()); | 505 DCHECK(!email.empty()); |
504 DCHECK(!gaia_id.empty()); | 506 DCHECK(!gaia_id.empty()); |
505 const std::string sanitized_email = gaia::SanitizeEmail(email); | 507 const std::string sanitized_email = gaia::SanitizeEmail(email); |
506 Delegate()->SetDisplayEmail(sanitized_email); | 508 Delegate()->SetDisplayEmail(sanitized_email); |
507 UserContext user_context(sanitized_email); | 509 UserContext user_context(sanitized_email); |
508 user_context.SetGaiaID(gaia_id); | 510 user_context.SetGaiaID(gaia_id); |
509 user_context.SetKey(Key(password)); | 511 user_context.SetKey(Key(password)); |
510 user_context.SetAuthCode(auth_code); | 512 user_context.SetAuthCode(auth_code); |
511 user_context.SetAuthFlow(using_saml | 513 user_context.SetAuthFlow(using_saml |
512 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML | 514 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML |
513 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML); | 515 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML); |
| 516 user_context.SetGAPSCookie(gaps_cookie); |
514 Delegate()->CompleteLogin(user_context); | 517 Delegate()->CompleteLogin(user_context); |
515 } | 518 } |
516 | 519 |
517 void GaiaScreenHandler::HandleCompleteAuthenticationAuthCodeOnly( | 520 void GaiaScreenHandler::HandleCompleteAuthenticationAuthCodeOnly( |
518 const std::string& auth_code) { | 521 const std::string& auth_code) { |
519 if (!Delegate()) | 522 if (!Delegate()) |
520 return; | 523 return; |
521 | 524 |
522 RecordGAIAFlowTypeHistogram(); | 525 RecordGAIAFlowTypeHistogram(); |
523 | 526 |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 | 928 |
926 std::string gaia_id; | 929 std::string gaia_id; |
927 if (user_manager::UserManager::Get()->FindGaiaID(context.email, &gaia_id)) | 930 if (user_manager::UserManager::Get()->FindGaiaID(context.email, &gaia_id)) |
928 context.gaia_id = gaia_id; | 931 context.gaia_id = gaia_id; |
929 | 932 |
930 if (Delegate()) { | 933 if (Delegate()) { |
931 context.show_users = Delegate()->IsShowUsers(); | 934 context.show_users = Delegate()->IsShowUsers(); |
932 context.has_users = !Delegate()->GetUsers().empty(); | 935 context.has_users = !Delegate()->GetUsers().empty(); |
933 } | 936 } |
934 | 937 |
| 938 if (!context.email.empty()) { |
| 939 context.gaps_cookie = |
| 940 user_manager::UserManager::Get()->GetKnownUserGAPSCookie( |
| 941 gaia::CanonicalizeEmail(context.email)); |
| 942 } |
| 943 |
935 populated_email_.clear(); | 944 populated_email_.clear(); |
936 | 945 |
937 LoadGaia(context); | 946 LoadGaia(context); |
938 } | 947 } |
939 | 948 |
940 void GaiaScreenHandler::UpdateState(NetworkError::ErrorReason reason) { | 949 void GaiaScreenHandler::UpdateState(NetworkError::ErrorReason reason) { |
941 if (signin_screen_handler_) | 950 if (signin_screen_handler_) |
942 signin_screen_handler_->UpdateState(reason); | 951 signin_screen_handler_->UpdateState(reason); |
943 } | 952 } |
944 | 953 |
945 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { | 954 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { |
946 DCHECK(signin_screen_handler_); | 955 DCHECK(signin_screen_handler_); |
947 return signin_screen_handler_->delegate_; | 956 return signin_screen_handler_->delegate_; |
948 } | 957 } |
949 | 958 |
950 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) { | 959 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) { |
951 signin_screen_handler_ = handler; | 960 signin_screen_handler_ = handler; |
952 } | 961 } |
953 | 962 |
954 } // namespace chromeos | 963 } // namespace chromeos |
OLD | NEW |