X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fchrome%2Fbrowser%2Fui%2Fash%2Fsession_state_delegate_chromeos.cc;h=8a854500db5f11c5a29f1c07456edd25a9fb6908;hb=3545e9f2671f595d2a2f3ee75ca0393b01e35ef6;hp=2f7c8405472735753c8d8adf41e5b0f75af54ce7;hpb=7d210d4c7e9ba36e635eabc5b5780495f8a63292;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/chrome/browser/ui/ash/session_state_delegate_chromeos.cc b/src/chrome/browser/ui/ash/session_state_delegate_chromeos.cc index 2f7c840..8a85450 100644 --- a/src/chrome/browser/ui/ash/session_state_delegate_chromeos.cc +++ b/src/chrome/browser/ui/ash/session_state_delegate_chromeos.cc @@ -6,6 +6,9 @@ #include "ash/multi_profile_uma.h" #include "ash/session/session_state_observer.h" +#include "ash/system/chromeos/multi_user/user_switch_util.h" +#include "base/bind.h" +#include "base/callback.h" #include "base/command_line.h" #include "base/logging.h" #include "base/prefs/pref_service.h" @@ -80,6 +83,18 @@ int SessionStateDelegateChromeos::NumberOfLoggedInUsers() const { return user_manager::UserManager::Get()->GetLoggedInUsers().size(); } +bool SessionStateDelegateChromeos::CanAddUserToMultiProfile( + AddUserError* error) const { + if (user_manager::UserManager::Get() + ->GetUsersAdmittedForMultiProfile() + .size() == 0) { + if (error) + *error = ADD_USER_ERROR_OUT_OF_USERS; + return false; + } + return SessionStateDelegate::CanAddUserToMultiProfile(error); +} + bool SessionStateDelegateChromeos::IsActiveUserSessionStarted() const { return user_manager::UserManager::Get()->IsSessionStarted(); } @@ -164,7 +179,7 @@ void SessionStateDelegateChromeos::SwitchActiveUser( gaia::CanonicalizeEmail(gaia::SanitizeEmail(user_id))); if (user_id == user_manager::UserManager::Get()->GetActiveUser()->email()) return; - user_manager::UserManager::Get()->SwitchActiveUser(user_id); + TryToSwitchUser(user_id); } void SessionStateDelegateChromeos::CycleActiveUser(CycleUser cycle_user) { @@ -207,7 +222,7 @@ void SessionStateDelegateChromeos::CycleActiveUser(CycleUser cycle_user) { } // Switch using the transformed |user_id|. - user_manager::UserManager::Get()->SwitchActiveUser(user_id); + TryToSwitchUser(user_id); } bool SessionStateDelegateChromeos::IsMultiProfileAllowedByPrimaryUserPolicy() @@ -267,3 +282,12 @@ void SessionStateDelegateChromeos::NotifySessionStateChanged() { session_state_observer_list_, SessionStateChanged(session_state_)); } + +void DoSwitchUser(const std::string& user_id) { + user_manager::UserManager::Get()->SwitchActiveUser(user_id); +} + +void SessionStateDelegateChromeos::TryToSwitchUser( + const std::string& user_id) { + ash::TrySwitchingActiveUser(base::Bind(&DoSwitchUser, user_id)); +}