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

Unified Diff: chrome/browser/ui/webui/signin/login_ui_service.cc

Issue 9295044: Start moving signin code out of browser/sync. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unit test Created 8 years, 10 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
Index: chrome/browser/ui/webui/signin/login_ui_service.cc
diff --git a/chrome/browser/ui/webui/signin/login_ui_service.cc b/chrome/browser/ui/webui/signin/login_ui_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6de85189516fa57ebc8b00a4e49f736c64c159aa
--- /dev/null
+++ b/chrome/browser/ui/webui/signin/login_ui_service.cc
@@ -0,0 +1,60 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/signin/login_ui_service.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/browser_window.h"
+#include "chrome/common/url_constants.h"
+#include "content/browser/renderer_host/render_view_host.h"
+#include "content/public/browser/render_view_host_delegate.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_ui.h"
+
+LoginUIService::LoginUIService(Profile* profile)
+ : ui_(NULL),
+ profile_(profile) {
+}
+
+LoginUIService::~LoginUIService() {}
+
+void LoginUIService::SetLoginUI(content::WebUI* ui) {
+ DCHECK(!current_login_ui() || current_login_ui() == ui);
+ ui_ = ui;
+}
+
+void LoginUIService::ClearLoginUI(content::WebUI* ui) {
+ if (current_login_ui() == ui)
James Hawkins 2012/02/10 23:08:01 What are the use cases for allowing |ui| to not ma
Andrew T Wilson (Slow) 2012/02/11 01:50:45 The use cases are that you might have multiple syn
+ ui_ = NULL;
+}
+
+void LoginUIService::FocusLoginUI() {
+ if (!ui_) {
+ NOTREACHED() << "FocusLoginUI() called with no active login UI";
+ return;
+ }
+ ui_->GetWebContents()->GetRenderViewHost()->delegate()->Activate();
+}
+
+void LoginUIService::ShowLoginUI() {
+ if (ui_) {
+ // We already have active login UI - make it visible.
+ FocusLoginUI();
+ return;
+ }
+
+ // Need to navigate to the settings page and display the UI.
+ if (profile_) {
+ Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
+ if (!browser) {
+ browser = Browser::Create(profile_);
+ browser->ShowOptionsTab(chrome::kSyncSetupSubPage);
+ browser->window()->Show();
+ } else {
+ browser->ShowOptionsTab(chrome::kSyncSetupSubPage);
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698