cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / chrome / browser / ui / webui / signin / login_ui_service.cc
blob713f62c840795a243d3e64c9ffc2e2a20e0c38a5
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/browser/signin_header_helper.h"
19 #include "components/signin/core/common/profile_management_switches.h"
21 #if defined(OS_CHROMEOS)
22 #include "chrome/browser/app_mode/app_mode_utils.h"
23 #endif
25 LoginUIService::LoginUIService(Profile* profile)
26 : ui_(NULL), profile_(profile) {
29 LoginUIService::~LoginUIService() {}
31 void LoginUIService::AddObserver(LoginUIService::Observer* observer) {
32 observer_list_.AddObserver(observer);
35 void LoginUIService::RemoveObserver(LoginUIService::Observer* observer) {
36 observer_list_.RemoveObserver(observer);
39 void LoginUIService::SetLoginUI(LoginUI* ui) {
40 DCHECK(!current_login_ui() || current_login_ui() == ui);
41 ui_ = ui;
42 FOR_EACH_OBSERVER(Observer, observer_list_, OnLoginUIShown(ui_));
45 void LoginUIService::LoginUIClosed(LoginUI* ui) {
46 if (current_login_ui() != ui)
47 return;
49 ui_ = NULL;
50 FOR_EACH_OBSERVER(Observer, observer_list_, OnLoginUIClosed(ui));
53 void LoginUIService::SyncConfirmationUIClosed(bool configure_sync_first) {
54 FOR_EACH_OBSERVER(
55 Observer,
56 observer_list_,
57 OnSyncConfirmationUIClosed(configure_sync_first));
60 void LoginUIService::UntrustedLoginUIShown() {
61 FOR_EACH_OBSERVER(Observer, observer_list_, OnUntrustedLoginUIShown());
64 void LoginUIService::ShowLoginPopup() {
65 #if defined(OS_CHROMEOS)
66 if (chrome::IsRunningInForcedAppMode())
67 InlineLoginDialog::Show(profile_);
68 #else
69 chrome::ScopedTabbedBrowserDisplayer displayer(
70 profile_, chrome::GetActiveDesktop());
71 chrome::ShowBrowserSignin(
72 displayer.browser(), signin_metrics::SOURCE_APP_LAUNCHER);
73 #endif
76 void LoginUIService::DisplayLoginResult(Browser* browser,
77 const base::string16& message) {
78 last_login_result_ = message;
79 if (switches::IsNewAvatarMenu()) {
80 browser->window()->ShowAvatarBubbleFromAvatarButton(
81 message.empty() ? BrowserWindow::AVATAR_BUBBLE_MODE_CONFIRM_SIGNIN :
82 BrowserWindow::AVATAR_BUBBLE_MODE_SHOW_ERROR,
83 signin::ManageAccountsParams());
84 } else {
85 #if defined(ENABLE_ONE_CLICK_SIGNIN)
86 browser->window()->ShowOneClickSigninBubble(
87 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE,
88 base::string16(), /* no SAML email */
89 message,
90 // This callback is never invoked.
91 // TODO(rogerta): Separate out the bubble API so we don't have to pass
92 // ignored |email| and |callback| params.
93 BrowserWindow::StartSyncCallback());
94 #endif
98 const base::string16& LoginUIService::GetLastLoginResult() {
99 return last_login_result_;