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

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

Powered by Google App Engine
This is Rietveld 408576698