| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 5 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/public/cpp/shell_window_ids.h" | 10 #include "ash/public/cpp/shell_window_ids.h" |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 pointer_factory_(this), | 366 pointer_factory_(this), |
| 367 animation_weak_ptr_factory_(this) { | 367 animation_weak_ptr_factory_(this) { |
| 368 if (ash_util::IsRunningInMash()) { | 368 if (ash_util::IsRunningInMash()) { |
| 369 // Animation, and initializing hidden, are not currently supported for Mash. | 369 // Animation, and initializing hidden, are not currently supported for Mash. |
| 370 finalize_animation_type_ = ANIMATION_NONE; | 370 finalize_animation_type_ = ANIMATION_NONE; |
| 371 initialize_webui_hidden_ = false; | 371 initialize_webui_hidden_ = false; |
| 372 } | 372 } |
| 373 | 373 |
| 374 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); | 374 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); |
| 375 CrasAudioHandler::Get()->AddAudioObserver(this); | 375 CrasAudioHandler::Get()->AddAudioObserver(this); |
| 376 if (keyboard::KeyboardController::GetInstance()) { | |
| 377 keyboard::KeyboardController::GetInstance()->AddObserver(this); | |
| 378 is_observing_keyboard_ = true; | |
| 379 } | |
| 380 | 376 |
| 381 if (!ash_util::IsRunningInMash()) | |
| 382 ash::Shell::Get()->AddShellObserver(this); | |
| 383 else | |
| 384 NOTIMPLEMENTED(); | |
| 385 display::Screen::GetScreen()->AddObserver(this); | 377 display::Screen::GetScreen()->AddObserver(this); |
| 386 | 378 |
| 387 // We need to listen to CLOSE_ALL_BROWSERS_REQUEST but not APP_TERMINATING | 379 // We need to listen to CLOSE_ALL_BROWSERS_REQUEST but not APP_TERMINATING |
| 388 // because/ APP_TERMINATING will never be fired as long as this keeps | 380 // because/ APP_TERMINATING will never be fired as long as this keeps |
| 389 // ref-count. CLOSE_ALL_BROWSERS_REQUEST is safe here because there will be no | 381 // ref-count. CLOSE_ALL_BROWSERS_REQUEST is safe here because there will be no |
| 390 // browser instance that will block the shutdown. | 382 // browser instance that will block the shutdown. |
| 391 registrar_.Add(this, | 383 registrar_.Add(this, |
| 392 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, | 384 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, |
| 393 content::NotificationService::AllSources()); | 385 content::NotificationService::AllSources()); |
| 394 | 386 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 scoped_drag_drop_disabler_.reset(new aura::client::ScopedDragDropDisabler( | 477 scoped_drag_drop_disabler_.reset(new aura::client::ScopedDragDropDisabler( |
| 486 ash::Shell::GetPrimaryRootWindow())); | 478 ash::Shell::GetPrimaryRootWindow())); |
| 487 } else { | 479 } else { |
| 488 NOTIMPLEMENTED(); | 480 NOTIMPLEMENTED(); |
| 489 } | 481 } |
| 490 } | 482 } |
| 491 | 483 |
| 492 LoginDisplayHostImpl::~LoginDisplayHostImpl() { | 484 LoginDisplayHostImpl::~LoginDisplayHostImpl() { |
| 493 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); | 485 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); |
| 494 CrasAudioHandler::Get()->RemoveAudioObserver(this); | 486 CrasAudioHandler::Get()->RemoveAudioObserver(this); |
| 495 if (keyboard::KeyboardController::GetInstance() && is_observing_keyboard_) { | |
| 496 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); | |
| 497 is_observing_keyboard_ = false; | |
| 498 } | |
| 499 | |
| 500 if (!ash_util::IsRunningInMash()) | |
| 501 ash::Shell::Get()->RemoveShellObserver(this); | |
| 502 else | |
| 503 NOTIMPLEMENTED(); | |
| 504 display::Screen::GetScreen()->RemoveObserver(this); | 487 display::Screen::GetScreen()->RemoveObserver(this); |
| 505 | 488 |
| 506 if (login_view_ && login_window_) | 489 if (login_view_ && login_window_) |
| 507 login_window_->RemoveRemovalsObserver(this); | 490 login_window_->RemoveRemovalsObserver(this); |
| 508 | 491 |
| 509 if (login_window_delegate_) | 492 if (login_window_delegate_) |
| 510 login_window_delegate_->LoginDisplayHostDestroyed(); | 493 login_window_delegate_->LoginDisplayHostDestroyed(); |
| 511 | 494 |
| 512 chrome::MultiUserWindowManager* window_manager = | 495 chrome::MultiUserWindowManager* window_manager = |
| 513 chrome::MultiUserWindowManager::GetInstance(); | 496 chrome::MultiUserWindowManager::GetInstance(); |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 } | 998 } |
| 1016 | 999 |
| 1017 //////////////////////////////////////////////////////////////////////////////// | 1000 //////////////////////////////////////////////////////////////////////////////// |
| 1018 // LoginDisplayHostImpl, chromeos::CrasAudioHandler::AudioObserver: | 1001 // LoginDisplayHostImpl, chromeos::CrasAudioHandler::AudioObserver: |
| 1019 | 1002 |
| 1020 void LoginDisplayHostImpl::OnActiveOutputNodeChanged() { | 1003 void LoginDisplayHostImpl::OnActiveOutputNodeChanged() { |
| 1021 TryToPlayStartupSound(); | 1004 TryToPlayStartupSound(); |
| 1022 } | 1005 } |
| 1023 | 1006 |
| 1024 //////////////////////////////////////////////////////////////////////////////// | 1007 //////////////////////////////////////////////////////////////////////////////// |
| 1025 // LoginDisplayHostImpl, ash::ShellObserver: | |
| 1026 | |
| 1027 void LoginDisplayHostImpl::OnVirtualKeyboardStateChanged( | |
| 1028 bool activated, | |
| 1029 ash::WmWindow* root_window) { | |
| 1030 if (keyboard::KeyboardController::GetInstance()) { | |
| 1031 if (activated) { | |
| 1032 if (!is_observing_keyboard_) { | |
| 1033 keyboard::KeyboardController::GetInstance()->AddObserver(this); | |
| 1034 is_observing_keyboard_ = true; | |
| 1035 } | |
| 1036 } else { | |
| 1037 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); | |
| 1038 is_observing_keyboard_ = false; | |
| 1039 } | |
| 1040 } | |
| 1041 } | |
| 1042 | |
| 1043 //////////////////////////////////////////////////////////////////////////////// | |
| 1044 // LoginDisplayHostImpl, keyboard::KeyboardControllerObserver: | |
| 1045 | |
| 1046 void LoginDisplayHostImpl::OnKeyboardBoundsChanging( | |
| 1047 const gfx::Rect& new_bounds) { | |
| 1048 if (new_bounds.IsEmpty()) { | |
| 1049 // Keyboard has been hidden. | |
| 1050 if (GetOobeUI()) | |
| 1051 GetOobeUI()->GetCoreOobeView()->ShowControlBar(true); | |
| 1052 } else if (!new_bounds.IsEmpty()) { | |
| 1053 // Keyboard has been shown. | |
| 1054 if (GetOobeUI()) | |
| 1055 GetOobeUI()->GetCoreOobeView()->ShowControlBar(false); | |
| 1056 } | |
| 1057 } | |
| 1058 | |
| 1059 void LoginDisplayHostImpl::OnKeyboardClosed() {} | |
| 1060 | |
| 1061 //////////////////////////////////////////////////////////////////////////////// | |
| 1062 // LoginDisplayHostImpl, display::DisplayObserver: | 1008 // LoginDisplayHostImpl, display::DisplayObserver: |
| 1063 | 1009 |
| 1064 void LoginDisplayHostImpl::OnDisplayAdded(const display::Display& new_display) { | 1010 void LoginDisplayHostImpl::OnDisplayAdded(const display::Display& new_display) { |
| 1065 } | 1011 } |
| 1066 | 1012 |
| 1067 void LoginDisplayHostImpl::OnDisplayRemoved( | 1013 void LoginDisplayHostImpl::OnDisplayRemoved( |
| 1068 const display::Display& old_display) {} | 1014 const display::Display& old_display) {} |
| 1069 | 1015 |
| 1070 void LoginDisplayHostImpl::OnDisplayMetricsChanged( | 1016 void LoginDisplayHostImpl::OnDisplayMetricsChanged( |
| 1071 const display::Display& display, | 1017 const display::Display& display, |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1484 // Chrome locale. Otherwise it will be lost if Chrome restarts. | 1430 // Chrome locale. Otherwise it will be lost if Chrome restarts. |
| 1485 // Don't need to schedule pref save because setting initial local | 1431 // Don't need to schedule pref save because setting initial local |
| 1486 // will enforce preference saving. | 1432 // will enforce preference saving. |
| 1487 prefs->SetString(prefs::kApplicationLocale, locale); | 1433 prefs->SetString(prefs::kApplicationLocale, locale); |
| 1488 StartupUtils::SetInitialLocale(locale); | 1434 StartupUtils::SetInitialLocale(locale); |
| 1489 | 1435 |
| 1490 TriggerShowLoginWizardFinish(locale, std::move(data)); | 1436 TriggerShowLoginWizardFinish(locale, std::move(data)); |
| 1491 } | 1437 } |
| 1492 | 1438 |
| 1493 } // namespace chromeos | 1439 } // namespace chromeos |
| OLD | NEW |