Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(659)

Unified Diff: chrome/browser/extensions/app_notify_channel_ui.cc

Issue 10192005: Refactor LoginUIService to not rely on WebUI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review feedback. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/sync/sync_global_error.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/app_notify_channel_ui.cc
diff --git a/chrome/browser/extensions/app_notify_channel_ui.cc b/chrome/browser/extensions/app_notify_channel_ui.cc
index 4217322c9a98f0d7ab1f742a9264f7420eee8855..53afc127647a670a8d06cc31e9f9908a5ad4cb1b 100644
--- a/chrome/browser/extensions/app_notify_channel_ui.cc
+++ b/chrome/browser/extensions/app_notify_channel_ui.cc
@@ -7,12 +7,17 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/infobars/infobar_tab_helper.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/signin/signin_manager.h"
+#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/webui/signin/login_ui_service.h"
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
+#include "chrome/common/url_constants.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
@@ -128,10 +133,36 @@ void AppNotifyChannelUIImpl::PromptSyncSetup(
void AppNotifyChannelUIImpl::OnInfoBarResult(bool accepted) {
if (accepted) {
StartObservingSync();
- LoginUIServiceFactory::GetForProfile(profile_)->ShowLoginUI(true);
- } else {
- delegate_->OnSyncSetupResult(false);
+ // Bring up the login page.
+ LoginUIService* login_ui_service =
+ LoginUIServiceFactory::GetForProfile(profile_);
+ LoginUIService::LoginUI* login_ui = login_ui_service->current_login_ui();
+ if (login_ui) {
+ // Some sort of login UI is already visible.
+ SigninManager* signin = SigninManagerFactory::GetForProfile(profile_);
+ if (signin->GetAuthenticatedUsername().empty()) {
+ // User is not logged in yet, so just bring up the login UI (could be
+ // the promo UI).
+ login_ui->FocusUI();
+ return;
+ } else {
+ // User is already logged in, so close whatever sync config UI the
+ // user is looking at and display new login UI.
+ login_ui->CloseUI();
+ DCHECK(!login_ui_service->current_login_ui());
+ }
+ }
+ // Any existing UI is now closed - display new login UI.
+ Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
+ if (browser) {
+ browser->ShowOptionsTab(chrome::kSyncSetupForceLoginSubPage);
+ return;
+ }
+ // Should not be possible to have no browser here, since we're in an
+ // infobar callback.
+ NOTREACHED();
}
+ delegate_->OnSyncSetupResult(false);
}
void AppNotifyChannelUIImpl::OnStateChanged() {
« no previous file with comments | « no previous file | chrome/browser/sync/sync_global_error.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698