Adding "UserAddedToSession" notifier to the SessionStateObserver
As discussed - there is no way to figure out that a user got added to the session. The UI needs to adapt to new users by presenting them dynamically in the system shelf menu (and possibly other places). This CL is adding this observer functionality accordingly. BUG=305433 TEST=manual testing by adding functions to various existing observer to see if they fire upon adding user. Review URL: https://codereview.chromium.org/26359003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@227806 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@ -16,6 +16,9 @@ class ASH_EXPORT SessionStateObserver {
|
||||
// Called when active user has changed.
|
||||
virtual void ActiveUserChanged(const std::string& user_id) {}
|
||||
|
||||
// Called when another user gets added to the existing session.
|
||||
virtual void UserAddedToSession(const std::string& user_id) {}
|
||||
|
||||
protected:
|
||||
virtual ~SessionStateObserver() {}
|
||||
};
|
||||
|
@ -37,6 +37,10 @@ void UserManager::UserSessionStateObserver::ActiveUserChanged(
|
||||
const User* active_user) {
|
||||
}
|
||||
|
||||
void UserManager::UserSessionStateObserver::UserAddedToSession(
|
||||
const User* active_user) {
|
||||
}
|
||||
|
||||
void UserManager::UserSessionStateObserver::ActiveUserHashChanged(
|
||||
const std::string& hash) {
|
||||
}
|
||||
|
@ -40,6 +40,9 @@ class UserManager {
|
||||
// Called when active user has changed.
|
||||
virtual void ActiveUserChanged(const User* active_user);
|
||||
|
||||
// Called when another user got added to the existing session.
|
||||
virtual void UserAddedToSession(const User* added_user);
|
||||
|
||||
// Called right before notifying on user change so that those who rely
|
||||
// on user_id hash would be accessing up-to-date value.
|
||||
virtual void ActiveUserHashChanged(const std::string& hash);
|
||||
|
@ -359,6 +359,7 @@ void UserManagerImpl::UserLoggedIn(const std::string& email,
|
||||
is_current_user_new_ = false;
|
||||
// Set active user wallpaper back.
|
||||
WallpaperManager::Get()->SetUserWallpaper(active_user_->email());
|
||||
NotifyUserAddedToSession(user);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1864,6 +1865,13 @@ void UserManagerImpl::NotifyActiveUserChanged(const User* active_user) {
|
||||
ActiveUserChanged(active_user));
|
||||
}
|
||||
|
||||
void UserManagerImpl::NotifyUserAddedToSession(const User* added_user) {
|
||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||
FOR_EACH_OBSERVER(UserManager::UserSessionStateObserver,
|
||||
session_state_observer_list_,
|
||||
UserAddedToSession(added_user));
|
||||
}
|
||||
|
||||
void UserManagerImpl::NotifyActiveUserHashChanged(const std::string& hash) {
|
||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||
FOR_EACH_OBSERVER(UserManager::UserSessionStateObserver,
|
||||
|
@ -279,6 +279,9 @@ class UserManagerImpl
|
||||
// Notifies observers that active user has changed.
|
||||
void NotifyActiveUserChanged(const User* active_user);
|
||||
|
||||
// Notifies observers that another user was added to the session.
|
||||
void NotifyUserAddedToSession(const User* added_user);
|
||||
|
||||
// Notifies observers that active user_id hash has changed.
|
||||
void NotifyActiveUserHashChanged(const std::string& hash);
|
||||
|
||||
|
@ -164,3 +164,10 @@ void SessionStateDelegateChromeos::ActiveUserChanged(
|
||||
session_state_observer_list_,
|
||||
ActiveUserChanged(active_user->email()));
|
||||
}
|
||||
|
||||
void SessionStateDelegateChromeos::UserAddedToSession(
|
||||
const chromeos::User* added_user) {
|
||||
FOR_EACH_OBSERVER(ash::SessionStateObserver,
|
||||
session_state_observer_list_,
|
||||
UserAddedToSession(added_user->email()));
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ class SessionStateDelegateChromeos
|
||||
|
||||
// UserManager::UserSessionStateObserver:
|
||||
virtual void ActiveUserChanged(const chromeos::User* active_user) OVERRIDE;
|
||||
virtual void UserAddedToSession(const chromeos::User* added_user) OVERRIDE;
|
||||
|
||||
private:
|
||||
// List of observers is only used on Chrome OS for now.
|
||||
|
Reference in New Issue
Block a user