| 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 28 matching lines...) Expand all Loading... |
| 39 void UpdateAuthParams(base::DictionaryValue* params, bool has_users) { | 39 void UpdateAuthParams(base::DictionaryValue* params, bool has_users) { |
| 40 CrosSettings* cros_settings = CrosSettings::Get(); | 40 CrosSettings* cros_settings = CrosSettings::Get(); |
| 41 bool allow_new_user = true; | 41 bool allow_new_user = true; |
| 42 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 42 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
| 43 bool allow_guest = true; | 43 bool allow_guest = true; |
| 44 cros_settings->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); | 44 cros_settings->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); |
| 45 // Account creation depends on Guest sign-in (http://crosbug.com/24570). | 45 // Account creation depends on Guest sign-in (http://crosbug.com/24570). |
| 46 params->SetBoolean("createAccount", allow_new_user && allow_guest); | 46 params->SetBoolean("createAccount", allow_new_user && allow_guest); |
| 47 params->SetBoolean("guestSignin", allow_guest); | 47 params->SetBoolean("guestSignin", allow_guest); |
| 48 | 48 |
| 49 // Allow locally managed user creation only if: | 49 // Allow supervised user creation only if: |
| 50 // 1. Enterprise managed device > is allowed by policy. | 50 // 1. Enterprise managed device > is allowed by policy. |
| 51 // 2. Consumer device > owner exists. | 51 // 2. Consumer device > owner exists. |
| 52 // 3. New users are allowed by owner. | 52 // 3. New users are allowed by owner. |
| 53 // 4. Supervised users are allowed by owner. | 53 // 4. Supervised users are allowed by owner. |
| 54 bool managed_users_allowed = | 54 bool supervised_users_allowed = |
| 55 UserManager::Get()->AreLocallyManagedUsersAllowed(); | 55 UserManager::Get()->AreSupervisedUsersAllowed(); |
| 56 bool managed_users_can_create = true; | 56 bool supervised_users_can_create = true; |
| 57 int message_id = -1; | 57 int message_id = -1; |
| 58 if (!has_users) { | 58 if (!has_users) { |
| 59 managed_users_can_create = false; | 59 supervised_users_can_create = false; |
| 60 message_id = IDS_CREATE_LOCALLY_MANAGED_USER_NO_MANAGER_TEXT; | 60 message_id = IDS_CREATE_LOCALLY_MANAGED_USER_NO_MANAGER_TEXT; |
| 61 } | 61 } |
| 62 if (!allow_new_user || !managed_users_allowed) { | 62 if (!allow_new_user || !supervised_users_allowed) { |
| 63 managed_users_can_create = false; | 63 supervised_users_can_create = false; |
| 64 message_id = IDS_CREATE_LOCALLY_MANAGED_USER_CREATION_RESTRICTED_TEXT; | 64 message_id = IDS_CREATE_LOCALLY_MANAGED_USER_CREATION_RESTRICTED_TEXT; |
| 65 } | 65 } |
| 66 | 66 |
| 67 params->SetBoolean("managedUsersEnabled", managed_users_allowed); | 67 params->SetBoolean("managedUsersEnabled", supervised_users_allowed); |
| 68 params->SetBoolean("managedUsersCanCreate", managed_users_can_create); | 68 params->SetBoolean("managedUsersCanCreate", supervised_users_can_create); |
| 69 if (!managed_users_can_create) { | 69 if (!supervised_users_can_create) { |
| 70 params->SetString("managedUsersRestrictionReason", | 70 params->SetString("managedUsersRestrictionReason", |
| 71 l10n_util::GetStringUTF16(message_id)); | 71 l10n_util::GetStringUTF16(message_id)); |
| 72 } | 72 } |
| 73 | 73 |
| 74 // Now check whether we're in multi-profiles user adding scenario and | 74 // Now check whether we're in multi-profiles user adding scenario and |
| 75 // disable GAIA right panel features if that's the case. | 75 // disable GAIA right panel features if that's the case. |
| 76 if (UserAddingScreen::Get()->IsRunning()) { | 76 if (UserAddingScreen::Get()->IsRunning()) { |
| 77 params->SetBoolean("createAccount", false); | 77 params->SetBoolean("createAccount", false); |
| 78 params->SetBoolean("guestSignin", false); | 78 params->SetBoolean("guestSignin", false); |
| 79 params->SetBoolean("managedUsersEnabled", false); | 79 params->SetBoolean("managedUsersEnabled", false); |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 | 538 |
| 539 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { | 539 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { |
| 540 DCHECK(signin_screen_handler_); | 540 DCHECK(signin_screen_handler_); |
| 541 return signin_screen_handler_->delegate_; | 541 return signin_screen_handler_->delegate_; |
| 542 } | 542 } |
| 543 | 543 |
| 544 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) { | 544 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) { |
| 545 signin_screen_handler_ = handler; | 545 signin_screen_handler_ = handler; |
| 546 } | 546 } |
| 547 } // namespace chromeos | 547 } // namespace chromeos |
| OLD | NEW |