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

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

Issue 444903002: [cros] user_manager component - move UserManagerBase and UserManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 | Annotate | Revision Log
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 12 matching lines...) Expand all
23 #include "base/metrics/histogram.h" 23 #include "base/metrics/histogram.h"
24 #include "base/strings/string_number_conversions.h" 24 #include "base/strings/string_number_conversions.h"
25 #include "base/strings/string_util.h" 25 #include "base/strings/string_util.h"
26 #include "base/timer/timer.h" 26 #include "base/timer/timer.h"
27 #include "chrome/browser/chrome_notification_types.h" 27 #include "chrome/browser/chrome_notification_types.h"
28 #include "chrome/browser/chromeos/login/auth/login_performer.h" 28 #include "chrome/browser/chromeos/login/auth/login_performer.h"
29 #include "chrome/browser/chromeos/login/lock/webui_screen_locker.h" 29 #include "chrome/browser/chromeos/login/lock/webui_screen_locker.h"
30 #include "chrome/browser/chromeos/login/login_utils.h" 30 #include "chrome/browser/chromeos/login/login_utils.h"
31 #include "chrome/browser/chromeos/login/supervised/supervised_user_authenticatio n.h" 31 #include "chrome/browser/chromeos/login/supervised/supervised_user_authenticatio n.h"
32 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" 32 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
33 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
33 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" 34 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
34 #include "chrome/browser/chromeos/login/users/user_manager.h"
35 #include "chrome/browser/lifetime/application_lifetime.h" 35 #include "chrome/browser/lifetime/application_lifetime.h"
36 #include "chrome/browser/signin/signin_manager_factory.h" 36 #include "chrome/browser/signin/signin_manager_factory.h"
37 #include "chrome/browser/ui/webui/chromeos/login/screenlock_icon_provider.h" 37 #include "chrome/browser/ui/webui/chromeos/login/screenlock_icon_provider.h"
38 #include "chrome/browser/ui/webui/chromeos/login/screenlock_icon_source.h" 38 #include "chrome/browser/ui/webui/chromeos/login/screenlock_icon_source.h"
39 #include "chrome/common/chrome_switches.h" 39 #include "chrome/common/chrome_switches.h"
40 #include "chrome/grit/browser_resources.h" 40 #include "chrome/grit/browser_resources.h"
41 #include "chrome/grit/generated_resources.h" 41 #include "chrome/grit/generated_resources.h"
42 #include "chromeos/audio/chromeos_sounds.h" 42 #include "chromeos/audio/chromeos_sounds.h"
43 #include "chromeos/dbus/dbus_thread_manager.h" 43 #include "chromeos/dbus/dbus_thread_manager.h"
44 #include "chromeos/dbus/session_manager_client.h" 44 #include "chromeos/dbus/session_manager_client.h"
45 #include "chromeos/login/auth/authenticator.h" 45 #include "chromeos/login/auth/authenticator.h"
46 #include "chromeos/login/auth/extended_authenticator.h" 46 #include "chromeos/login/auth/extended_authenticator.h"
47 #include "components/signin/core/browser/signin_manager.h" 47 #include "components/signin/core/browser/signin_manager.h"
48 #include "components/user_manager/user_manager.h"
48 #include "components/user_manager/user_type.h" 49 #include "components/user_manager/user_type.h"
49 #include "content/public/browser/browser_thread.h" 50 #include "content/public/browser/browser_thread.h"
50 #include "content/public/browser/notification_service.h" 51 #include "content/public/browser/notification_service.h"
51 #include "content/public/browser/url_data_source.h" 52 #include "content/public/browser/url_data_source.h"
52 #include "content/public/browser/user_metrics.h" 53 #include "content/public/browser/user_metrics.h"
53 #include "content/public/browser/web_contents.h" 54 #include "content/public/browser/web_contents.h"
54 #include "content/public/browser/web_ui.h" 55 #include "content/public/browser/web_ui.h"
55 #include "media/audio/sounds/sounds_manager.h" 56 #include "media/audio/sounds/sounds_manager.h"
56 #include "ui/base/resource/resource_bundle.h" 57 #include "ui/base/resource/resource_bundle.h"
57 #include "ui/gfx/image/image.h" 58 #include "ui/gfx/image/image.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 if (authentication_start_time_.is_null()) { 196 if (authentication_start_time_.is_null()) {
196 if (!user_context.GetUserID().empty()) 197 if (!user_context.GetUserID().empty())
197 LOG(ERROR) << "Start time is not set at authentication success"; 198 LOG(ERROR) << "Start time is not set at authentication success";
198 } else { 199 } else {
199 base::TimeDelta delta = base::Time::Now() - authentication_start_time_; 200 base::TimeDelta delta = base::Time::Now() - authentication_start_time_;
200 VLOG(1) << "Authentication success: " << delta.InSecondsF() << " second(s)"; 201 VLOG(1) << "Authentication success: " << delta.InSecondsF() << " second(s)";
201 UMA_HISTOGRAM_TIMES("ScreenLocker.AuthenticationSuccessTime", delta); 202 UMA_HISTOGRAM_TIMES("ScreenLocker.AuthenticationSuccessTime", delta);
202 } 203 }
203 204
204 const user_manager::User* user = 205 const user_manager::User* user =
205 UserManager::Get()->FindUser(user_context.GetUserID()); 206 user_manager::UserManager::Get()->FindUser(user_context.GetUserID());
206 if (user) { 207 if (user) {
207 if (!user->is_active()) 208 if (!user->is_active())
208 UserManager::Get()->SwitchActiveUser(user_context.GetUserID()); 209 user_manager::UserManager::Get()->SwitchActiveUser(
210 user_context.GetUserID());
209 } else { 211 } else {
210 NOTREACHED() << "Logged in user not found."; 212 NOTREACHED() << "Logged in user not found.";
211 } 213 }
212 214
213 authentication_capture_.reset(new AuthenticationParametersCapture()); 215 authentication_capture_.reset(new AuthenticationParametersCapture());
214 authentication_capture_->user_context = user_context; 216 authentication_capture_->user_context = user_context;
215 217
216 // Add guard for case when something get broken in call chain to unlock 218 // Add guard for case when something get broken in call chain to unlock
217 // for sure. 219 // for sure.
218 base::MessageLoop::current()->PostDelayedTask( 220 base::MessageLoop::current()->PostDelayedTask(
(...skipping 27 matching lines...) Expand all
246 << "Invalid user trying to unlock."; 248 << "Invalid user trying to unlock.";
247 249
248 authentication_start_time_ = base::Time::Now(); 250 authentication_start_time_ = base::Time::Now();
249 delegate_->SetInputEnabled(false); 251 delegate_->SetInputEnabled(false);
250 delegate_->OnAuthenticate(); 252 delegate_->OnAuthenticate();
251 253
252 // Special case: supervised users. Use special authenticator. 254 // Special case: supervised users. Use special authenticator.
253 if (const user_manager::User* user = 255 if (const user_manager::User* user =
254 FindUnlockUser(user_context.GetUserID())) { 256 FindUnlockUser(user_context.GetUserID())) {
255 if (user->GetType() == user_manager::USER_TYPE_SUPERVISED) { 257 if (user->GetType() == user_manager::USER_TYPE_SUPERVISED) {
256 UserContext updated_context = UserManager::Get() 258 UserContext updated_context = ChromeUserManager::Get()
257 ->GetSupervisedUserManager() 259 ->GetSupervisedUserManager()
258 ->GetAuthentication() 260 ->GetAuthentication()
259 ->TransformKey(user_context); 261 ->TransformKey(user_context);
260 // TODO(antrim) : replace empty closure with explicit method. 262 // TODO(antrim) : replace empty closure with explicit method.
261 // http://crbug.com/351268 263 // http://crbug.com/351268
262 BrowserThread::PostTask( 264 BrowserThread::PostTask(
263 BrowserThread::UI, 265 BrowserThread::UI,
264 FROM_HERE, 266 FROM_HERE,
265 base::Bind(&ExtendedAuthenticator::AuthenticateToCheck, 267 base::Bind(&ExtendedAuthenticator::AuthenticateToCheck,
266 extended_authenticator_.get(), 268 extended_authenticator_.get(),
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 void ScreenLocker::HandleLockScreenRequest() { 343 void ScreenLocker::HandleLockScreenRequest() {
342 VLOG(1) << "Received LockScreen request from session manager"; 344 VLOG(1) << "Received LockScreen request from session manager";
343 DCHECK(g_screen_lock_observer); 345 DCHECK(g_screen_lock_observer);
344 if (UserAddingScreen::Get()->IsRunning()) { 346 if (UserAddingScreen::Get()->IsRunning()) {
345 VLOG(1) << "Waiting for user adding screen to stop"; 347 VLOG(1) << "Waiting for user adding screen to stop";
346 UserAddingScreen::Get()->AddObserver(g_screen_lock_observer); 348 UserAddingScreen::Get()->AddObserver(g_screen_lock_observer);
347 UserAddingScreen::Get()->Cancel(); 349 UserAddingScreen::Get()->Cancel();
348 return; 350 return;
349 } 351 }
350 if (g_screen_lock_observer->session_started() && 352 if (g_screen_lock_observer->session_started() &&
351 UserManager::Get()->CanCurrentUserLock()) { 353 user_manager::UserManager::Get()->CanCurrentUserLock()) {
352 ScreenLocker::Show(); 354 ScreenLocker::Show();
353 ash::Shell::GetInstance()->lock_state_controller()->OnStartingLock(); 355 ash::Shell::GetInstance()->lock_state_controller()->OnStartingLock();
354 } else { 356 } else {
355 // If the current user's session cannot be locked or the user has not 357 // If the current user's session cannot be locked or the user has not
356 // completed all sign-in steps yet, log out instead. The latter is done to 358 // completed all sign-in steps yet, log out instead. The latter is done to
357 // avoid complications with displaying the lock screen over the login 359 // avoid complications with displaying the lock screen over the login
358 // screen while remaining secure in the case the user walks away during 360 // screen while remaining secure in the case the user walks away during
359 // the sign-in steps. See crbug.com/112225 and crbug.com/110933. 361 // the sign-in steps. See crbug.com/112225 and crbug.com/110933.
360 VLOG(1) << "Calling session manager's StopSession D-Bus method"; 362 VLOG(1) << "Calling session manager's StopSession D-Bus method";
361 DBusThreadManager::Get()->GetSessionManagerClient()->StopSession(); 363 DBusThreadManager::Get()->GetSessionManagerClient()->StopSession();
362 } 364 }
363 } 365 }
364 366
365 // static 367 // static
366 void ScreenLocker::Show() { 368 void ScreenLocker::Show() {
367 content::RecordAction(UserMetricsAction("ScreenLocker_Show")); 369 content::RecordAction(UserMetricsAction("ScreenLocker_Show"));
368 DCHECK(base::MessageLoopForUI::IsCurrent()); 370 DCHECK(base::MessageLoopForUI::IsCurrent());
369 371
370 // Check whether the currently logged in user is a guest account and if so, 372 // Check whether the currently logged in user is a guest account and if so,
371 // refuse to lock the screen (crosbug.com/23764). 373 // refuse to lock the screen (crosbug.com/23764).
372 // For a demo user, we should never show the lock screen (crosbug.com/27647). 374 // For a demo user, we should never show the lock screen (crosbug.com/27647).
373 if (UserManager::Get()->IsLoggedInAsGuest() || 375 if (user_manager::UserManager::Get()->IsLoggedInAsGuest() ||
374 UserManager::Get()->IsLoggedInAsDemoUser()) { 376 user_manager::UserManager::Get()->IsLoggedInAsDemoUser()) {
375 VLOG(1) << "Refusing to lock screen for guest/demo account"; 377 VLOG(1) << "Refusing to lock screen for guest/demo account";
376 return; 378 return;
377 } 379 }
378 380
379 // If the active window is fullscreen, exit fullscreen to avoid the web page 381 // If the active window is fullscreen, exit fullscreen to avoid the web page
380 // or app mimicking the lock screen. Do not exit fullscreen if the shelf is 382 // or app mimicking the lock screen. Do not exit fullscreen if the shelf is
381 // visible while in fullscreen because the shelf makes it harder for a web 383 // visible while in fullscreen because the shelf makes it harder for a web
382 // page or app to mimick the lock screen. 384 // page or app to mimick the lock screen.
383 ash::wm::WindowState* active_window_state = ash::wm::GetActiveWindowState(); 385 ash::wm::WindowState* active_window_state = ash::wm::GetActiveWindowState();
384 if (active_window_state && 386 if (active_window_state &&
385 active_window_state->IsFullscreen() && 387 active_window_state->IsFullscreen() &&
386 active_window_state->hide_shelf_when_fullscreen()) { 388 active_window_state->hide_shelf_when_fullscreen()) {
387 const ash::wm::WMEvent event(ash::wm::WM_EVENT_TOGGLE_FULLSCREEN); 389 const ash::wm::WMEvent event(ash::wm::WM_EVENT_TOGGLE_FULLSCREEN);
388 active_window_state->OnWMEvent(&event); 390 active_window_state->OnWMEvent(&event);
389 } 391 }
390 392
391 if (!screen_locker_) { 393 if (!screen_locker_) {
392 ScreenLocker* locker = 394 ScreenLocker* locker =
393 new ScreenLocker(UserManager::Get()->GetUnlockUsers()); 395 new ScreenLocker(user_manager::UserManager::Get()->GetUnlockUsers());
394 VLOG(1) << "Created ScreenLocker " << locker; 396 VLOG(1) << "Created ScreenLocker " << locker;
395 locker->Init(); 397 locker->Init();
396 } else { 398 } else {
397 VLOG(1) << "ScreenLocker " << screen_locker_ << " already exists; " 399 VLOG(1) << "ScreenLocker " << screen_locker_ << " already exists; "
398 << " calling session manager's HandleLockScreenShown D-Bus method"; 400 << " calling session manager's HandleLockScreenShown D-Bus method";
399 DBusThreadManager::Get()->GetSessionManagerClient()-> 401 DBusThreadManager::Get()->GetSessionManagerClient()->
400 NotifyLockScreenShown(); 402 NotifyLockScreenShown();
401 } 403 }
402 } 404 }
403 405
404 // static 406 // static
405 void ScreenLocker::Hide() { 407 void ScreenLocker::Hide() {
406 DCHECK(base::MessageLoopForUI::IsCurrent()); 408 DCHECK(base::MessageLoopForUI::IsCurrent());
407 // For a guest/demo user, screen_locker_ would have never been initialized. 409 // For a guest/demo user, screen_locker_ would have never been initialized.
408 if (UserManager::Get()->IsLoggedInAsGuest() || 410 if (user_manager::UserManager::Get()->IsLoggedInAsGuest() ||
409 UserManager::Get()->IsLoggedInAsDemoUser()) { 411 user_manager::UserManager::Get()->IsLoggedInAsDemoUser()) {
410 VLOG(1) << "Refusing to hide lock screen for guest/demo account"; 412 VLOG(1) << "Refusing to hide lock screen for guest/demo account";
411 return; 413 return;
412 } 414 }
413 415
414 DCHECK(screen_locker_); 416 DCHECK(screen_locker_);
415 base::Callback<void(void)> callback = 417 base::Callback<void(void)> callback =
416 base::Bind(&ScreenLocker::ScheduleDeletion); 418 base::Bind(&ScreenLocker::ScheduleDeletion);
417 ash::Shell::GetInstance()->lock_state_controller()-> 419 ash::Shell::GetInstance()->lock_state_controller()->
418 OnLockScreenHide(callback); 420 OnLockScreenHide(callback);
419 } 421 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 for (user_manager::UserList::const_iterator it = users_.begin(); 493 for (user_manager::UserList::const_iterator it = users_.begin();
492 it != users_.end(); 494 it != users_.end();
493 ++it) { 495 ++it) {
494 if ((*it)->email() == username) 496 if ((*it)->email() == username)
495 return true; 497 return true;
496 } 498 }
497 return false; 499 return false;
498 } 500 }
499 501
500 } // namespace chromeos 502 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/kiosk_browsertest.cc ('k') | chrome/browser/chromeos/login/lock/webui_screen_locker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698