Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2200)

Unified Diff: chrome/browser/ui/webui/signin/user_manager_screen_handler.cc

Issue 149883004: Fix sketchy User Manager code :( (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compile Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/profiles/profile_window.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..032b96035957d056e241f4f2afbd59a5c4019aa6 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,18 @@ 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. The task needs to be posted,
+// as HideUserManager will end up destroying its WebContents, which will
+// destruct the UserManagerScreenHandler as well.
+void OnSwitchToProfileComplete() {
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&chrome::HideUserManager));
+}
+
std::string GetAvatarImageAtIndex(
size_t index, const ProfileInfoCache& info_cache) {
bool is_gaia_picture =
@@ -185,7 +197,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 +275,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 +312,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 +484,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(
« no previous file with comments | « chrome/browser/profiles/profile_window.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698