| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
| 30 | 30 |
| 31 using content::BrowserThread; | 31 using content::BrowserThread; |
| 32 | 32 |
| 33 namespace chromeos { | 33 namespace chromeos { |
| 34 | 34 |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| 37 const char kJsScreenPath[] = "login.GaiaSigninScreen"; | 37 const char kJsScreenPath[] = "login.GaiaSigninScreen"; |
| 38 | 38 |
| 39 void UpdateAuthParams(base::DictionaryValue* params, bool has_users) { | 39 void UpdateAuthParams(base::DictionaryValue* params, bool has_users, |
| 40 bool is_enrolling_consumer_management) { |
| 40 CrosSettings* cros_settings = CrosSettings::Get(); | 41 CrosSettings* cros_settings = CrosSettings::Get(); |
| 41 bool allow_new_user = true; | 42 bool allow_new_user = true; |
| 42 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 43 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
| 43 bool allow_guest = true; | 44 bool allow_guest = true; |
| 44 cros_settings->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); | 45 cros_settings->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); |
| 45 // Account creation depends on Guest sign-in (http://crosbug.com/24570). | 46 // Account creation depends on Guest sign-in (http://crosbug.com/24570). |
| 46 params->SetBoolean("createAccount", allow_new_user && allow_guest); | 47 params->SetBoolean("createAccount", allow_new_user && allow_guest); |
| 47 params->SetBoolean("guestSignin", allow_guest); | 48 params->SetBoolean("guestSignin", allow_guest); |
| 48 | 49 |
| 49 // Allow supervised user creation only if: | 50 // Allow supervised user creation only if: |
| (...skipping 16 matching lines...) Expand all Loading... |
| 66 | 67 |
| 67 params->SetBoolean("managedUsersEnabled", supervised_users_allowed); | 68 params->SetBoolean("managedUsersEnabled", supervised_users_allowed); |
| 68 params->SetBoolean("managedUsersCanCreate", supervised_users_can_create); | 69 params->SetBoolean("managedUsersCanCreate", supervised_users_can_create); |
| 69 if (!supervised_users_can_create) { | 70 if (!supervised_users_can_create) { |
| 70 params->SetString("managedUsersRestrictionReason", | 71 params->SetString("managedUsersRestrictionReason", |
| 71 l10n_util::GetStringUTF16(message_id)); | 72 l10n_util::GetStringUTF16(message_id)); |
| 72 } | 73 } |
| 73 | 74 |
| 74 // Now check whether we're in multi-profiles user adding scenario and | 75 // Now check whether we're in multi-profiles user adding scenario and |
| 75 // disable GAIA right panel features if that's the case. | 76 // disable GAIA right panel features if that's the case. |
| 76 if (UserAddingScreen::Get()->IsRunning()) { | 77 // For consumer management enrollment, we also hide all right panel components |
| 78 // and show only an enrollment message. |
| 79 if (UserAddingScreen::Get()->IsRunning() || |
| 80 is_enrolling_consumer_management) { |
| 77 params->SetBoolean("createAccount", false); | 81 params->SetBoolean("createAccount", false); |
| 78 params->SetBoolean("guestSignin", false); | 82 params->SetBoolean("guestSignin", false); |
| 79 params->SetBoolean("managedUsersEnabled", false); | 83 params->SetBoolean("managedUsersEnabled", false); |
| 80 } | 84 } |
| 81 } | 85 } |
| 82 | 86 |
| 83 void RecordSAMLScrapingVerificationResultInHistogram(bool success) { | 87 void RecordSAMLScrapingVerificationResultInHistogram(bool success) { |
| 84 UMA_HISTOGRAM_BOOLEAN("ChromeOS.SAML.Scraping.VerificationResult", success); | 88 UMA_HISTOGRAM_BOOLEAN("ChromeOS.SAML.Scraping.VerificationResult", success); |
| 85 } | 89 } |
| 86 | 90 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 109 : BaseScreenHandler(kJsScreenPath), | 113 : BaseScreenHandler(kJsScreenPath), |
| 110 frame_state_(FRAME_STATE_UNKNOWN), | 114 frame_state_(FRAME_STATE_UNKNOWN), |
| 111 frame_error_(net::OK), | 115 frame_error_(net::OK), |
| 112 network_state_informer_(network_state_informer), | 116 network_state_informer_(network_state_informer), |
| 113 dns_cleared_(false), | 117 dns_cleared_(false), |
| 114 dns_clear_task_running_(false), | 118 dns_clear_task_running_(false), |
| 115 cookies_cleared_(false), | 119 cookies_cleared_(false), |
| 116 focus_stolen_(false), | 120 focus_stolen_(false), |
| 117 gaia_silent_load_(false), | 121 gaia_silent_load_(false), |
| 118 using_saml_api_(false), | 122 using_saml_api_(false), |
| 123 is_enrolling_consumer_management_(false), |
| 119 test_expects_complete_login_(false), | 124 test_expects_complete_login_(false), |
| 120 signin_screen_handler_(NULL), | 125 signin_screen_handler_(NULL), |
| 121 weak_factory_(this) { | 126 weak_factory_(this) { |
| 122 DCHECK(network_state_informer_.get()); | 127 DCHECK(network_state_informer_.get()); |
| 123 } | 128 } |
| 124 | 129 |
| 125 GaiaScreenHandler::~GaiaScreenHandler() { | 130 GaiaScreenHandler::~GaiaScreenHandler() { |
| 126 } | 131 } |
| 127 | 132 |
| 128 void GaiaScreenHandler::LoadGaia(const GaiaContext& context) { | 133 void GaiaScreenHandler::LoadGaia(const GaiaContext& context) { |
| 129 base::DictionaryValue params; | 134 base::DictionaryValue params; |
| 130 | 135 |
| 131 params.SetBoolean("forceReload", context.force_reload); | 136 params.SetBoolean("forceReload", context.force_reload); |
| 132 params.SetBoolean("isLocal", context.is_local); | 137 params.SetBoolean("isLocal", context.is_local); |
| 133 params.SetBoolean("passwordChanged", context.password_changed); | 138 params.SetBoolean("passwordChanged", context.password_changed); |
| 134 params.SetBoolean("isShowUsers", context.show_users); | 139 params.SetBoolean("isShowUsers", context.show_users); |
| 135 params.SetBoolean("useOffline", context.use_offline); | 140 params.SetBoolean("useOffline", context.use_offline); |
| 136 params.SetString("email", context.email); | 141 params.SetString("email", context.email); |
| 142 params.SetBoolean("isEnrollingConsumerManagement", |
| 143 context.is_enrolling_consumer_management); |
| 137 | 144 |
| 138 UpdateAuthParams(¶ms, context.has_users); | 145 UpdateAuthParams(¶ms, context.has_users, |
| 146 context.is_enrolling_consumer_management); |
| 139 | 147 |
| 140 if (!context.use_offline) { | 148 if (!context.use_offline) { |
| 141 const std::string app_locale = g_browser_process->GetApplicationLocale(); | 149 const std::string app_locale = g_browser_process->GetApplicationLocale(); |
| 142 if (!app_locale.empty()) | 150 if (!app_locale.empty()) |
| 143 params.SetString("hl", app_locale); | 151 params.SetString("hl", app_locale); |
| 144 } else { | 152 } else { |
| 145 base::DictionaryValue* localized_strings = new base::DictionaryValue(); | 153 base::DictionaryValue* localized_strings = new base::DictionaryValue(); |
| 146 localized_strings->SetString( | 154 localized_strings->SetString( |
| 147 "stringEmail", l10n_util::GetStringUTF16(IDS_LOGIN_OFFLINE_EMAIL)); | 155 "stringEmail", l10n_util::GetStringUTF16(IDS_LOGIN_OFFLINE_EMAIL)); |
| 148 localized_strings->SetString( | 156 localized_strings->SetString( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 171 | 179 |
| 172 if (command_line->HasSwitch(chromeos::switches::kEnableEmbeddedSignin)) | 180 if (command_line->HasSwitch(chromeos::switches::kEnableEmbeddedSignin)) |
| 173 params.SetBoolean("useEmbedded", true); | 181 params.SetBoolean("useEmbedded", true); |
| 174 | 182 |
| 175 frame_state_ = FRAME_STATE_LOADING; | 183 frame_state_ = FRAME_STATE_LOADING; |
| 176 CallJS("loadAuthExtension", params); | 184 CallJS("loadAuthExtension", params); |
| 177 } | 185 } |
| 178 | 186 |
| 179 void GaiaScreenHandler::UpdateGaia(const GaiaContext& context) { | 187 void GaiaScreenHandler::UpdateGaia(const GaiaContext& context) { |
| 180 base::DictionaryValue params; | 188 base::DictionaryValue params; |
| 181 UpdateAuthParams(¶ms, context.has_users); | 189 UpdateAuthParams(¶ms, context.has_users, |
| 190 context.is_enrolling_consumer_management); |
| 182 CallJS("updateAuthExtension", params); | 191 CallJS("updateAuthExtension", params); |
| 183 } | 192 } |
| 184 | 193 |
| 185 void GaiaScreenHandler::ReloadGaia(bool force_reload) { | 194 void GaiaScreenHandler::ReloadGaia(bool force_reload) { |
| 186 if (frame_state_ == FRAME_STATE_LOADING && !force_reload) { | 195 if (frame_state_ == FRAME_STATE_LOADING && !force_reload) { |
| 187 VLOG(1) << "Skipping reloading of Gaia since gaia is loading."; | 196 VLOG(1) << "Skipping reloading of Gaia since gaia is loading."; |
| 188 return; | 197 return; |
| 189 } | 198 } |
| 190 NetworkStateInformer::State state = network_state_informer_->state(); | 199 NetworkStateInformer::State state = network_state_informer_->state(); |
| 191 if (state != NetworkStateInformer::ONLINE) { | 200 if (state != NetworkStateInformer::ONLINE) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 202 LocalizedValuesBuilder* builder) { | 211 LocalizedValuesBuilder* builder) { |
| 203 builder->Add("signinScreenTitle", IDS_SIGNIN_SCREEN_TITLE); | 212 builder->Add("signinScreenTitle", IDS_SIGNIN_SCREEN_TITLE); |
| 204 builder->Add("signinScreenPasswordChanged", | 213 builder->Add("signinScreenPasswordChanged", |
| 205 IDS_SIGNIN_SCREEN_PASSWORD_CHANGED); | 214 IDS_SIGNIN_SCREEN_PASSWORD_CHANGED); |
| 206 builder->Add("createAccount", IDS_CREATE_ACCOUNT_HTML); | 215 builder->Add("createAccount", IDS_CREATE_ACCOUNT_HTML); |
| 207 builder->Add("guestSignin", IDS_BROWSE_WITHOUT_SIGNING_IN_HTML); | 216 builder->Add("guestSignin", IDS_BROWSE_WITHOUT_SIGNING_IN_HTML); |
| 208 builder->Add("createLocallyManagedUser", | 217 builder->Add("createLocallyManagedUser", |
| 209 IDS_CREATE_LOCALLY_MANAGED_USER_HTML); | 218 IDS_CREATE_LOCALLY_MANAGED_USER_HTML); |
| 210 builder->Add("createManagedUserFeatureName", | 219 builder->Add("createManagedUserFeatureName", |
| 211 IDS_CREATE_LOCALLY_MANAGED_USER_FEATURE_NAME); | 220 IDS_CREATE_LOCALLY_MANAGED_USER_FEATURE_NAME); |
| 221 builder->Add("consumerManagementEnrollmentSigninMessage", |
| 222 IDS_LOGIN_CONSUMER_MANAGEMENT_ENROLLMENT); |
| 212 | 223 |
| 213 // Strings used by the SAML fatal error dialog. | 224 // Strings used by the SAML fatal error dialog. |
| 214 builder->Add("fatalErrorMessageNoEmail", IDS_LOGIN_FATAL_ERROR_NO_EMAIL); | 225 builder->Add("fatalErrorMessageNoEmail", IDS_LOGIN_FATAL_ERROR_NO_EMAIL); |
| 215 builder->Add("fatalErrorMessageNoPassword", | 226 builder->Add("fatalErrorMessageNoPassword", |
| 216 IDS_LOGIN_FATAL_ERROR_NO_PASSWORD); | 227 IDS_LOGIN_FATAL_ERROR_NO_PASSWORD); |
| 217 builder->Add("fatalErrorMessageVerificationFailed", | 228 builder->Add("fatalErrorMessageVerificationFailed", |
| 218 IDS_LOGIN_FATAL_ERROR_PASSWORD_VERIFICATION); | 229 IDS_LOGIN_FATAL_ERROR_PASSWORD_VERIFICATION); |
| 219 builder->Add("fatalErrorMessageInsecureURL", | 230 builder->Add("fatalErrorMessageInsecureURL", |
| 220 IDS_LOGIN_FATAL_ERROR_TEXT_INSECURE_URL); | 231 IDS_LOGIN_FATAL_ERROR_TEXT_INSECURE_URL); |
| 221 builder->Add("fatalErrorInstructions", IDS_LOGIN_FATAL_ERROR_INSTRUCTIONS); | 232 builder->Add("fatalErrorInstructions", IDS_LOGIN_FATAL_ERROR_INSTRUCTIONS); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 // Test properties are cleared in HandleCompleteLogin because the form | 450 // Test properties are cleared in HandleCompleteLogin because the form |
| 440 // submission might fail and login will not be attempted after reloading | 451 // submission might fail and login will not be attempted after reloading |
| 441 // if they are cleared here. | 452 // if they are cleared here. |
| 442 } | 453 } |
| 443 | 454 |
| 444 void GaiaScreenHandler::SetSAMLPrincipalsAPIUsed(bool api_used) { | 455 void GaiaScreenHandler::SetSAMLPrincipalsAPIUsed(bool api_used) { |
| 445 using_saml_api_ = api_used; | 456 using_saml_api_ = api_used; |
| 446 UMA_HISTOGRAM_BOOLEAN("ChromeOS.SAML.APIUsed", api_used); | 457 UMA_HISTOGRAM_BOOLEAN("ChromeOS.SAML.APIUsed", api_used); |
| 447 } | 458 } |
| 448 | 459 |
| 449 void GaiaScreenHandler::ShowGaia() { | 460 void GaiaScreenHandler::ShowGaia(bool is_enrolling_consumer_management) { |
| 461 is_enrolling_consumer_management_ = is_enrolling_consumer_management; |
| 450 if (gaia_silent_load_ && populated_email_.empty()) { | 462 if (gaia_silent_load_ && populated_email_.empty()) { |
| 451 dns_cleared_ = true; | 463 dns_cleared_ = true; |
| 452 cookies_cleared_ = true; | 464 cookies_cleared_ = true; |
| 453 ShowGaiaScreenIfReady(); | 465 ShowGaiaScreenIfReady(); |
| 454 } else { | 466 } else { |
| 455 StartClearingDnsCache(); | 467 StartClearingDnsCache(); |
| 456 StartClearingCookies(base::Bind(&GaiaScreenHandler::ShowGaiaScreenIfReady, | 468 StartClearingCookies(base::Bind(&GaiaScreenHandler::ShowGaiaScreenIfReady, |
| 457 weak_factory_.GetWeakPtr())); | 469 weak_factory_.GetWeakPtr())); |
| 458 } | 470 } |
| 459 } | 471 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 void GaiaScreenHandler::LoadAuthExtension(bool force, | 528 void GaiaScreenHandler::LoadAuthExtension(bool force, |
| 517 bool silent_load, | 529 bool silent_load, |
| 518 bool offline) { | 530 bool offline) { |
| 519 GaiaContext context; | 531 GaiaContext context; |
| 520 context.force_reload = force; | 532 context.force_reload = force; |
| 521 context.is_local = offline; | 533 context.is_local = offline; |
| 522 context.password_changed = !populated_email_.empty() && | 534 context.password_changed = !populated_email_.empty() && |
| 523 password_changed_for_.count(populated_email_); | 535 password_changed_for_.count(populated_email_); |
| 524 context.use_offline = offline; | 536 context.use_offline = offline; |
| 525 context.email = populated_email_; | 537 context.email = populated_email_; |
| 538 context.is_enrolling_consumer_management = is_enrolling_consumer_management_; |
| 526 if (Delegate()) { | 539 if (Delegate()) { |
| 527 context.show_users = Delegate()->IsShowUsers(); | 540 context.show_users = Delegate()->IsShowUsers(); |
| 528 context.has_users = !Delegate()->GetUsers().empty(); | 541 context.has_users = !Delegate()->GetUsers().empty(); |
| 529 } | 542 } |
| 530 | 543 |
| 531 populated_email_.clear(); | 544 populated_email_.clear(); |
| 532 | 545 |
| 533 LoadGaia(context); | 546 LoadGaia(context); |
| 534 } | 547 } |
| 535 | 548 |
| 536 void GaiaScreenHandler::UpdateState(ErrorScreenActor::ErrorReason reason) { | 549 void GaiaScreenHandler::UpdateState(ErrorScreenActor::ErrorReason reason) { |
| 537 if (signin_screen_handler_) | 550 if (signin_screen_handler_) |
| 538 signin_screen_handler_->UpdateState(reason); | 551 signin_screen_handler_->UpdateState(reason); |
| 539 } | 552 } |
| 540 | 553 |
| 541 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { | 554 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { |
| 542 DCHECK(signin_screen_handler_); | 555 DCHECK(signin_screen_handler_); |
| 543 return signin_screen_handler_->delegate_; | 556 return signin_screen_handler_->delegate_; |
| 544 } | 557 } |
| 545 | 558 |
| 546 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) { | 559 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) { |
| 547 signin_screen_handler_ = handler; | 560 signin_screen_handler_ = handler; |
| 548 } | 561 } |
| 549 } // namespace chromeos | 562 } // namespace chromeos |
| OLD | NEW |