Chromium Code Reviews| 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" | |
| 8 #include "chrome/browser/ui/chrome_pages.h" | 9 #include "chrome/browser/ui/chrome_pages.h" |
| 9 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
| 11 #include "chrome/common/chrome_notification_types.h" | |
| 12 #include "content/public/browser/notification_service.h" | |
| 13 #include "content/public/browser/notification_source.h" | |
| 14 #include "content/public/browser/page_navigator.h" | |
| 15 #include "content/public/common/page_transition_types.h" | |
| 16 #include "content/public/common/referrer.h" | |
| 17 #include "webkit/glue/window_open_disposition.h" | |
| 18 | |
| 19 using content::OpenURLParams; | |
| 20 using content::Referrer; | |
| 10 | 21 |
| 11 LoginUIService::LoginUIService() : ui_(NULL) { | 22 LoginUIService::LoginUIService() : ui_(NULL) { |
| 12 } | 23 } |
| 13 | 24 |
| 14 LoginUIService::~LoginUIService() {} | 25 LoginUIService::~LoginUIService() {} |
| 15 | 26 |
| 16 void LoginUIService::SetLoginUI(LoginUI* ui) { | 27 void LoginUIService::SetLoginUI(LoginUI* ui) { |
| 17 DCHECK(!current_login_ui() || current_login_ui() == ui); | 28 DCHECK(!current_login_ui() || current_login_ui() == ui); |
| 18 ui_ = ui; | 29 ui_ = ui; |
| 30 FireLoginUIChanged(); | |
| 19 } | 31 } |
| 20 | 32 |
| 21 void LoginUIService::LoginUIClosed(LoginUI* ui) { | 33 void LoginUIService::LoginUIClosed(LoginUI* ui) { |
| 22 if (current_login_ui() == ui) | 34 if (current_login_ui() != ui) |
| 23 ui_ = NULL; | 35 return; |
| 36 | |
| 37 ui_ = NULL; | |
| 38 FireLoginUIChanged(); | |
| 24 } | 39 } |
| 25 | 40 |
| 26 void LoginUIService::ShowLoginUI(Browser* browser) { | 41 void LoginUIService::ShowLoginUI(Browser* browser) { |
| 27 if (ui_) { | 42 if (ui_) { |
| 28 // We already have active login UI - make it visible. | 43 // We already have active login UI - make it visible. |
| 29 ui_->FocusUI(); | 44 ui_->FocusUI(); |
| 30 return; | 45 return; |
| 31 } | 46 } |
| 32 | 47 |
| 33 // Need to navigate to the settings page and display the UI. | 48 // Need to navigate to the settings page and display the UI. |
| 34 chrome::ShowSettingsSubPage(browser, chrome::kSyncSetupSubPage); | 49 chrome::ShowSettingsSubPage(browser, chrome::kSyncSetupSubPage); |
| 35 } | 50 } |
| 51 | |
| 52 void LoginUIService::ShowLoginDialogUI(Browser* browser) { | |
|
Andrew T Wilson (Slow)
2012/07/03 17:34:09
This isn't displaying a dialog - it's displaying a
Munjal (Google)
2012/07/03 17:52:17
I changed the name to ShowLoginUIPopup. I think it
Andrew T Wilson (Slow)
2012/07/09 19:52:06
Let's put this in the caller (take it out of this
Munjal (Google)
2012/07/09 21:13:26
Done.
| |
| 53 if (ui_) { | |
| 54 // We already have active login UI - make it visible. | |
| 55 ui_->FocusUI(); | |
| 56 return; | |
| 57 } | |
| 58 | |
| 59 OpenURLParams params( | |
| 60 GURL(chrome::kChromeUISyncPromoURL), Referrer(), NEW_POPUP, | |
| 61 content::PAGE_TRANSITION_START_PAGE, false); | |
| 62 browser->OpenURL(params); | |
| 63 } | |
| 64 | |
| 65 void LoginUIService::FireLoginUIChanged() const { | |
| 66 content::NotificationService::current()->Notify( | |
| 67 chrome::NOTIFICATION_LOGIN_UI_CHANGED, | |
| 68 content::Source<LoginUIService>(this), | |
| 69 content::NotificationService::NoDetails()); | |
|
Andrew T Wilson (Slow)
2012/07/03 17:34:09
Does it make sense to send out the current login U
Munjal (Google)
2012/07/03 17:52:17
We discussed that remember? In fact, your suggesti
Andrew T Wilson (Slow)
2012/07/09 19:52:06
Yeah, I remember, and I was just reconsidering the
| |
| 70 } | |
| OLD | NEW |