Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / webui / signin / login_ui_service.cc
blobb01cc0dddf21e5ef0710bc923d6a975213f25c4b
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.
5 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/signin/signin_promo.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_navigator.h"
11 #include "chrome/browser/ui/chrome_pages.h"
12 #include "chrome/browser/ui/host_desktop.h"
13 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
14 #include "chrome/browser/ui/sync/inline_login_dialog.h"
15 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
16 #include "chrome/common/url_constants.h"
18 #if defined(OS_CHROMEOS)
19 #include "chrome/browser/app_mode/app_mode_utils.h"
20 #endif
22 LoginUIService::LoginUIService(Profile* profile)
23 : ui_(NULL), profile_(profile) {
26 LoginUIService::~LoginUIService() {}
28 void LoginUIService::AddObserver(LoginUIService::Observer* observer) {
29 observer_list_.AddObserver(observer);
32 void LoginUIService::RemoveObserver(LoginUIService::Observer* observer) {
33 observer_list_.RemoveObserver(observer);
36 void LoginUIService::SetLoginUI(LoginUI* ui) {
37 DCHECK(!current_login_ui() || current_login_ui() == ui);
38 ui_ = ui;
39 FOR_EACH_OBSERVER(Observer, observer_list_, OnLoginUIShown(ui_));
42 void LoginUIService::LoginUIClosed(LoginUI* ui) {
43 if (current_login_ui() != ui)
44 return;
46 ui_ = NULL;
47 FOR_EACH_OBSERVER(Observer, observer_list_, OnLoginUIClosed(ui));
50 void LoginUIService::ShowLoginPopup() {
51 #if defined(OS_CHROMEOS)
52 if (chrome::IsRunningInForcedAppMode())
53 InlineLoginDialog::Show(profile_);
54 #else
55 chrome::ScopedTabbedBrowserDisplayer displayer(
56 profile_, chrome::GetActiveDesktop());
57 chrome::ShowBrowserSignin(displayer.browser(), signin::SOURCE_APP_LAUNCHER);
58 #endif