| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/login/screens/user_selection_screen.h" | 5 #include "chrome/browser/chromeos/login/screens/user_selection_screen.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 11 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 12 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" | 12 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" |
| 13 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 13 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 14 #include "chrome/browser/signin/screenlock_bridge.h" | 14 #include "chrome/browser/signin/screenlock_bridge.h" |
| 15 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" | 15 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
| 16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 17 #include "components/user_manager/user_type.h" | 17 #include "components/user_manager/user_type.h" |
| 18 #include "ui/wm/core/user_activity_detector.h" | 18 #include "ui/wm/core/user_activity_detector.h" |
| 19 | 19 |
| 20 namespace chromeos { | 20 namespace chromeos { |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 // User dictionary keys. | 24 // User dictionary keys. |
| 25 const char kKeyUsername[] = "username"; | 25 const char kKeyUsername[] = "username"; |
| 26 const char kKeyDisplayName[] = "displayName"; | 26 const char kKeyDisplayName[] = "displayName"; |
| 27 const char kKeyEmailAddress[] = "emailAddress"; | 27 const char kKeyEmailAddress[] = "emailAddress"; |
| 28 const char kKeyEnterpriseDomain[] = "enterpriseDomain"; | 28 const char kKeyEnterpriseDomain[] = "enterpriseDomain"; |
| 29 const char kKeyPublicAccount[] = "publicAccount"; | 29 const char kKeyPublicAccount[] = "publicAccount"; |
| 30 const char kKeyLocallyManagedUser[] = "locallyManagedUser"; | 30 const char kKeySupervisedUser[] = "locallyManagedUser"; |
| 31 const char kKeySignedIn[] = "signedIn"; | 31 const char kKeySignedIn[] = "signedIn"; |
| 32 const char kKeyCanRemove[] = "canRemove"; | 32 const char kKeyCanRemove[] = "canRemove"; |
| 33 const char kKeyIsOwner[] = "isOwner"; | 33 const char kKeyIsOwner[] = "isOwner"; |
| 34 const char kKeyInitialAuthType[] = "initialAuthType"; | 34 const char kKeyInitialAuthType[] = "initialAuthType"; |
| 35 const char kKeyMultiProfilesAllowed[] = "isMultiProfilesAllowed"; | 35 const char kKeyMultiProfilesAllowed[] = "isMultiProfilesAllowed"; |
| 36 const char kKeyMultiProfilesPolicy[] = "multiProfilesPolicy"; | 36 const char kKeyMultiProfilesPolicy[] = "multiProfilesPolicy"; |
| 37 | 37 |
| 38 // Max number of users to show. | 38 // Max number of users to show. |
| 39 const size_t kMaxUsers = 18; | 39 const size_t kMaxUsers = 18; |
| 40 | 40 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 55 // static | 55 // static |
| 56 void UserSelectionScreen::FillUserDictionary( | 56 void UserSelectionScreen::FillUserDictionary( |
| 57 User* user, | 57 User* user, |
| 58 bool is_owner, | 58 bool is_owner, |
| 59 bool is_signin_to_add, | 59 bool is_signin_to_add, |
| 60 ScreenlockBridge::LockHandler::AuthType auth_type, | 60 ScreenlockBridge::LockHandler::AuthType auth_type, |
| 61 base::DictionaryValue* user_dict) { | 61 base::DictionaryValue* user_dict) { |
| 62 const std::string& user_id = user->email(); | 62 const std::string& user_id = user->email(); |
| 63 const bool is_public_account = | 63 const bool is_public_account = |
| 64 user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT; | 64 user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT; |
| 65 const bool is_locally_managed_user = | 65 const bool is_supervised_user = |
| 66 user->GetType() == user_manager::USER_TYPE_LOCALLY_MANAGED; | 66 user->GetType() == user_manager::USER_TYPE_SUPERVISED; |
| 67 | 67 |
| 68 user_dict->SetString(kKeyUsername, user_id); | 68 user_dict->SetString(kKeyUsername, user_id); |
| 69 user_dict->SetString(kKeyEmailAddress, user->display_email()); | 69 user_dict->SetString(kKeyEmailAddress, user->display_email()); |
| 70 user_dict->SetString(kKeyDisplayName, user->GetDisplayName()); | 70 user_dict->SetString(kKeyDisplayName, user->GetDisplayName()); |
| 71 user_dict->SetBoolean(kKeyPublicAccount, is_public_account); | 71 user_dict->SetBoolean(kKeyPublicAccount, is_public_account); |
| 72 user_dict->SetBoolean(kKeyLocallyManagedUser, is_locally_managed_user); | 72 user_dict->SetBoolean(kKeySupervisedUser, is_supervised_user); |
| 73 user_dict->SetInteger(kKeyInitialAuthType, auth_type); | 73 user_dict->SetInteger(kKeyInitialAuthType, auth_type); |
| 74 user_dict->SetBoolean(kKeySignedIn, user->is_logged_in()); | 74 user_dict->SetBoolean(kKeySignedIn, user->is_logged_in()); |
| 75 user_dict->SetBoolean(kKeyIsOwner, is_owner); | 75 user_dict->SetBoolean(kKeyIsOwner, is_owner); |
| 76 | 76 |
| 77 // Fill in multi-profiles related fields. | 77 // Fill in multi-profiles related fields. |
| 78 if (is_signin_to_add) { | 78 if (is_signin_to_add) { |
| 79 MultiProfileUserController* multi_profile_user_controller = | 79 MultiProfileUserController* multi_profile_user_controller = |
| 80 UserManager::Get()->GetMultiProfileUserController(); | 80 UserManager::Get()->GetMultiProfileUserController(); |
| 81 std::string behavior = | 81 std::string behavior = |
| 82 multi_profile_user_controller->GetCachedValue(user_id); | 82 multi_profile_user_controller->GetCachedValue(user_id); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 106 // is unknown or valid. | 106 // is unknown or valid. |
| 107 // For all other users, force online sign in if: | 107 // For all other users, force online sign in if: |
| 108 // * The flag to force online sign-in is set for the user. | 108 // * The flag to force online sign-in is set for the user. |
| 109 // * The user's OAuth token is invalid. | 109 // * The user's OAuth token is invalid. |
| 110 // * The user's OAuth token status is unknown (except supervised users, | 110 // * The user's OAuth token status is unknown (except supervised users, |
| 111 // see above). | 111 // see above). |
| 112 if (user->is_logged_in()) | 112 if (user->is_logged_in()) |
| 113 return false; | 113 return false; |
| 114 | 114 |
| 115 const User::OAuthTokenStatus token_status = user->oauth_token_status(); | 115 const User::OAuthTokenStatus token_status = user->oauth_token_status(); |
| 116 const bool is_locally_managed_user = | 116 const bool is_supervised_user = |
| 117 user->GetType() == user_manager::USER_TYPE_LOCALLY_MANAGED; | 117 user->GetType() == user_manager::USER_TYPE_SUPERVISED; |
| 118 const bool is_public_session = | 118 const bool is_public_session = |
| 119 user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT; | 119 user->GetType() == user_manager::USER_TYPE_PUBLIC_ACCOUNT; |
| 120 | 120 |
| 121 if (is_locally_managed_user && | 121 if (is_supervised_user && |
| 122 token_status == User::OAUTH_TOKEN_STATUS_UNKNOWN) { | 122 token_status == User::OAUTH_TOKEN_STATUS_UNKNOWN) { |
| 123 return false; | 123 return false; |
| 124 } | 124 } |
| 125 | 125 |
| 126 if (is_public_session) | 126 if (is_public_session) |
| 127 return false; | 127 return false; |
| 128 | 128 |
| 129 return user->force_online_signin() || | 129 return user->force_online_signin() || |
| 130 (token_status == User::OAUTH2_TOKEN_STATUS_INVALID) || | 130 (token_status == User::OAUTH2_TOKEN_STATUS_INVALID) || |
| 131 (token_status == User::OAUTH_TOKEN_STATUS_UNKNOWN); | 131 (token_status == User::OAUTH_TOKEN_STATUS_UNKNOWN); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 } | 288 } |
| 289 | 289 |
| 290 ScreenlockBridge::LockHandler::AuthType UserSelectionScreen::GetAuthType( | 290 ScreenlockBridge::LockHandler::AuthType UserSelectionScreen::GetAuthType( |
| 291 const std::string& username) const { | 291 const std::string& username) const { |
| 292 if (user_auth_type_map_.find(username) == user_auth_type_map_.end()) | 292 if (user_auth_type_map_.find(username) == user_auth_type_map_.end()) |
| 293 return ScreenlockBridge::LockHandler::OFFLINE_PASSWORD; | 293 return ScreenlockBridge::LockHandler::OFFLINE_PASSWORD; |
| 294 return user_auth_type_map_.find(username)->second; | 294 return user_auth_type_map_.find(username)->second; |
| 295 } | 295 } |
| 296 | 296 |
| 297 } // namespace chromeos | 297 } // namespace chromeos |
| OLD | NEW |