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

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

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

Powered by Google App Engine
This is Rietveld 408576698