| 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/lock/webui_screen_locker.h" | 5 #include "chrome/browser/chromeos/login/lock/webui_screen_locker.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/shell_port.h" | 8 #include "ash/shell_port.h" |
| 9 #include "ash/system/power/power_event_observer.h" | 9 #include "ash/system/power/power_event_observer.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "content/public/browser/notification_types.h" | 36 #include "content/public/browser/notification_types.h" |
| 37 #include "content/public/browser/render_widget_host_view.h" | 37 #include "content/public/browser/render_widget_host_view.h" |
| 38 #include "content/public/browser/web_contents.h" | 38 #include "content/public/browser/web_contents.h" |
| 39 #include "content/public/browser/web_ui.h" | 39 #include "content/public/browser/web_ui.h" |
| 40 #include "ui/aura/client/capture_client.h" | 40 #include "ui/aura/client/capture_client.h" |
| 41 #include "ui/aura/window_event_dispatcher.h" | 41 #include "ui/aura/window_event_dispatcher.h" |
| 42 #include "ui/base/l10n/l10n_util.h" | 42 #include "ui/base/l10n/l10n_util.h" |
| 43 #include "ui/base/x/x11_util.h" | 43 #include "ui/base/x/x11_util.h" |
| 44 #include "ui/display/display.h" | 44 #include "ui/display/display.h" |
| 45 #include "ui/display/screen.h" | 45 #include "ui/display/screen.h" |
| 46 #include "ui/keyboard/keyboard_controller.h" | |
| 47 #include "ui/keyboard/keyboard_util.h" | 46 #include "ui/keyboard/keyboard_util.h" |
| 48 #include "ui/views/controls/webview/webview.h" | 47 #include "ui/views/controls/webview/webview.h" |
| 49 | 48 |
| 50 namespace { | 49 namespace { |
| 51 | 50 |
| 52 // URL which corresponds to the login WebUI. | 51 // URL which corresponds to the login WebUI. |
| 53 const char kLoginURL[] = "chrome://oobe/lock"; | 52 const char kLoginURL[] = "chrome://oobe/lock"; |
| 54 | 53 |
| 55 // Disables virtual keyboard overscroll. Login UI will scroll user pods | 54 // Disables virtual keyboard overscroll. Login UI will scroll user pods |
| 56 // into view on JS side when virtual keyboard is shown. | 55 // into view on JS side when virtual keyboard is shown. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 //////////////////////////////////////////////////////////////////////////////// | 118 //////////////////////////////////////////////////////////////////////////////// |
| 120 // WebUIScreenLocker implementation. | 119 // WebUIScreenLocker implementation. |
| 121 | 120 |
| 122 WebUIScreenLocker::WebUIScreenLocker(ScreenLocker* screen_locker) | 121 WebUIScreenLocker::WebUIScreenLocker(ScreenLocker* screen_locker) |
| 123 : WebUILoginView(BuildConfigSettings()), | 122 : WebUILoginView(BuildConfigSettings()), |
| 124 screen_locker_(screen_locker), | 123 screen_locker_(screen_locker), |
| 125 network_state_helper_(new login::NetworkStateHelper), | 124 network_state_helper_(new login::NetworkStateHelper), |
| 126 weak_factory_(this) { | 125 weak_factory_(this) { |
| 127 set_should_emit_login_prompt_visible(false); | 126 set_should_emit_login_prompt_visible(false); |
| 128 ash::ShellPort::Get()->AddLockStateObserver(this); | 127 ash::ShellPort::Get()->AddLockStateObserver(this); |
| 129 ash::Shell::Get()->AddShellObserver(this); | |
| 130 display::Screen::GetScreen()->AddObserver(this); | 128 display::Screen::GetScreen()->AddObserver(this); |
| 131 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); | 129 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); |
| 132 | |
| 133 if (keyboard::KeyboardController::GetInstance()) { | |
| 134 keyboard::KeyboardController::GetInstance()->AddObserver(this); | |
| 135 is_observing_keyboard_ = true; | |
| 136 } | |
| 137 } | 130 } |
| 138 | 131 |
| 139 WebUIScreenLocker::~WebUIScreenLocker() { | 132 WebUIScreenLocker::~WebUIScreenLocker() { |
| 140 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); | 133 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); |
| 141 display::Screen::GetScreen()->RemoveObserver(this); | 134 display::Screen::GetScreen()->RemoveObserver(this); |
| 142 ash::ShellPort::Get()->RemoveLockStateObserver(this); | 135 ash::ShellPort::Get()->RemoveLockStateObserver(this); |
| 143 ash::Shell::Get()->RemoveShellObserver(this); | |
| 144 // In case of shutdown, lock_window_ may be deleted before WebUIScreenLocker. | 136 // In case of shutdown, lock_window_ may be deleted before WebUIScreenLocker. |
| 145 if (lock_window_) { | 137 if (lock_window_) { |
| 146 lock_window_->RemoveObserver(this); | 138 lock_window_->RemoveObserver(this); |
| 147 lock_window_->Close(); | 139 lock_window_->Close(); |
| 148 } | 140 } |
| 149 // If LockScreen() was called, we need to clear the signin screen handler | 141 // If LockScreen() was called, we need to clear the signin screen handler |
| 150 // delegate set in ShowSigninScreen so that it no longer points to us. | 142 // delegate set in ShowSigninScreen so that it no longer points to us. |
| 151 if (login_display_.get() && GetOobeUI()) | 143 if (login_display_.get() && GetOobeUI()) |
| 152 GetOobeUI()->ResetSigninScreenHandlerDelegate(); | 144 GetOobeUI()->ResetSigninScreenHandlerDelegate(); |
| 153 | 145 |
| 154 if (keyboard::KeyboardController::GetInstance() && is_observing_keyboard_) { | |
| 155 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); | |
| 156 is_observing_keyboard_ = false; | |
| 157 } | |
| 158 | |
| 159 ResetKeyboardOverscrollOverride(); | 146 ResetKeyboardOverscrollOverride(); |
| 160 | 147 |
| 161 RequestPreload(); | 148 RequestPreload(); |
| 162 } | 149 } |
| 163 | 150 |
| 164 void WebUIScreenLocker::LockScreen() { | 151 void WebUIScreenLocker::LockScreen() { |
| 165 gfx::Rect bounds = display::Screen::GetScreen()->GetPrimaryDisplay().bounds(); | 152 gfx::Rect bounds = display::Screen::GetScreen()->GetPrimaryDisplay().bounds(); |
| 166 | 153 |
| 167 lock_time_ = base::TimeTicks::Now(); | 154 lock_time_ = base::TimeTicks::Now(); |
| 168 lock_window_ = new LockWindow(this); | 155 lock_window_ = new LockWindow(this); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 | 394 |
| 408 void WebUIScreenLocker::RenderProcessGone(base::TerminationStatus status) { | 395 void WebUIScreenLocker::RenderProcessGone(base::TerminationStatus status) { |
| 409 if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID && | 396 if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID && |
| 410 status != base::TERMINATION_STATUS_NORMAL_TERMINATION) { | 397 status != base::TERMINATION_STATUS_NORMAL_TERMINATION) { |
| 411 LOG(ERROR) << "Renderer crash on lock screen; signing out"; | 398 LOG(ERROR) << "Renderer crash on lock screen; signing out"; |
| 412 Signout(); | 399 Signout(); |
| 413 } | 400 } |
| 414 } | 401 } |
| 415 | 402 |
| 416 //////////////////////////////////////////////////////////////////////////////// | 403 //////////////////////////////////////////////////////////////////////////////// |
| 417 // ash::ShellObserver: | |
| 418 | |
| 419 void WebUIScreenLocker::OnVirtualKeyboardStateChanged( | |
| 420 bool activated, | |
| 421 ash::WmWindow* root_window) { | |
| 422 if (keyboard::KeyboardController::GetInstance()) { | |
| 423 if (activated) { | |
| 424 if (!is_observing_keyboard_) { | |
| 425 keyboard::KeyboardController::GetInstance()->AddObserver(this); | |
| 426 is_observing_keyboard_ = true; | |
| 427 } | |
| 428 } else { | |
| 429 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); | |
| 430 is_observing_keyboard_ = false; | |
| 431 } | |
| 432 } | |
| 433 } | |
| 434 | |
| 435 //////////////////////////////////////////////////////////////////////////////// | |
| 436 // keyboard::KeyboardControllerObserver: | |
| 437 | |
| 438 void WebUIScreenLocker::OnKeyboardBoundsChanging( | |
| 439 const gfx::Rect& new_bounds) { | |
| 440 if (new_bounds.IsEmpty()) { | |
| 441 // Keyboard has been hidden. | |
| 442 if (GetOobeUI()) { | |
| 443 GetOobeUI()->GetCoreOobeView()->ShowControlBar(true); | |
| 444 GetOobeUI()->GetCoreOobeView()->ShowPinKeyboard(true); | |
| 445 } | |
| 446 } else { | |
| 447 // Keyboard has been shown. | |
| 448 if (GetOobeUI()) { | |
| 449 GetOobeUI()->GetCoreOobeView()->ShowControlBar(false); | |
| 450 GetOobeUI()->GetCoreOobeView()->ShowPinKeyboard(false); | |
| 451 } | |
| 452 } | |
| 453 } | |
| 454 | |
| 455 void WebUIScreenLocker::OnKeyboardClosed() {} | |
| 456 | |
| 457 //////////////////////////////////////////////////////////////////////////////// | |
| 458 // display::DisplayObserver: | 404 // display::DisplayObserver: |
| 459 | 405 |
| 460 void WebUIScreenLocker::OnDisplayAdded(const display::Display& new_display) {} | 406 void WebUIScreenLocker::OnDisplayAdded(const display::Display& new_display) {} |
| 461 | 407 |
| 462 void WebUIScreenLocker::OnDisplayRemoved(const display::Display& old_display) {} | 408 void WebUIScreenLocker::OnDisplayRemoved(const display::Display& old_display) {} |
| 463 | 409 |
| 464 void WebUIScreenLocker::OnDisplayMetricsChanged(const display::Display& display, | 410 void WebUIScreenLocker::OnDisplayMetricsChanged(const display::Display& display, |
| 465 uint32_t changed_metrics) { | 411 uint32_t changed_metrics) { |
| 466 display::Display primary_display = | 412 display::Display primary_display = |
| 467 display::Screen::GetScreen()->GetPrimaryDisplay(); | 413 display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 468 if (display.id() != primary_display.id() || | 414 if (display.id() != primary_display.id() || |
| 469 !(changed_metrics & DISPLAY_METRIC_BOUNDS)) { | 415 !(changed_metrics & DISPLAY_METRIC_BOUNDS)) { |
| 470 return; | 416 return; |
| 471 } | 417 } |
| 472 | 418 |
| 473 if (GetOobeUI()) { | 419 if (GetOobeUI()) { |
| 474 const gfx::Size& size = primary_display.size(); | 420 const gfx::Size& size = primary_display.size(); |
| 475 GetOobeUI()->GetCoreOobeView()->SetClientAreaSize(size.width(), | 421 GetOobeUI()->GetCoreOobeView()->SetClientAreaSize(size.width(), |
| 476 size.height()); | 422 size.height()); |
| 477 } | 423 } |
| 478 } | 424 } |
| 479 | 425 |
| 480 } // namespace chromeos | 426 } // namespace chromeos |
| OLD | NEW |