Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: chrome/browser/chromeos/login/lock/webui_screen_locker.cc

Issue 689683004: Make login code not depend on Ash when use_athena=1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@athena_do_not_use_ash44_ui
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/shell.h"
37 #include "ash/wm/lock_state_controller.h"
38 #include "ash/wm/lock_state_observer.h"
39 #endif
40
38 namespace { 41 namespace {
39 42
40 // URL which corresponds to the login WebUI. 43 // URL which corresponds to the login WebUI.
41 const char kLoginURL[] = "chrome://oobe/lock"; 44 const char kLoginURL[] = "chrome://oobe/lock";
42 45
43 // Disables virtual keyboard overscroll. Login UI will scroll user pods 46 // Disables virtual keyboard overscroll. Login UI will scroll user pods
44 // into view on JS side when virtual keyboard is shown. 47 // into view on JS side when virtual keyboard is shown.
45 void DisableKeyboardOverscroll() { 48 void DisableKeyboardOverscroll() {
46 keyboard::SetKeyboardOverscrollOverride( 49 keyboard::SetKeyboardOverscrollOverride(
47 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED); 50 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED);
(...skipping 25 matching lines...) Expand all
73 #endif 76 #endif
74 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); 77 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this);
75 78
76 if (keyboard::KeyboardController::GetInstance()) { 79 if (keyboard::KeyboardController::GetInstance()) {
77 keyboard::KeyboardController::GetInstance()->AddObserver(this); 80 keyboard::KeyboardController::GetInstance()->AddObserver(this);
78 is_observing_keyboard_ = true; 81 is_observing_keyboard_ = true;
79 } 82 }
80 } 83 }
81 84
82 void WebUIScreenLocker::LockScreen() { 85 void WebUIScreenLocker::LockScreen() {
83 gfx::Rect bounds(ash::Shell::GetScreen()->GetPrimaryDisplay().bounds()); 86 gfx::Rect bounds;
87 #if !defined(USE_ATHENA)
88 bounds = ash::Shell::GetScreen()->GetPrimaryDisplay().bounds();
oshima 2014/10/30 18:11:42 ditto
89 #endif
84 90
85 lock_time_ = base::TimeTicks::Now(); 91 lock_time_ = base::TimeTicks::Now();
86 LockWindow* lock_window = LockWindow::Create(); 92 LockWindow* lock_window = LockWindow::Create();
87 lock_window->set_observer(this); 93 lock_window->set_observer(this);
88 lock_window->set_initially_focused_view(this); 94 lock_window->set_initially_focused_view(this);
89 lock_window_ = lock_window->GetWidget(); 95 lock_window_ = lock_window->GetWidget();
90 lock_window_->AddObserver(this); 96 lock_window_->AddObserver(this);
91 WebUILoginView::Init(); 97 WebUILoginView::Init();
92 lock_window_->SetContentsView(this); 98 lock_window_->SetContentsView(this);
93 lock_window_->SetBounds(bounds); 99 lock_window_->SetBounds(bounds);
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 void WebUIScreenLocker::OnLockWindowReady() { 302 void WebUIScreenLocker::OnLockWindowReady() {
297 VLOG(1) << "Lock window ready; WebUI is " << (webui_ready_ ? "too" : "not"); 303 VLOG(1) << "Lock window ready; WebUI is " << (webui_ready_ ? "too" : "not");
298 lock_ready_ = true; 304 lock_ready_ = true;
299 if (webui_ready_) 305 if (webui_ready_)
300 ScreenLockReady(); 306 ScreenLockReady();
301 } 307 }
302 308
303 //////////////////////////////////////////////////////////////////////////////// 309 ////////////////////////////////////////////////////////////////////////////////
304 // SessionLockStateObserver override. 310 // SessionLockStateObserver override.
305 311
312 #if !defined(USE_ATHENA)
306 void WebUIScreenLocker::OnLockStateEvent( 313 void WebUIScreenLocker::OnLockStateEvent(
307 ash::LockStateObserver::EventType event) { 314 ash::LockStateObserver::EventType event) {
308 if (event == ash::LockStateObserver::EVENT_LOCK_ANIMATION_FINISHED) { 315 if (event == ash::LockStateObserver::EVENT_LOCK_ANIMATION_FINISHED) {
309 // Release capture if any. 316 // Release capture if any.
310 aura::client::GetCaptureClient(GetNativeWindow()->GetRootWindow())-> 317 aura::client::GetCaptureClient(GetNativeWindow()->GetRootWindow())->
311 SetCapture(NULL); 318 SetCapture(NULL);
312 GetWebUI()->CallJavascriptFunction("cr.ui.Oobe.animateOnceFullyDisplayed"); 319 GetWebUI()->CallJavascriptFunction("cr.ui.Oobe.animateOnceFullyDisplayed");
313 } 320 }
314 } 321 }
322 #endif
315 323
316 //////////////////////////////////////////////////////////////////////////////// 324 ////////////////////////////////////////////////////////////////////////////////
317 // WidgetObserver override. 325 // WidgetObserver override.
318 326
319 void WebUIScreenLocker::OnWidgetDestroying(views::Widget* widget) { 327 void WebUIScreenLocker::OnWidgetDestroying(views::Widget* widget) {
320 lock_window_->RemoveObserver(this); 328 lock_window_->RemoveObserver(this);
321 lock_window_ = NULL; 329 lock_window_ = NULL;
322 } 330 }
323 331
324 //////////////////////////////////////////////////////////////////////////////// 332 ////////////////////////////////////////////////////////////////////////////////
(...skipping 18 matching lines...) Expand all
343 if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID && 351 if (browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID &&
344 status != base::TERMINATION_STATUS_NORMAL_TERMINATION) { 352 status != base::TERMINATION_STATUS_NORMAL_TERMINATION) {
345 LOG(ERROR) << "Renderer crash on lock screen"; 353 LOG(ERROR) << "Renderer crash on lock screen";
346 Signout(); 354 Signout();
347 } 355 }
348 } 356 }
349 357
350 //////////////////////////////////////////////////////////////////////////////// 358 ////////////////////////////////////////////////////////////////////////////////
351 // ash::KeyboardStateObserver overrides. 359 // ash::KeyboardStateObserver overrides.
352 360
361 #if !defined(USE_ATHENA)
353 void WebUIScreenLocker::OnVirtualKeyboardStateChanged(bool activated) { 362 void WebUIScreenLocker::OnVirtualKeyboardStateChanged(bool activated) {
354 if (keyboard::KeyboardController::GetInstance()) { 363 if (keyboard::KeyboardController::GetInstance()) {
355 if (activated) { 364 if (activated) {
356 if (!is_observing_keyboard_) { 365 if (!is_observing_keyboard_) {
357 keyboard::KeyboardController::GetInstance()->AddObserver(this); 366 keyboard::KeyboardController::GetInstance()->AddObserver(this);
358 is_observing_keyboard_ = true; 367 is_observing_keyboard_ = true;
359 } 368 }
360 } else { 369 } else {
361 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); 370 keyboard::KeyboardController::GetInstance()->RemoveObserver(this);
362 is_observing_keyboard_ = false; 371 is_observing_keyboard_ = false;
363 } 372 }
364 } 373 }
365 } 374 }
375 #endif
366 376
367 //////////////////////////////////////////////////////////////////////////////// 377 ////////////////////////////////////////////////////////////////////////////////
368 // keyboard::KeyboardControllerObserver overrides. 378 // keyboard::KeyboardControllerObserver overrides.
369 379
370 void WebUIScreenLocker::OnKeyboardBoundsChanging( 380 void WebUIScreenLocker::OnKeyboardBoundsChanging(
371 const gfx::Rect& new_bounds) { 381 const gfx::Rect& new_bounds) {
372 if (new_bounds.IsEmpty() && !keyboard_bounds_.IsEmpty()) { 382 if (new_bounds.IsEmpty() && !keyboard_bounds_.IsEmpty()) {
373 // Keyboard has been hidden. 383 // Keyboard has been hidden.
374 if (GetOobeUI()) { 384 if (GetOobeUI()) {
375 GetOobeUI()->GetCoreOobeActor()->ShowControlBar(true); 385 GetOobeUI()->GetCoreOobeActor()->ShowControlBar(true);
376 if (login::LoginScrollIntoViewEnabled()) 386 if (login::LoginScrollIntoViewEnabled())
377 GetOobeUI()->GetCoreOobeActor()->SetKeyboardState(false, new_bounds); 387 GetOobeUI()->GetCoreOobeActor()->SetKeyboardState(false, new_bounds);
378 } 388 }
379 } else if (!new_bounds.IsEmpty() && keyboard_bounds_.IsEmpty()) { 389 } else if (!new_bounds.IsEmpty() && keyboard_bounds_.IsEmpty()) {
380 // Keyboard has been shown. 390 // Keyboard has been shown.
381 if (GetOobeUI()) { 391 if (GetOobeUI()) {
382 GetOobeUI()->GetCoreOobeActor()->ShowControlBar(false); 392 GetOobeUI()->GetCoreOobeActor()->ShowControlBar(false);
383 if (login::LoginScrollIntoViewEnabled()) 393 if (login::LoginScrollIntoViewEnabled())
384 GetOobeUI()->GetCoreOobeActor()->SetKeyboardState(true, new_bounds); 394 GetOobeUI()->GetCoreOobeActor()->SetKeyboardState(true, new_bounds);
385 } 395 }
386 } 396 }
387 397
388 keyboard_bounds_ = new_bounds; 398 keyboard_bounds_ = new_bounds;
389 } 399 }
390 400
391 } // namespace chromeos 401 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698