Index: chrome/browser/ui/webui/signin/signin_error_handler.cc |
diff --git a/chrome/browser/ui/webui/signin/signin_error_handler.cc b/chrome/browser/ui/webui/signin/signin_error_handler.cc |
index 47916eac593aa98861a2d515cf60d1d56ed6c450..4111b6a52e9ce6c7259f8995a17c9a4bc6ac663f 100644 |
--- a/chrome/browser/ui/webui/signin/signin_error_handler.cc |
+++ b/chrome/browser/ui/webui/signin/signin_error_handler.cc |
@@ -38,14 +38,19 @@ void SigninErrorHandler::HandleSwitchToExistingProfile( |
const base::ListValue* args) { |
if (duplicate_profile_path_.empty()) |
return; |
+ |
+ // CloseDialog will eventually destroy this object, so nothing should access |
+ // its members after this call. However, closing the dialog may steal focus |
+ // back to the original window, so make a copy of the path to switch to and |
+ // perform the switch after the dialog is closed. |
+ base::FilePath path_switching_to = duplicate_profile_path_; |
+ CloseDialog(); |
+ |
// Switch to the existing duplicate profile. Do not create a new window when |
// any existing ones can be reused. |
- profiles::SwitchToProfile(duplicate_profile_path_, false, |
+ profiles::SwitchToProfile(path_switching_to, false, |
ProfileManager::CreateCallback(), |
ProfileMetrics::SWITCH_PROFILE_DUPLICATE); |
- // CloseDialog will eventually destroy this object, so nothing should access |
- // its members after this call. |
- CloseDialog(); |
} |
void SigninErrorHandler::HandleConfirm(const base::ListValue* args) { |