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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
6
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_list.h"
10 #include "chrome/browser/ui/browser_window.h"
11 #include "chrome/common/url_constants.h"
12 #include "content/browser/renderer_host/render_view_host.h"
13 #include "content/public/browser/render_view_host_delegate.h"
14 #include "content/public/browser/web_contents.h"
15 #include "content/public/browser/web_ui.h"
16
17 LoginUIService::LoginUIService(Profile* profile)
18 : ui_(NULL),
19 profile_(profile) {
20 }
21
22 LoginUIService::~LoginUIService() {}
23
24 void LoginUIService::SetLoginUI(content::WebUI* ui) {
25 DCHECK(!current_login_ui() || current_login_ui() == ui);
26 ui_ = ui;
27 }
28
29 void LoginUIService::ClearLoginUI(content::WebUI* ui) {
30 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
31 ui_ = NULL;
32 }
33
34 void LoginUIService::FocusLoginUI() {
35 if (!ui_) {
36 NOTREACHED() << "FocusLoginUI() called with no active login UI";
37 return;
38 }
39 ui_->GetWebContents()->GetRenderViewHost()->delegate()->Activate();
40 }
41
42 void LoginUIService::ShowLoginUI() {
43 if (ui_) {
44 // We already have active login UI - make it visible.
45 FocusLoginUI();
46 return;
47 }
48
49 // Need to navigate to the settings page and display the UI.
50 if (profile_) {
51 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
52 if (!browser) {
53 browser = Browser::Create(profile_);
54 browser->ShowOptionsTab(chrome::kSyncSetupSubPage);
55 browser->window()->Show();
56 } else {
57 browser->ShowOptionsTab(chrome::kSyncSetupSubPage);
58 }
59 }
60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698