| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/webui/signin/signin_error_handler.h" | 5 #include "chrome/browser/ui/webui/signin/signin_error_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chrome/browser/profiles/profile_manager.h" | 8 #include "chrome/browser/profiles/profile_manager.h" |
| 9 #include "chrome/browser/profiles/profile_window.h" | 9 #include "chrome/browser/profiles/profile_window.h" |
| 10 #include "chrome/browser/signin/signin_ui_util.h" | 10 #include "chrome/browser/signin/signin_ui_util.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 web_ui()->RegisterMessageCallback( | 31 web_ui()->RegisterMessageCallback( |
| 32 "initializedWithSize", | 32 "initializedWithSize", |
| 33 base::Bind(&SigninErrorHandler::HandleInitializedWithSize, | 33 base::Bind(&SigninErrorHandler::HandleInitializedWithSize, |
| 34 base::Unretained(this))); | 34 base::Unretained(this))); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void SigninErrorHandler::HandleSwitchToExistingProfile( | 37 void SigninErrorHandler::HandleSwitchToExistingProfile( |
| 38 const base::ListValue* args) { | 38 const base::ListValue* args) { |
| 39 if (duplicate_profile_path_.empty()) | 39 if (duplicate_profile_path_.empty()) |
| 40 return; | 40 return; |
| 41 |
| 42 // CloseDialog will eventually destroy this object, so nothing should access |
| 43 // its members after this call. However, closing the dialog may steal focus |
| 44 // back to the original window, so make a copy of the path to switch to and |
| 45 // perform the switch after the dialog is closed. |
| 46 base::FilePath path_switching_to = duplicate_profile_path_; |
| 47 CloseDialog(); |
| 48 |
| 41 // Switch to the existing duplicate profile. Do not create a new window when | 49 // Switch to the existing duplicate profile. Do not create a new window when |
| 42 // any existing ones can be reused. | 50 // any existing ones can be reused. |
| 43 profiles::SwitchToProfile(duplicate_profile_path_, false, | 51 profiles::SwitchToProfile(path_switching_to, false, |
| 44 ProfileManager::CreateCallback(), | 52 ProfileManager::CreateCallback(), |
| 45 ProfileMetrics::SWITCH_PROFILE_DUPLICATE); | 53 ProfileMetrics::SWITCH_PROFILE_DUPLICATE); |
| 46 // CloseDialog will eventually destroy this object, so nothing should access | |
| 47 // its members after this call. | |
| 48 CloseDialog(); | |
| 49 } | 54 } |
| 50 | 55 |
| 51 void SigninErrorHandler::HandleConfirm(const base::ListValue* args) { | 56 void SigninErrorHandler::HandleConfirm(const base::ListValue* args) { |
| 52 CloseDialog(); | 57 CloseDialog(); |
| 53 } | 58 } |
| 54 | 59 |
| 55 void SigninErrorHandler::HandleLearnMore(const base::ListValue* args) { | 60 void SigninErrorHandler::HandleLearnMore(const base::ListValue* args) { |
| 56 Browser* browser = signin::GetDesktopBrowser(web_ui()); | 61 Browser* browser = signin::GetDesktopBrowser(web_ui()); |
| 57 DCHECK(browser); | 62 DCHECK(browser); |
| 58 browser->CloseModalSigninWindow(); | 63 browser->CloseModalSigninWindow(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 78 if (is_system_profile_) { | 83 if (is_system_profile_) { |
| 79 // Avoid closing the user manager window when the error message is displayed | 84 // Avoid closing the user manager window when the error message is displayed |
| 80 // without browser window. | 85 // without browser window. |
| 81 UserManager::HideReauthDialog(); | 86 UserManager::HideReauthDialog(); |
| 82 } else { | 87 } else { |
| 83 Browser* browser = signin::GetDesktopBrowser(web_ui()); | 88 Browser* browser = signin::GetDesktopBrowser(web_ui()); |
| 84 DCHECK(browser); | 89 DCHECK(browser); |
| 85 browser->CloseModalSigninWindow(); | 90 browser->CloseModalSigninWindow(); |
| 86 } | 91 } |
| 87 } | 92 } |
| OLD | NEW |