| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 ProfileMetrics::SWITCH_PROFILE_DUPLICATE); | 53 ProfileMetrics::SWITCH_PROFILE_DUPLICATE); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void SigninErrorHandler::HandleConfirm(const base::ListValue* args) { | 56 void SigninErrorHandler::HandleConfirm(const base::ListValue* args) { |
| 57 CloseDialog(); | 57 CloseDialog(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void SigninErrorHandler::HandleLearnMore(const base::ListValue* args) { | 60 void SigninErrorHandler::HandleLearnMore(const base::ListValue* args) { |
| 61 Browser* browser = signin::GetDesktopBrowser(web_ui()); | 61 Browser* browser = signin::GetDesktopBrowser(web_ui()); |
| 62 DCHECK(browser); | 62 DCHECK(browser); |
| 63 browser->CloseModalSigninWindow(); | 63 browser->signin_view_controller()->CloseModalSignin(); |
| 64 signin_ui_util::ShowSigninErrorLearnMorePage(browser->profile()); | 64 signin_ui_util::ShowSigninErrorLearnMorePage(browser->profile()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void SigninErrorHandler::HandleInitializedWithSize( | 67 void SigninErrorHandler::HandleInitializedWithSize( |
| 68 const base::ListValue* args) { | 68 const base::ListValue* args) { |
| 69 AllowJavascript(); | 69 AllowJavascript(); |
| 70 if (duplicate_profile_path_.empty()) | 70 if (duplicate_profile_path_.empty()) |
| 71 CallJavascriptFunction("signin.error.removeSwitchButton"); | 71 CallJavascriptFunction("signin.error.removeSwitchButton"); |
| 72 | 72 |
| 73 signin::SetInitializedModalHeight(web_ui(), args); | 73 signin::SetInitializedModalHeight(web_ui(), args); |
| 74 | 74 |
| 75 // After the dialog is shown, some platforms might have an element focused. | 75 // After the dialog is shown, some platforms might have an element focused. |
| 76 // To be consistent, clear the focused element on all platforms. | 76 // To be consistent, clear the focused element on all platforms. |
| 77 // TODO(anthonyvd): Figure out why this is needed on Mac and not other | 77 // TODO(anthonyvd): Figure out why this is needed on Mac and not other |
| 78 // platforms and if there's a way to start unfocused while avoiding this | 78 // platforms and if there's a way to start unfocused while avoiding this |
| 79 // workaround. | 79 // workaround. |
| 80 CallJavascriptFunction("signin.error.clearFocus"); | 80 CallJavascriptFunction("signin.error.clearFocus"); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void SigninErrorHandler::CloseDialog() { | 83 void SigninErrorHandler::CloseDialog() { |
| 84 if (is_system_profile_) { | 84 if (is_system_profile_) { |
| 85 // Avoid closing the user manager window when the error message is displayed | 85 // Avoid closing the user manager window when the error message is displayed |
| 86 // without browser window. | 86 // without browser window. |
| 87 UserManagerProfileDialog::HideDialog(); | 87 UserManagerProfileDialog::HideDialog(); |
| 88 } else { | 88 } else { |
| 89 Browser* browser = signin::GetDesktopBrowser(web_ui()); | 89 Browser* browser = signin::GetDesktopBrowser(web_ui()); |
| 90 DCHECK(browser); | 90 DCHECK(browser); |
| 91 browser->CloseModalSigninWindow(); | 91 browser->signin_view_controller()->CloseModalSignin(); |
| 92 } | 92 } |
| 93 } | 93 } |
| OLD | NEW |