Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / login / existing_user_controller.cc
index 08eb483..cb6764e 100644 (file)
@@ -188,18 +188,22 @@ void ExistingUserController::UpdateLoginDisplay(const UserList& users) {
 
   cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn,
                              &show_users_on_signin);
-  if (show_users_on_signin) {
-    for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) {
-      // TODO(xiyuan): Clean user profile whose email is not in whitelist.
-      bool meets_locally_managed_requirements =
-          (*it)->GetType() != User::USER_TYPE_LOCALLY_MANAGED ||
-          UserManager::Get()->AreLocallyManagedUsersAllowed();
-      bool meets_whitelist_requirements =
-          LoginUtils::IsWhitelisted((*it)->email(), NULL) ||
-          (*it)->GetType() != User::USER_TYPE_REGULAR;
-      if (meets_locally_managed_requirements && meets_whitelist_requirements) {
-        filtered_users.push_back(*it);
-      }
+  for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) {
+    // TODO(xiyuan): Clean user profile whose email is not in whitelist.
+    bool meets_locally_managed_requirements =
+        (*it)->GetType() != User::USER_TYPE_LOCALLY_MANAGED ||
+        UserManager::Get()->AreLocallyManagedUsersAllowed();
+    bool meets_whitelist_requirements =
+        LoginUtils::IsWhitelisted((*it)->email(), NULL) ||
+        (*it)->GetType() != User::USER_TYPE_REGULAR;
+
+    // Public session accounts are always shown on login screen.
+    bool meets_show_users_requirements = show_users_on_signin ||
+        (*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT;
+    if (meets_locally_managed_requirements &&
+        meets_whitelist_requirements &&
+        meets_show_users_requirements) {
+      filtered_users.push_back(*it);
     }
   }
 
@@ -207,12 +211,12 @@ void ExistingUserController::UpdateLoginDisplay(const UserList& users) {
   // have guest session link.
   bool show_guest;
   cros_settings_->GetBoolean(kAccountsPrefAllowGuest, &show_guest);
-  bool show_users;
-  cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, &show_users);
+  show_users_on_signin |= !filtered_users.empty();
   show_guest &= !filtered_users.empty();
   bool show_new_user = true;
   login_display_->set_parent_window(GetNativeWindow());
-  login_display_->Init(filtered_users, show_guest, show_users, show_new_user);
+  login_display_->Init(
+      filtered_users, show_guest, show_users_on_signin, show_new_user);
   host_->OnPreferencesChanged();
 }
 
@@ -383,8 +387,6 @@ void ExistingUserController::Login(const UserContext& user_context) {
   // Disable clicking on other windows.
   login_display_->SetUIEnabled(false);
 
-  BootTimesLoader::Get()->RecordLoginAttempted();
-
   if (last_login_attempt_username_ != user_context.username) {
     last_login_attempt_username_ = user_context.username;
     num_login_attempts_ = 0;
@@ -402,6 +404,8 @@ void ExistingUserController::PerformLogin(
   UserManager::Get()->GetUserFlow(last_login_attempt_username_)->
       set_host(host_);
 
+  BootTimesLoader::Get()->RecordLoginAttempted();
+
   // Disable UI while loading user profile.
   login_display_->SetUIEnabled(false);
 
@@ -591,10 +595,6 @@ void ExistingUserController::OnStartKioskEnableScreen() {
           weak_factory_.GetWeakPtr()));
 }
 
-void ExistingUserController::OnStartDeviceReset() {
-  ShowResetScreen();
-}
-
 void ExistingUserController::OnStartKioskAutolaunchScreen() {
   ShowKioskAutolaunchScreen();
 }
@@ -1096,6 +1096,15 @@ void ExistingUserController::ShowError(int error_id,
       break;
   }
 
+  if (error_id == IDS_LOGIN_ERROR_AUTHENTICATING) {
+    if (num_login_attempts_ > 1) {
+      const User* user =
+          UserManager::Get()->FindUser(last_login_attempt_username_);
+      if (user && (user->GetType() == User::USER_TYPE_LOCALLY_MANAGED))
+        error_id = IDS_LOGIN_ERROR_AUTHENTICATING_2ND_TIME_SUPERVISED;
+    }
+  }
+
   login_display_->ShowError(error_id, num_login_attempts_, help_topic_id);
 }