Index: chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc |
diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc |
index 9c3c388d02e2d368bf133dc75150b283efa0b49e..3513975abbd89f536f43b8eabeb95aa0a6c34b90 100644 |
--- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc |
+++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc |
@@ -85,7 +85,6 @@ const char kKeyEnterpriseDomain[] = "enterpriseDomain"; |
const char kKeyPublicAccount[] = "publicAccount"; |
const char kKeyLocallyManagedUser[] = "locallyManagedUser"; |
const char kKeySignedIn[] = "signedIn"; |
-const char kKeyCanRemove[] = "canRemove"; |
const char kKeyIsOwner[] = "isOwner"; |
const char kKeyInitialAuthType[] = "initialAuthType"; |
const char kKeyMultiProfilesAllowed[] = "isMultiProfilesAllowed"; |
@@ -229,37 +228,6 @@ void RecordSAMLScrapingVerificationResultInHistogram(bool success) { |
UMA_HISTOGRAM_BOOLEAN("ChromeOS.SAML.Scraping.VerificationResult", success); |
} |
-bool ShouldForceOnlineSignIn(const User* user) { |
- // Public sessions are always allowed to log in offline. |
- // Supervised user are allowed to log in offline if their OAuth token status |
- // is unknown or valid. |
- // For all other users, force online sign in if: |
- // * The flag to force online sign-in is set for the user. |
- // * The user's OAuth token is invalid. |
- // * The user's OAuth token status is unknown (except supervised users, |
- // see above). |
- if (user->is_logged_in()) |
- return false; |
- |
- const User::OAuthTokenStatus token_status = user->oauth_token_status(); |
- const bool is_locally_managed_user = |
- user->GetType() == User::USER_TYPE_LOCALLY_MANAGED; |
- const bool is_public_session = |
- user->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT; |
- |
- if (is_locally_managed_user && |
- token_status == User::OAUTH_TOKEN_STATUS_UNKNOWN) { |
- return false; |
- } |
- |
- if (is_public_session) |
- return false; |
- |
- return user->force_online_signin() || |
- (token_status == User::OAUTH2_TOKEN_STATUS_INVALID) || |
- (token_status == User::OAUTH_TOKEN_STATUS_UNKNOWN); |
-} |
- |
} // namespace |
// LoginScreenContext implementation ------------------------------------------ |
@@ -500,7 +468,7 @@ void SigninScreenHandler::ShowImpl() { |
} else { |
// Populates account picker. Animation is turned off for now until we |
// figure out how to make it fast enough. |
- SendUserList(false); |
+ delegate_->HandleGetUsers(); |
// Reset Caps Lock state when login screen is shown. |
input_method::InputMethodManager::Get() |
@@ -807,7 +775,8 @@ void SigninScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) { |
} |
void SigninScreenHandler::HandleGetUsers() { |
- SendUserList(false); |
+ if (delegate_) |
+ delegate_->HandleGetUsers(); |
} |
void SigninScreenHandler::ClearAndEnablePassword() { |
@@ -845,7 +814,8 @@ void SigninScreenHandler::OnPreferencesChanged() { |
if (delegate_ && !delegate_->IsShowUsers()) { |
HandleShowAddUser(NULL); |
} else { |
- SendUserList(false); |
+ if (delegate_) |
+ delegate_->HandleGetUsers(); |
UpdateUIState(UI_STATE_ACCOUNT_PICKER, NULL); |
} |
preferences_changed_delayed_ = false; |
@@ -859,26 +829,13 @@ void SigninScreenHandler::ShowBannerMessage(const std::string& message) { |
CallJS("login.AccountPickerScreen.showBannerMessage", message); |
} |
-void SigninScreenHandler::ShowUserPodButton( |
- const std::string& username, |
- const std::string& iconURL, |
- const base::Closure& click_callback) { |
- user_pod_button_callback_map_[username] = click_callback; |
+void SigninScreenHandler::ShowUserPodButton(const std::string& username, |
+ const std::string& iconURL) { |
CallJS("login.AccountPickerScreen.showUserPodButton", username, iconURL); |
+} |
- // TODO(tengs): Move this code once we move unlocking to native code. |
- if (ScreenLocker::default_screen_locker()) { |
- UserManager* user_manager = UserManager::Get(); |
- const User* user = user_manager->FindUser(username); |
- if (!user) |
- return; |
- PrefService* profile_prefs = |
- user_manager->GetProfileByUser(user)->GetPrefs(); |
- if (profile_prefs->GetBoolean(prefs::kEasyUnlockShowTutorial)) { |
- CallJS("login.AccountPickerScreen.showEasyUnlockBubble"); |
- profile_prefs->SetBoolean(prefs::kEasyUnlockShowTutorial, false); |
- } |
- } |
+void SigninScreenHandler::ShowEasyUnlockBubble() { |
+ CallJS("login.AccountPickerScreen.showEasyUnlockBubble"); |
} |
void SigninScreenHandler::HideUserPodButton(const std::string& username) { |
@@ -888,20 +845,12 @@ void SigninScreenHandler::HideUserPodButton(const std::string& username) { |
void SigninScreenHandler::SetAuthType(const std::string& username, |
LoginDisplay::AuthType auth_type, |
const std::string& initial_value) { |
- user_auth_type_map_[username] = auth_type; |
CallJS("login.AccountPickerScreen.setAuthType", |
username, |
static_cast<int>(auth_type), |
base::StringValue(initial_value)); |
} |
-LoginDisplay::AuthType SigninScreenHandler::GetAuthType( |
- const std::string& username) const { |
- if (user_auth_type_map_.find(username) == user_auth_type_map_.end()) |
- return LoginDisplay::OFFLINE_PASSWORD; |
- return user_auth_type_map_.find(username)->second; |
-} |
- |
void SigninScreenHandler::ShowError(int login_attempts, |
const std::string& error_text, |
const std::string& help_link_text, |
@@ -1280,6 +1229,7 @@ void SigninScreenHandler::HandleToggleKioskAutolaunchScreen() { |
delegate_->ShowKioskAutolaunchScreen(); |
} |
+// ToDo(antrim) : move to screen |
void SigninScreenHandler::FillUserDictionary(User* user, |
Nikita (slow)
2014/05/23 15:52:15
You can delete this method.
Nikita (slow)
2014/05/27 17:03:24
What about this method?
Denis Kuznetsov (DE-MUC)
2014/05/27 17:35:28
Done.
|
bool is_owner, |
bool is_signin_to_add, |
@@ -1325,77 +1275,9 @@ void SigninScreenHandler::FillUserDictionary(User* user, |
} |
} |
-void SigninScreenHandler::SendUserList(bool animated) { |
- if (!delegate_) |
- return; |
- TRACE_EVENT_ASYNC_STEP_INTO0("ui", |
- "ShowLoginWebUI", |
- LoginDisplayHostImpl::kShowLoginWebUIid, |
- "SendUserList"); |
- BootTimesLoader::Get()->RecordCurrentStats("login-send-user-list"); |
- |
- base::ListValue users_list; |
- const UserList& users = delegate_->GetUsers(); |
- |
- // TODO(nkostylev): Move to a separate method in UserManager. |
- // http://crbug.com/230852 |
- bool is_signin_to_add = LoginDisplayHostImpl::default_host() && |
- UserManager::Get()->IsUserLoggedIn(); |
- |
- user_pod_button_callback_map_.clear(); |
- user_auth_type_map_.clear(); |
- |
- bool single_user = users.size() == 1; |
- std::string owner; |
- chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); |
- bool has_owner = owner.size() > 0; |
- size_t max_non_owner_users = has_owner ? kMaxUsers - 1 : kMaxUsers; |
- size_t non_owner_count = 0; |
- policy::BrowserPolicyConnectorChromeOS* connector = |
- g_browser_process->platform_part()-> |
- browser_policy_connector_chromeos(); |
- bool is_enterprise_managed = connector->IsEnterpriseManaged(); |
- |
- |
- for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { |
- const std::string& email = (*it)->email(); |
- bool is_owner = (email == owner); |
- bool is_public_account = |
- ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT); |
- |
- if ((is_public_account && !is_signin_to_add) || |
- is_owner || |
- (!is_public_account && non_owner_count < max_non_owner_users)) { |
- LoginDisplay::AuthType initial_auth_type = |
- ShouldForceOnlineSignIn(*it) ? LoginDisplay::ONLINE_SIGN_IN |
- : LoginDisplay::OFFLINE_PASSWORD; |
- user_auth_type_map_[email] = initial_auth_type; |
- |
- base::DictionaryValue* user_dict = new base::DictionaryValue(); |
- FillUserDictionary( |
- *it, is_owner, is_signin_to_add, initial_auth_type, user_dict); |
- bool signed_in = (*it)->is_logged_in(); |
- // Single user check here is necessary because owner info might not be |
- // available when running into login screen on first boot. |
- // See http://crosbug.com/12723 |
- bool can_remove_user = ((!single_user || is_enterprise_managed) && |
- !email.empty() && !is_owner && !is_public_account && |
- !signed_in && !is_signin_to_add); |
- user_dict->SetBoolean(kKeyCanRemove, can_remove_user); |
- |
- if (!is_owner) |
- ++non_owner_count; |
- if (is_owner && users_list.GetSize() > kMaxUsers) { |
- // Owner is always in the list. |
- users_list.Insert(kMaxUsers - 1, user_dict); |
- } else { |
- users_list.Append(user_dict); |
- } |
- } |
- } |
- while (users_list.GetSize() > kMaxUsers) |
- users_list.Remove(kMaxUsers, NULL); |
- |
+void SigninScreenHandler::LoadUsers(const base::ListValue& users_list, |
+ bool animated, |
+ bool showGuest) { |
CallJS("login.AccountPickerScreen.loadUsers", users_list, animated, |
delegate_->IsShowGuest()); |
} |
@@ -1568,13 +1450,9 @@ void SigninScreenHandler::HandleFocusPod(const std::string& user_id) { |
} |
void SigninScreenHandler::HandleCustomButtonClicked( |
- const std::string& username) { |
- if (user_pod_button_callback_map_.find(username) |
- == user_pod_button_callback_map_.end()) { |
- LOG(WARNING) << "User pod custom button clicked but no callback found"; |
- return; |
- } |
- user_pod_button_callback_map_[username].Run(); |
+ const std::string& user_id) { |
+ if (delegate_) |
+ delegate_->HandleCustomButtonClicked(user_id); |
} |
void SigninScreenHandler::HandleRetrieveAuthenticatedUserEmail( |