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 "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/ui/chrome_pages.h" | 8 #include "chrome/browser/ui/chrome_pages.h" |
9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
10 | 10 |
11 LoginUIService::LoginUIService() : ui_(NULL) { | 11 LoginUIService::LoginUIService() : ui_(NULL) { |
12 } | 12 } |
13 | 13 |
14 LoginUIService::~LoginUIService() {} | 14 LoginUIService::~LoginUIService() {} |
15 | 15 |
16 void LoginUIService::AddObserver(Observer* o) { | |
17 if (o) | |
jam
2012/07/10 16:13:07
why do you need to handle someone calling add/remo
Munjal (Google)
2012/07/10 16:46:15
Done.
| |
18 observer_list_.AddObserver(o); | |
19 } | |
20 | |
21 void LoginUIService::RemoveObserver(Observer* o) { | |
22 if (o) | |
23 observer_list_.RemoveObserver(o); | |
24 } | |
25 | |
16 void LoginUIService::SetLoginUI(LoginUI* ui) { | 26 void LoginUIService::SetLoginUI(LoginUI* ui) { |
17 DCHECK(!current_login_ui() || current_login_ui() == ui); | 27 DCHECK(!current_login_ui() || current_login_ui() == ui); |
18 ui_ = ui; | 28 ui_ = ui; |
29 FOR_EACH_OBSERVER(Observer, observer_list_, OnLoginUIShown(ui_)); | |
19 } | 30 } |
20 | 31 |
21 void LoginUIService::LoginUIClosed(LoginUI* ui) { | 32 void LoginUIService::LoginUIClosed(LoginUI* ui) { |
22 if (current_login_ui() == ui) | 33 if (current_login_ui() != ui) |
23 ui_ = NULL; | 34 return; |
35 | |
36 FOR_EACH_OBSERVER(Observer, observer_list_, OnLoginUIClosed(ui_)); | |
37 ui_ = NULL; | |
24 } | 38 } |
25 | 39 |
26 void LoginUIService::ShowLoginUI(Browser* browser) { | 40 void LoginUIService::ShowLoginUI(Browser* browser) { |
27 if (ui_) { | 41 if (ui_) { |
28 // We already have active login UI - make it visible. | 42 // We already have active login UI - make it visible. |
29 ui_->FocusUI(); | 43 ui_->FocusUI(); |
30 return; | 44 return; |
31 } | 45 } |
32 | 46 |
33 // Need to navigate to the settings page and display the UI. | 47 // Need to navigate to the settings page and display the UI. |
34 chrome::ShowSettingsSubPage(browser, chrome::kSyncSetupSubPage); | 48 chrome::ShowSettingsSubPage(browser, chrome::kSyncSetupSubPage); |
35 } | 49 } |
OLD | NEW |