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/screen_locker.h" | 5 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 DCHECK(g_screen_lock_observer); | 357 DCHECK(g_screen_lock_observer); |
358 if (UserAddingScreen::Get()->IsRunning()) { | 358 if (UserAddingScreen::Get()->IsRunning()) { |
359 VLOG(1) << "Waiting for user adding screen to stop"; | 359 VLOG(1) << "Waiting for user adding screen to stop"; |
360 UserAddingScreen::Get()->AddObserver(g_screen_lock_observer); | 360 UserAddingScreen::Get()->AddObserver(g_screen_lock_observer); |
361 UserAddingScreen::Get()->Cancel(); | 361 UserAddingScreen::Get()->Cancel(); |
362 return; | 362 return; |
363 } | 363 } |
364 if (g_screen_lock_observer->session_started() && | 364 if (g_screen_lock_observer->session_started() && |
365 user_manager::UserManager::Get()->CanCurrentUserLock()) { | 365 user_manager::UserManager::Get()->CanCurrentUserLock()) { |
366 ScreenLocker::Show(); | 366 ScreenLocker::Show(); |
| 367 #if !defined(USE_ATHENA) |
| 368 // TOOD(dpolukhin): crbug.com/413926. |
367 ash::Shell::GetInstance()->lock_state_controller()->OnStartingLock(); | 369 ash::Shell::GetInstance()->lock_state_controller()->OnStartingLock(); |
| 370 #endif |
368 } else { | 371 } else { |
369 // If the current user's session cannot be locked or the user has not | 372 // If the current user's session cannot be locked or the user has not |
370 // completed all sign-in steps yet, log out instead. The latter is done to | 373 // completed all sign-in steps yet, log out instead. The latter is done to |
371 // avoid complications with displaying the lock screen over the login | 374 // avoid complications with displaying the lock screen over the login |
372 // screen while remaining secure in the case the user walks away during | 375 // screen while remaining secure in the case the user walks away during |
373 // the sign-in steps. See crbug.com/112225 and crbug.com/110933. | 376 // the sign-in steps. See crbug.com/112225 and crbug.com/110933. |
374 VLOG(1) << "Calling session manager's StopSession D-Bus method"; | 377 VLOG(1) << "Calling session manager's StopSession D-Bus method"; |
375 DBusThreadManager::Get()->GetSessionManagerClient()->StopSession(); | 378 DBusThreadManager::Get()->GetSessionManagerClient()->StopSession(); |
376 } | 379 } |
377 } | 380 } |
378 | 381 |
379 // static | 382 // static |
380 void ScreenLocker::Show() { | 383 void ScreenLocker::Show() { |
381 #if defined(USE_ATHENA) | |
382 // crbug.com/413926 | |
383 return; | |
384 #endif | |
385 | |
386 content::RecordAction(UserMetricsAction("ScreenLocker_Show")); | 384 content::RecordAction(UserMetricsAction("ScreenLocker_Show")); |
387 DCHECK(base::MessageLoopForUI::IsCurrent()); | 385 DCHECK(base::MessageLoopForUI::IsCurrent()); |
388 | 386 |
389 // Check whether the currently logged in user is a guest account and if so, | 387 // Check whether the currently logged in user is a guest account and if so, |
390 // refuse to lock the screen (crosbug.com/23764). | 388 // refuse to lock the screen (crosbug.com/23764). |
391 // For a demo user, we should never show the lock screen (crosbug.com/27647). | 389 // For a demo user, we should never show the lock screen (crosbug.com/27647). |
392 if (user_manager::UserManager::Get()->IsLoggedInAsGuest() || | 390 if (user_manager::UserManager::Get()->IsLoggedInAsGuest() || |
393 user_manager::UserManager::Get()->IsLoggedInAsDemoUser()) { | 391 user_manager::UserManager::Get()->IsLoggedInAsDemoUser()) { |
394 VLOG(1) << "Refusing to lock screen for guest/demo account"; | 392 VLOG(1) << "Refusing to lock screen for guest/demo account"; |
395 return; | 393 return; |
396 } | 394 } |
397 | 395 |
| 396 #if !defined(USE_ATHENA) |
398 // If the active window is fullscreen, exit fullscreen to avoid the web page | 397 // If the active window is fullscreen, exit fullscreen to avoid the web page |
399 // or app mimicking the lock screen. Do not exit fullscreen if the shelf is | 398 // or app mimicking the lock screen. Do not exit fullscreen if the shelf is |
400 // visible while in fullscreen because the shelf makes it harder for a web | 399 // visible while in fullscreen because the shelf makes it harder for a web |
401 // page or app to mimick the lock screen. | 400 // page or app to mimick the lock screen. |
402 ash::wm::WindowState* active_window_state = ash::wm::GetActiveWindowState(); | 401 ash::wm::WindowState* active_window_state = ash::wm::GetActiveWindowState(); |
403 if (active_window_state && | 402 if (active_window_state && |
404 active_window_state->IsFullscreen() && | 403 active_window_state->IsFullscreen() && |
405 active_window_state->hide_shelf_when_fullscreen()) { | 404 active_window_state->hide_shelf_when_fullscreen()) { |
406 const ash::wm::WMEvent event(ash::wm::WM_EVENT_TOGGLE_FULLSCREEN); | 405 const ash::wm::WMEvent event(ash::wm::WM_EVENT_TOGGLE_FULLSCREEN); |
407 active_window_state->OnWMEvent(&event); | 406 active_window_state->OnWMEvent(&event); |
408 } | 407 } |
| 408 #endif |
409 | 409 |
410 if (!screen_locker_) { | 410 if (!screen_locker_) { |
411 ScreenLocker* locker = | 411 ScreenLocker* locker = |
412 new ScreenLocker(user_manager::UserManager::Get()->GetUnlockUsers()); | 412 new ScreenLocker(user_manager::UserManager::Get()->GetUnlockUsers()); |
413 VLOG(1) << "Created ScreenLocker " << locker; | 413 VLOG(1) << "Created ScreenLocker " << locker; |
414 locker->Init(); | 414 locker->Init(); |
415 } else { | 415 } else { |
416 VLOG(1) << "ScreenLocker " << screen_locker_ << " already exists; " | 416 VLOG(1) << "ScreenLocker " << screen_locker_ << " already exists; " |
417 << " calling session manager's HandleLockScreenShown D-Bus method"; | 417 << " calling session manager's HandleLockScreenShown D-Bus method"; |
418 DBusThreadManager::Get()->GetSessionManagerClient()-> | 418 DBusThreadManager::Get()->GetSessionManagerClient()-> |
419 NotifyLockScreenShown(); | 419 NotifyLockScreenShown(); |
420 } | 420 } |
421 } | 421 } |
422 | 422 |
423 // static | 423 // static |
424 void ScreenLocker::Hide() { | 424 void ScreenLocker::Hide() { |
425 #if defined(USE_ATHENA) | |
426 // crbug.com/413926 | |
427 return; | |
428 #endif | |
429 | |
430 DCHECK(base::MessageLoopForUI::IsCurrent()); | 425 DCHECK(base::MessageLoopForUI::IsCurrent()); |
431 // For a guest/demo user, screen_locker_ would have never been initialized. | 426 // For a guest/demo user, screen_locker_ would have never been initialized. |
432 if (user_manager::UserManager::Get()->IsLoggedInAsGuest() || | 427 if (user_manager::UserManager::Get()->IsLoggedInAsGuest() || |
433 user_manager::UserManager::Get()->IsLoggedInAsDemoUser()) { | 428 user_manager::UserManager::Get()->IsLoggedInAsDemoUser()) { |
434 VLOG(1) << "Refusing to hide lock screen for guest/demo account"; | 429 VLOG(1) << "Refusing to hide lock screen for guest/demo account"; |
435 return; | 430 return; |
436 } | 431 } |
437 | 432 |
438 DCHECK(screen_locker_); | 433 DCHECK(screen_locker_); |
439 base::Callback<void(void)> callback = | 434 base::Callback<void(void)> callback = |
440 base::Bind(&ScreenLocker::ScheduleDeletion); | 435 base::Bind(&ScreenLocker::ScheduleDeletion); |
| 436 #if !defined(USE_ATHENA) |
441 ash::Shell::GetInstance()->lock_state_controller()-> | 437 ash::Shell::GetInstance()->lock_state_controller()-> |
442 OnLockScreenHide(callback); | 438 OnLockScreenHide(callback); |
| 439 #else |
| 440 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); |
| 441 #endif |
443 } | 442 } |
444 | 443 |
445 void ScreenLocker::ScheduleDeletion() { | 444 void ScreenLocker::ScheduleDeletion() { |
446 // Avoid possible multiple calls. | 445 // Avoid possible multiple calls. |
447 if (screen_locker_ == NULL) | 446 if (screen_locker_ == NULL) |
448 return; | 447 return; |
449 VLOG(1) << "Deleting ScreenLocker " << screen_locker_; | 448 VLOG(1) << "Deleting ScreenLocker " << screen_locker_; |
450 | 449 |
| 450 #if !defined(USE_ATHENA) |
451 ash::PlaySystemSoundIfSpokenFeedback(SOUND_UNLOCK); | 451 ash::PlaySystemSoundIfSpokenFeedback(SOUND_UNLOCK); |
| 452 #endif |
452 | 453 |
453 delete screen_locker_; | 454 delete screen_locker_; |
454 screen_locker_ = NULL; | 455 screen_locker_ = NULL; |
455 } | 456 } |
456 | 457 |
457 //////////////////////////////////////////////////////////////////////////////// | 458 //////////////////////////////////////////////////////////////////////////////// |
458 // ScreenLocker, private: | 459 // ScreenLocker, private: |
459 | 460 |
460 ScreenLocker::~ScreenLocker() { | 461 ScreenLocker::~ScreenLocker() { |
461 VLOG(1) << "Destroying ScreenLocker " << this; | 462 VLOG(1) << "Destroying ScreenLocker " << this; |
462 DCHECK(base::MessageLoopForUI::IsCurrent()); | 463 DCHECK(base::MessageLoopForUI::IsCurrent()); |
463 | 464 |
464 if (authenticator_.get()) | 465 if (authenticator_.get()) |
465 authenticator_->SetConsumer(NULL); | 466 authenticator_->SetConsumer(NULL); |
466 ClearErrors(); | 467 ClearErrors(); |
467 | 468 |
| 469 #if !defined(USE_ATHENA) |
| 470 // TOOD(dpolukhin): we need to to something similar for Athena. |
468 VLOG(1) << "Moving desktop background to unlocked container"; | 471 VLOG(1) << "Moving desktop background to unlocked container"; |
469 ash::Shell::GetInstance()-> | 472 ash::Shell::GetInstance()-> |
470 desktop_background_controller()->MoveDesktopToUnlockedContainer(); | 473 desktop_background_controller()->MoveDesktopToUnlockedContainer(); |
| 474 #endif |
471 | 475 |
472 screen_locker_ = NULL; | 476 screen_locker_ = NULL; |
473 bool state = false; | 477 bool state = false; |
474 VLOG(1) << "Emitting SCREEN_LOCK_STATE_CHANGED with state=" << state; | 478 VLOG(1) << "Emitting SCREEN_LOCK_STATE_CHANGED with state=" << state; |
475 content::NotificationService::current()->Notify( | 479 content::NotificationService::current()->Notify( |
476 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, | 480 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, |
477 content::Source<ScreenLocker>(this), | 481 content::Source<ScreenLocker>(this), |
478 content::Details<bool>(&state)); | 482 content::Details<bool>(&state)); |
479 | 483 |
480 VLOG(1) << "Calling session manager's HandleLockScreenDismissed D-Bus method"; | 484 VLOG(1) << "Calling session manager's HandleLockScreenDismissed D-Bus method"; |
(...skipping 10 matching lines...) Expand all Loading... |
491 } | 495 } |
492 | 496 |
493 void ScreenLocker::ScreenLockReady() { | 497 void ScreenLocker::ScreenLockReady() { |
494 locked_ = true; | 498 locked_ = true; |
495 base::TimeDelta delta = base::Time::Now() - start_time_; | 499 base::TimeDelta delta = base::Time::Now() - start_time_; |
496 VLOG(1) << "ScreenLocker " << this << " is ready after " | 500 VLOG(1) << "ScreenLocker " << this << " is ready after " |
497 << delta.InSecondsF() << " second(s)"; | 501 << delta.InSecondsF() << " second(s)"; |
498 UMA_HISTOGRAM_TIMES("ScreenLocker.ScreenLockTime", delta); | 502 UMA_HISTOGRAM_TIMES("ScreenLocker.ScreenLockTime", delta); |
499 | 503 |
500 VLOG(1) << "Moving desktop background to locked container"; | 504 VLOG(1) << "Moving desktop background to locked container"; |
| 505 #if !defined(USE_ATHENA) |
501 ash::Shell::GetInstance()-> | 506 ash::Shell::GetInstance()-> |
502 desktop_background_controller()->MoveDesktopToLockedContainer(); | 507 desktop_background_controller()->MoveDesktopToLockedContainer(); |
| 508 #endif |
503 | 509 |
504 input_method::InputMethodManager::Get() | 510 input_method::InputMethodManager::Get() |
505 ->GetActiveIMEState() | 511 ->GetActiveIMEState() |
506 ->EnableLockScreenLayouts(); | 512 ->EnableLockScreenLayouts(); |
507 | 513 |
508 bool state = true; | 514 bool state = true; |
509 VLOG(1) << "Emitting SCREEN_LOCK_STATE_CHANGED with state=" << state; | 515 VLOG(1) << "Emitting SCREEN_LOCK_STATE_CHANGED with state=" << state; |
510 content::NotificationService::current()->Notify( | 516 content::NotificationService::current()->Notify( |
511 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, | 517 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, |
512 content::Source<ScreenLocker>(this), | 518 content::Source<ScreenLocker>(this), |
(...skipping 10 matching lines...) Expand all Loading... |
523 for (user_manager::UserList::const_iterator it = users_.begin(); | 529 for (user_manager::UserList::const_iterator it = users_.begin(); |
524 it != users_.end(); | 530 it != users_.end(); |
525 ++it) { | 531 ++it) { |
526 if ((*it)->email() == username) | 532 if ((*it)->email() == username) |
527 return true; | 533 return true; |
528 } | 534 } |
529 return false; | 535 return false; |
530 } | 536 } |
531 | 537 |
532 } // namespace chromeos | 538 } // namespace chromeos |
OLD | NEW |