| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/login_ui_service.h" | 5 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/signin/signin_promo.h" | 9 #include "chrome/browser/signin/signin_promo.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 LoginUIService::~LoginUIService() {} | 26 LoginUIService::~LoginUIService() {} |
| 27 | 27 |
| 28 void LoginUIService::AddObserver(LoginUIService::Observer* observer) { | 28 void LoginUIService::AddObserver(LoginUIService::Observer* observer) { |
| 29 observer_list_.AddObserver(observer); | 29 observer_list_.AddObserver(observer); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void LoginUIService::RemoveObserver(LoginUIService::Observer* observer) { | 32 void LoginUIService::RemoveObserver(LoginUIService::Observer* observer) { |
| 33 observer_list_.RemoveObserver(observer); | 33 observer_list_.RemoveObserver(observer); |
| 34 } | 34 } |
| 35 | 35 |
| 36 LoginUIService::LoginUI* LoginUIService::current_login_ui() const { |
| 37 return ui_list_.empty() ? nullptr : ui_list_.front(); |
| 38 } |
| 39 |
| 36 void LoginUIService::SetLoginUI(LoginUI* ui) { | 40 void LoginUIService::SetLoginUI(LoginUI* ui) { |
| 37 DCHECK(!current_login_ui() || current_login_ui() == ui); | 41 ui_list_.remove(ui); |
| 38 ui_ = ui; | 42 ui_list_.push_front(ui); |
| 39 FOR_EACH_OBSERVER(Observer, observer_list_, OnLoginUIShown(ui_)); | |
| 40 } | 43 } |
| 41 | 44 |
| 42 void LoginUIService::LoginUIClosed(LoginUI* ui) { | 45 void LoginUIService::LoginUIClosed(LoginUI* ui) { |
| 43 if (current_login_ui() != ui) | 46 ui_list_.remove(ui); |
| 44 return; | |
| 45 | |
| 46 ui_ = NULL; | |
| 47 FOR_EACH_OBSERVER(Observer, observer_list_, OnLoginUIClosed(ui)); | |
| 48 } | 47 } |
| 49 | 48 |
| 50 void LoginUIService::SyncConfirmationUIClosed( | 49 void LoginUIService::SyncConfirmationUIClosed( |
| 51 SyncConfirmationUIClosedResult result) { | 50 SyncConfirmationUIClosedResult result) { |
| 52 FOR_EACH_OBSERVER( | 51 FOR_EACH_OBSERVER( |
| 53 Observer, | 52 Observer, |
| 54 observer_list_, | 53 observer_list_, |
| 55 OnSyncConfirmationUIClosed(result)); | 54 OnSyncConfirmationUIClosed(result)); |
| 56 } | 55 } |
| 57 | 56 |
| 58 void LoginUIService::UntrustedLoginUIShown() { | |
| 59 FOR_EACH_OBSERVER(Observer, observer_list_, OnUntrustedLoginUIShown()); | |
| 60 } | |
| 61 | |
| 62 void LoginUIService::ShowLoginPopup() { | 57 void LoginUIService::ShowLoginPopup() { |
| 63 #if defined(OS_CHROMEOS) | 58 #if defined(OS_CHROMEOS) |
| 64 NOTREACHED(); | 59 NOTREACHED(); |
| 65 #else | 60 #else |
| 66 chrome::ScopedTabbedBrowserDisplayer displayer(profile_); | 61 chrome::ScopedTabbedBrowserDisplayer displayer(profile_); |
| 67 chrome::ShowBrowserSignin( | 62 chrome::ShowBrowserSignin( |
| 68 displayer.browser(), | 63 displayer.browser(), |
| 69 signin_metrics::AccessPoint::ACCESS_POINT_EXTENSIONS); | 64 signin_metrics::AccessPoint::ACCESS_POINT_EXTENSIONS); |
| 70 #endif | 65 #endif |
| 71 } | 66 } |
| 72 | 67 |
| 73 void LoginUIService::DisplayLoginResult(Browser* browser, | 68 void LoginUIService::DisplayLoginResult(Browser* browser, |
| 74 const base::string16& message) { | 69 const base::string16& message) { |
| 75 #if defined(OS_CHROMEOS) | 70 #if defined(OS_CHROMEOS) |
| 76 // ChromeOS doesn't have the avatar bubble so it never calls this function. | 71 // ChromeOS doesn't have the avatar bubble so it never calls this function. |
| 77 NOTREACHED(); | 72 NOTREACHED(); |
| 78 #endif | 73 #endif |
| 79 last_login_result_ = message; | 74 last_login_result_ = message; |
| 80 browser->window()->ShowAvatarBubbleFromAvatarButton( | 75 browser->window()->ShowAvatarBubbleFromAvatarButton( |
| 81 message.empty() ? BrowserWindow::AVATAR_BUBBLE_MODE_CONFIRM_SIGNIN | 76 message.empty() ? BrowserWindow::AVATAR_BUBBLE_MODE_CONFIRM_SIGNIN |
| 82 : BrowserWindow::AVATAR_BUBBLE_MODE_SHOW_ERROR, | 77 : BrowserWindow::AVATAR_BUBBLE_MODE_SHOW_ERROR, |
| 83 signin::ManageAccountsParams(), | 78 signin::ManageAccountsParams(), |
| 84 signin_metrics::AccessPoint::ACCESS_POINT_EXTENSIONS); | 79 signin_metrics::AccessPoint::ACCESS_POINT_EXTENSIONS); |
| 85 } | 80 } |
| 86 | 81 |
| 87 const base::string16& LoginUIService::GetLastLoginResult() { | 82 const base::string16& LoginUIService::GetLastLoginResult() { |
| 88 return last_login_result_; | 83 return last_login_result_; |
| 89 } | 84 } |
| OLD | NEW |