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/browser.h" | |
9 #include "chrome/browser/ui/browser_finder.h" | |
10 #include "chrome/browser/ui/browser_window.h" | |
11 #include "chrome/browser/ui/chrome_pages.h" | 8 #include "chrome/browser/ui/chrome_pages.h" |
12 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
13 | 10 |
14 LoginUIService::LoginUIService(Profile* profile) | 11 LoginUIService::LoginUIService() : ui_(NULL) { |
15 : ui_(NULL), | |
16 profile_(profile) { | |
17 } | 12 } |
18 | 13 |
19 LoginUIService::~LoginUIService() {} | 14 LoginUIService::~LoginUIService() {} |
20 | 15 |
21 void LoginUIService::SetLoginUI(LoginUI* ui) { | 16 void LoginUIService::SetLoginUI(LoginUI* ui) { |
22 DCHECK(!current_login_ui() || current_login_ui() == ui); | 17 DCHECK(!current_login_ui() || current_login_ui() == ui); |
23 ui_ = ui; | 18 ui_ = ui; |
24 } | 19 } |
25 | 20 |
26 void LoginUIService::LoginUIClosed(LoginUI* ui) { | 21 void LoginUIService::LoginUIClosed(LoginUI* ui) { |
27 if (current_login_ui() == ui) | 22 if (current_login_ui() == ui) |
28 ui_ = NULL; | 23 ui_ = NULL; |
29 } | 24 } |
30 | 25 |
31 void LoginUIService::ShowLoginUI() { | 26 void LoginUIService::ShowLoginUI(Browser* browser) { |
32 if (ui_) { | 27 if (ui_) { |
33 // We already have active login UI - make it visible. | 28 // We already have active login UI - make it visible. |
34 ui_->FocusUI(); | 29 ui_->FocusUI(); |
35 return; | 30 return; |
36 } | 31 } |
37 | 32 |
38 // Need to navigate to the settings page and display the UI. | 33 // Need to navigate to the settings page and display the UI. |
39 if (profile_) { | 34 chrome::ShowSettingsSubPage(browser, chrome::kSyncSetupSubPage); |
40 Browser* browser = browser::FindLastActiveWithProfile(profile_); | |
41 if (!browser) { | |
42 browser = Browser::Create(profile_); | |
43 chrome::ShowSettingsSubPage(browser, chrome::kSyncSetupSubPage); | |
44 browser->window()->Show(); | |
45 } else { | |
46 chrome::ShowSettingsSubPage(browser, chrome::kSyncSetupSubPage); | |
47 } | |
48 } | |
49 } | 35 } |
OLD | NEW |