| 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" | |
| 8 #include "ash/wm/lock_state_controller.h" | |
| 9 #include "ash/wm/lock_state_observer.h" | |
| 10 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 11 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/values.h" | 10 #include "base/values.h" |
| 14 #include "chrome/browser/browser_shutdown.h" | 11 #include "chrome/browser/browser_shutdown.h" |
| 15 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
| 16 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 13 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
| 17 #include "chrome/browser/chromeos/login/helper.h" | 14 #include "chrome/browser/chromeos/login/helper.h" |
| 18 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 15 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
| 19 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" | 16 #include "chrome/browser/chromeos/login/ui/webui_login_display.h" |
| 20 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 17 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| 21 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" | 18 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
| 22 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
| 23 #include "chromeos/dbus/dbus_thread_manager.h" | 20 #include "chromeos/dbus/dbus_thread_manager.h" |
| 24 #include "components/user_manager/user.h" | 21 #include "components/user_manager/user.h" |
| 25 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
| 26 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
| 27 #include "content/public/browser/notification_types.h" | 24 #include "content/public/browser/notification_types.h" |
| 28 #include "content/public/browser/render_widget_host_view.h" | 25 #include "content/public/browser/render_widget_host_view.h" |
| 29 #include "content/public/browser/web_ui.h" | 26 #include "content/public/browser/web_ui.h" |
| 30 #include "ui/aura/client/capture_client.h" | 27 #include "ui/aura/client/capture_client.h" |
| 31 #include "ui/aura/window_event_dispatcher.h" | 28 #include "ui/aura/window_event_dispatcher.h" |
| 32 #include "ui/base/x/x11_util.h" | 29 #include "ui/base/x/x11_util.h" |
| 33 #include "ui/gfx/screen.h" | 30 #include "ui/gfx/screen.h" |
| 34 #include "ui/keyboard/keyboard_controller.h" | 31 #include "ui/keyboard/keyboard_controller.h" |
| 35 #include "ui/keyboard/keyboard_util.h" | 32 #include "ui/keyboard/keyboard_util.h" |
| 36 #include "ui/views/controls/webview/webview.h" | 33 #include "ui/views/controls/webview/webview.h" |
| 37 | 34 |
| 35 #if !defined(USE_ATHENA) |
| 36 #include "ash/wm/lock_state_controller.h" |
| 37 #include "ash/wm/lock_state_observer.h" |
| 38 #endif |
| 39 |
| 38 namespace { | 40 namespace { |
| 39 | 41 |
| 40 // URL which corresponds to the login WebUI. | 42 // URL which corresponds to the login WebUI. |
| 41 const char kLoginURL[] = "chrome://oobe/lock"; | 43 const char kLoginURL[] = "chrome://oobe/lock"; |
| 42 | 44 |
| 43 // Disables virtual keyboard overscroll. Login UI will scroll user pods | 45 // Disables virtual keyboard overscroll. Login UI will scroll user pods |
| 44 // into view on JS side when virtual keyboard is shown. | 46 // into view on JS side when virtual keyboard is shown. |
| 45 void DisableKeyboardOverscroll() { | 47 void DisableKeyboardOverscroll() { |
| 46 keyboard::SetKeyboardOverscrollOverride( | 48 keyboard::SetKeyboardOverscrollOverride( |
| 47 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED); | 49 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 73 #endif | 75 #endif |
| 74 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); | 76 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); |
| 75 | 77 |
| 76 if (keyboard::KeyboardController::GetInstance()) { | 78 if (keyboard::KeyboardController::GetInstance()) { |
| 77 keyboard::KeyboardController::GetInstance()->AddObserver(this); | 79 keyboard::KeyboardController::GetInstance()->AddObserver(this); |
| 78 is_observing_keyboard_ = true; | 80 is_observing_keyboard_ = true; |
| 79 } | 81 } |
| 80 } | 82 } |
| 81 | 83 |
| 82 void WebUIScreenLocker::LockScreen() { | 84 void WebUIScreenLocker::LockScreen() { |
| 83 gfx::Rect bounds(ash::Shell::GetScreen()->GetPrimaryDisplay().bounds()); | 85 gfx::Rect bounds = |
| 86 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().bounds(); |
| 84 | 87 |
| 85 lock_time_ = base::TimeTicks::Now(); | 88 lock_time_ = base::TimeTicks::Now(); |
| 86 LockWindow* lock_window = LockWindow::Create(); | 89 LockWindow* lock_window = LockWindow::Create(); |
| 87 lock_window->set_observer(this); | 90 lock_window->set_observer(this); |
| 88 lock_window->set_initially_focused_view(this); | 91 lock_window->set_initially_focused_view(this); |
| 89 lock_window_ = lock_window->GetWidget(); | 92 lock_window_ = lock_window->GetWidget(); |
| 90 lock_window_->AddObserver(this); | 93 lock_window_->AddObserver(this); |
| 91 WebUILoginView::Init(); | 94 WebUILoginView::Init(); |
| 92 lock_window_->SetContentsView(this); | 95 lock_window_->SetContentsView(this); |
| 93 lock_window_->SetBounds(bounds); | 96 lock_window_->SetBounds(bounds); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 void WebUIScreenLocker::OnLockWindowReady() { | 299 void WebUIScreenLocker::OnLockWindowReady() { |
| 297 VLOG(1) << "Lock window ready; WebUI is " << (webui_ready_ ? "too" : "not"); | 300 VLOG(1) << "Lock window ready; WebUI is " << (webui_ready_ ? "too" : "not"); |
| 298 lock_ready_ = true; | 301 lock_ready_ = true; |
| 299 if (webui_ready_) | 302 if (webui_ready_) |
| 300 ScreenLockReady(); | 303 ScreenLockReady(); |
| 301 } | 304 } |
| 302 | 305 |
| 303 //////////////////////////////////////////////////////////////////////////////// | 306 //////////////////////////////////////////////////////////////////////////////// |
| 304 // SessionLockStateObserver override. | 307 // SessionLockStateObserver override. |
| 305 | 308 |
| 309 #if !defined(USE_ATHENA) |
| 306 void WebUIScreenLocker::OnLockStateEvent( | 310 void WebUIScreenLocker::OnLockStateEvent( |
| 307 ash::LockStateObserver::EventType event) { | 311 ash::LockStateObserver::EventType event) { |
| 308 if (event == ash::LockStateObserver::EVENT_LOCK_ANIMATION_FINISHED) { | 312 if (event == ash::LockStateObserver::EVENT_LOCK_ANIMATION_FINISHED) { |
| 309 // Release capture if any. | 313 // Release capture if any. |
| 310 aura::client::GetCaptureClient(GetNativeWindow()->GetRootWindow())-> | 314 aura::client::GetCaptureClient(GetNativeWindow()->GetRootWindow())-> |
| 311 SetCapture(NULL); | 315 SetCapture(NULL); |
| 312 GetWebUI()->CallJavascriptFunction("cr.ui.Oobe.animateOnceFullyDisplayed"); | 316 GetWebUI()->CallJavascriptFunction("cr.ui.Oobe.animateOnceFullyDisplayed"); |
| 313 } | 317 } |
| 314 } | 318 } |
| 319 #endif |
| 315 | 320 |
| 316 //////////////////////////////////////////////////////////////////////////////// | 321 //////////////////////////////////////////////////////////////////////////////// |
| 317 // WidgetObserver override. | 322 // WidgetObserver override. |
| 318 | 323 |
| 319 void WebUIScreenLocker::OnWidgetDestroying(views::Widget* widget) { | 324 void WebUIScreenLocker::OnWidgetDestroying(views::Widget* widget) { |
| 320 lock_window_->RemoveObserver(this); | 325 lock_window_->RemoveObserver(this); |
| 321 lock_window_ = NULL; | 326 lock_window_ = NULL; |
| 322 } | 327 } |
| 323 | 328 |
| 324 //////////////////////////////////////////////////////////////////////////////// | 329 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 18 matching lines...) Expand all Loading... |
| 343 if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID && | 348 if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID && |
| 344 status != base::TERMINATION_STATUS_NORMAL_TERMINATION) { | 349 status != base::TERMINATION_STATUS_NORMAL_TERMINATION) { |
| 345 LOG(ERROR) << "Renderer crash on lock screen"; | 350 LOG(ERROR) << "Renderer crash on lock screen"; |
| 346 Signout(); | 351 Signout(); |
| 347 } | 352 } |
| 348 } | 353 } |
| 349 | 354 |
| 350 //////////////////////////////////////////////////////////////////////////////// | 355 //////////////////////////////////////////////////////////////////////////////// |
| 351 // ash::KeyboardStateObserver overrides. | 356 // ash::KeyboardStateObserver overrides. |
| 352 | 357 |
| 358 #if !defined(USE_ATHENA) |
| 353 void WebUIScreenLocker::OnVirtualKeyboardStateChanged(bool activated) { | 359 void WebUIScreenLocker::OnVirtualKeyboardStateChanged(bool activated) { |
| 354 if (keyboard::KeyboardController::GetInstance()) { | 360 if (keyboard::KeyboardController::GetInstance()) { |
| 355 if (activated) { | 361 if (activated) { |
| 356 if (!is_observing_keyboard_) { | 362 if (!is_observing_keyboard_) { |
| 357 keyboard::KeyboardController::GetInstance()->AddObserver(this); | 363 keyboard::KeyboardController::GetInstance()->AddObserver(this); |
| 358 is_observing_keyboard_ = true; | 364 is_observing_keyboard_ = true; |
| 359 } | 365 } |
| 360 } else { | 366 } else { |
| 361 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); | 367 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); |
| 362 is_observing_keyboard_ = false; | 368 is_observing_keyboard_ = false; |
| 363 } | 369 } |
| 364 } | 370 } |
| 365 } | 371 } |
| 372 #endif |
| 366 | 373 |
| 367 //////////////////////////////////////////////////////////////////////////////// | 374 //////////////////////////////////////////////////////////////////////////////// |
| 368 // keyboard::KeyboardControllerObserver overrides. | 375 // keyboard::KeyboardControllerObserver overrides. |
| 369 | 376 |
| 370 void WebUIScreenLocker::OnKeyboardBoundsChanging( | 377 void WebUIScreenLocker::OnKeyboardBoundsChanging( |
| 371 const gfx::Rect& new_bounds) { | 378 const gfx::Rect& new_bounds) { |
| 372 if (new_bounds.IsEmpty() && !keyboard_bounds_.IsEmpty()) { | 379 if (new_bounds.IsEmpty() && !keyboard_bounds_.IsEmpty()) { |
| 373 // Keyboard has been hidden. | 380 // Keyboard has been hidden. |
| 374 if (GetOobeUI()) { | 381 if (GetOobeUI()) { |
| 375 GetOobeUI()->GetCoreOobeActor()->ShowControlBar(true); | 382 GetOobeUI()->GetCoreOobeActor()->ShowControlBar(true); |
| 376 if (login::LoginScrollIntoViewEnabled()) | 383 if (login::LoginScrollIntoViewEnabled()) |
| 377 GetOobeUI()->GetCoreOobeActor()->SetKeyboardState(false, new_bounds); | 384 GetOobeUI()->GetCoreOobeActor()->SetKeyboardState(false, new_bounds); |
| 378 } | 385 } |
| 379 } else if (!new_bounds.IsEmpty() && keyboard_bounds_.IsEmpty()) { | 386 } else if (!new_bounds.IsEmpty() && keyboard_bounds_.IsEmpty()) { |
| 380 // Keyboard has been shown. | 387 // Keyboard has been shown. |
| 381 if (GetOobeUI()) { | 388 if (GetOobeUI()) { |
| 382 GetOobeUI()->GetCoreOobeActor()->ShowControlBar(false); | 389 GetOobeUI()->GetCoreOobeActor()->ShowControlBar(false); |
| 383 if (login::LoginScrollIntoViewEnabled()) | 390 if (login::LoginScrollIntoViewEnabled()) |
| 384 GetOobeUI()->GetCoreOobeActor()->SetKeyboardState(true, new_bounds); | 391 GetOobeUI()->GetCoreOobeActor()->SetKeyboardState(true, new_bounds); |
| 385 } | 392 } |
| 386 } | 393 } |
| 387 | 394 |
| 388 keyboard_bounds_ = new_bounds; | 395 keyboard_bounds_ = new_bounds; |
| 389 } | 396 } |
| 390 | 397 |
| 391 } // namespace chromeos | 398 } // namespace chromeos |
| OLD | NEW |