Index: chrome/browser/ui/webui/signin/user_manager_screen_handler.cc |
diff --git a/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc b/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc |
index 2bea73cf61f7e925c5adcda4b3dda15a66e52a20..5d8a67eda08bc9e0673ec0dff01f3491e49dec9e 100644 |
--- a/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc |
+++ b/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc |
@@ -80,6 +80,16 @@ void OpenNewWindowForProfile( |
false); |
} |
+// This callback is run after switching to a new profile has finished. This |
+// means either a new browser window has been opened, or an existing one |
+// has been found, which means we can safely close the User Manager without |
+// accidentally terminating the browser process. |
+void OnSwitchToProfileComplete() { |
+ base::MessageLoop::current()->PostTask( |
Alexei Svitkine (slow)
2014/02/06 22:02:12
Your comment should explain why this is posted rat
noms (inactive)
2014/02/06 22:51:34
Done.
|
+ FROM_HERE, |
+ base::Bind(&chrome::HideUserManager)); |
+} |
+ |
std::string GetAvatarImageAtIndex( |
size_t index, const ProfileInfoCache& info_cache) { |
bool is_gaia_picture = |
@@ -185,7 +195,7 @@ void UserManagerScreenHandler::HandleInitialize(const base::ListValue* args) { |
void UserManagerScreenHandler::HandleAddUser(const base::ListValue* args) { |
profiles::CreateAndSwitchToNewProfile(desktop_type_, |
- base::Bind(&chrome::HideUserManager), |
+ base::Bind(&OnSwitchToProfileComplete), |
ProfileMetrics::ADD_NEW_USER_MANAGER); |
} |
@@ -263,7 +273,7 @@ void UserManagerScreenHandler::HandleRemoveUser(const base::ListValue* args) { |
void UserManagerScreenHandler::HandleLaunchGuest(const base::ListValue* args) { |
profiles::SwitchToGuestProfile(desktop_type_, |
- base::Bind(&chrome::HideUserManager)); |
+ base::Bind(&OnSwitchToProfileComplete)); |
ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::SWITCH_PROFILE_GUEST); |
} |
@@ -300,7 +310,7 @@ void UserManagerScreenHandler::HandleLaunchUser(const base::ListValue* args) { |
profiles::SwitchToProfile(path, |
desktop_type_, |
false, /* reuse any existing windows */ |
- base::Bind(&chrome::HideUserManager), |
+ base::Bind(&OnSwitchToProfileComplete), |
ProfileMetrics::SWITCH_PROFILE_MANAGER); |
} |
@@ -472,7 +482,7 @@ void UserManagerScreenHandler::ReportAuthenticationResult( |
base::FilePath path = info_cache.GetPathOfProfileAtIndex( |
authenticating_profile_index_); |
profiles::SwitchToProfile(path, desktop_type_, true, |
- base::Bind(&chrome::HideUserManager), |
+ base::Bind(&OnSwitchToProfileComplete), |
ProfileMetrics::SWITCH_PROFILE_UNLOCK); |
} else { |
web_ui()->CallJavascriptFunction( |