Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / chrome / browser / ui / webui / signin / login_ui_service.cc
bloba2786a8c062854d27aec8b5e3e5ac74e599a4236
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/browser_window.h"
12 #include "chrome/browser/ui/chrome_pages.h"
13 #include "chrome/browser/ui/host_desktop.h"
14 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
15 #include "chrome/browser/ui/sync/inline_login_dialog.h"
16 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
17 #include "chrome/common/url_constants.h"
18 #include "components/signin/core/common/profile_management_switches.h"
20 #if defined(OS_CHROMEOS)
21 #include "chrome/browser/app_mode/app_mode_utils.h"
22 #endif
24 LoginUIService::LoginUIService(Profile* profile)
25 : ui_(NULL), profile_(profile) {
28 LoginUIService::~LoginUIService() {}
30 void LoginUIService::AddObserver(LoginUIService::Observer* observer) {
31 observer_list_.AddObserver(observer);
34 void LoginUIService::RemoveObserver(LoginUIService::Observer* observer) {
35 observer_list_.RemoveObserver(observer);
38 void LoginUIService::SetLoginUI(LoginUI* ui) {
39 DCHECK(!current_login_ui() || current_login_ui() == ui);
40 ui_ = ui;
41 FOR_EACH_OBSERVER(Observer, observer_list_, OnLoginUIShown(ui_));
44 void LoginUIService::LoginUIClosed(LoginUI* ui) {
45 if (current_login_ui() != ui)
46 return;
48 ui_ = NULL;
49 FOR_EACH_OBSERVER(Observer, observer_list_, OnLoginUIClosed(ui));
52 void LoginUIService::SyncConfirmationUIClosed(bool configure_sync_first) {
53 FOR_EACH_OBSERVER(
54 Observer,
55 observer_list_,
56 OnSyncConfirmationUIClosed(configure_sync_first));
59 void LoginUIService::UntrustedLoginUIShown() {
60 FOR_EACH_OBSERVER(Observer, observer_list_, OnUntrustedLoginUIShown());
63 void LoginUIService::ShowLoginPopup() {
64 #if defined(OS_CHROMEOS)
65 if (chrome::IsRunningInForcedAppMode())
66 InlineLoginDialog::Show(profile_);
67 #else
68 chrome::ScopedTabbedBrowserDisplayer displayer(
69 profile_, chrome::GetActiveDesktop());
70 chrome::ShowBrowserSignin(
71 displayer.browser(), signin_metrics::SOURCE_APP_LAUNCHER);
72 #endif
75 void LoginUIService::DisplayLoginResult(Browser* browser,
76 const base::string16& message) {
77 last_login_result_ = message;
78 if (switches::IsNewAvatarMenu()) {
79 browser->window()->ShowAvatarBubbleFromAvatarButton(
80 message.empty() ? BrowserWindow::AVATAR_BUBBLE_MODE_CONFIRM_SIGNIN :
81 BrowserWindow::AVATAR_BUBBLE_MODE_SHOW_ERROR,
82 signin::ManageAccountsParams());
83 } else {
84 #if defined(ENABLE_ONE_CLICK_SIGNIN)
85 browser->window()->ShowOneClickSigninBubble(
86 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE,
87 base::string16(), /* no SAML email */
88 message,
89 // This callback is never invoked.
90 // TODO(rogerta): Separate out the bubble API so we don't have to pass
91 // ignored |email| and |callback| params.
92 BrowserWindow::StartSyncCallback());
93 #endif
97 const base::string16& LoginUIService::GetLastLoginResult() {
98 return last_login_result_;