Index: chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc |
diff --git a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc |
index 43e92626217fa1abf39fb7a986b1443f40e369d2..1b5a15369f72106cd30c65f585b2f87780293ac6 100644 |
--- a/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc |
+++ b/chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc |
@@ -215,20 +215,6 @@ MultiUserWindowManagerChromeOS::MultiUserWindowManagerChromeOS( |
message_center::MessageCenter::Get(), current_user_id)), |
suppress_visibility_changes_(false), |
animation_speed_(ANIMATION_SPEED_NORMAL) { |
- // Add a session state observer to be able to monitor session changes. |
- if (ash::Shell::HasInstance()) |
- ash::Shell::GetInstance()->session_state_delegate()-> |
- AddSessionStateObserver(this); |
- |
- // The BrowserListObserver would have been better to use then the old |
- // notification system, but that observer fires before the window got created. |
- registrar_.Add(this, NOTIFICATION_BROWSER_WINDOW_READY, |
- content::NotificationService::AllSources()); |
- |
- // Add an app window observer & all already running apps. |
- Profile* profile = multi_user_util::GetProfileFromUserID(current_user_id); |
- if (profile) |
- AddUser(profile); |
} |
MultiUserWindowManagerChromeOS::~MultiUserWindowManagerChromeOS() { |
@@ -264,6 +250,29 @@ MultiUserWindowManagerChromeOS::~MultiUserWindowManagerChromeOS() { |
RemoveSessionStateObserver(this); |
} |
+void MultiUserWindowManagerChromeOS::Init() { |
+ // Since we are setting the SessionStateObserver and adding the user, this |
+ // function should get called only once. |
+ DCHECK(user_id_to_app_observer_.find(current_user_id_) == |
+ user_id_to_app_observer_.end()); |
+ |
+ // Add a session state observer to be able to monitor session changes. |
+ if (ash::Shell::HasInstance()) { |
+ ash::Shell::GetInstance()->session_state_delegate()-> |
+ AddSessionStateObserver(this); |
+ } |
+ |
+ // The BrowserListObserver would have been better to use then the old |
+ // notification system, but that observer fires before the window got created. |
+ registrar_.Add(this, NOTIFICATION_BROWSER_WINDOW_READY, |
+ content::NotificationService::AllSources()); |
+ |
+ // Add an app window observer & all already running apps. |
+ Profile* profile = multi_user_util::GetProfileFromUserID(current_user_id_); |
+ if (profile) |
+ AddUser(profile); |
+} |
+ |
void MultiUserWindowManagerChromeOS::SetWindowOwner( |
aura::Window* window, |
const std::string& user_id) { |