OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/screen_locker.h" | 5 #include "chrome/browser/chromeos/login/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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 authentication_capture_->username = user_context.username; | 215 authentication_capture_->username = user_context.username; |
216 authentication_capture_->pending_requests = pending_requests; | 216 authentication_capture_->pending_requests = pending_requests; |
217 authentication_capture_->using_oauth = using_oauth; | 217 authentication_capture_->using_oauth = using_oauth; |
218 | 218 |
219 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 219 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
220 if (command_line->HasSwitch(ash::switches::kAshDisableNewLockAnimations)) { | 220 if (command_line->HasSwitch(ash::switches::kAshDisableNewLockAnimations)) { |
221 UnlockOnLoginSuccess(); | 221 UnlockOnLoginSuccess(); |
222 } else { | 222 } else { |
223 // Add guard for case when something get broken in call chain to unlock | 223 // Add guard for case when something get broken in call chain to unlock |
224 // for sure. | 224 // for sure. |
225 MessageLoop::current()->PostDelayedTask( | 225 base::MessageLoop::current()->PostDelayedTask( |
226 FROM_HERE, | 226 FROM_HERE, |
227 base::Bind(&ScreenLocker::UnlockOnLoginSuccess, | 227 base::Bind(&ScreenLocker::UnlockOnLoginSuccess, |
228 weak_factory_.GetWeakPtr()), | 228 weak_factory_.GetWeakPtr()), |
229 base::TimeDelta::FromMilliseconds(kUnlockGuardTimeoutMs)); | 229 base::TimeDelta::FromMilliseconds(kUnlockGuardTimeoutMs)); |
230 delegate_->AnimateAuthenticationSuccess(); | 230 delegate_->AnimateAuthenticationSuccess(); |
231 } | 231 } |
232 } | 232 } |
233 | 233 |
234 void ScreenLocker::UnlockOnLoginSuccess() { | 234 void ScreenLocker::UnlockOnLoginSuccess() { |
235 DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI); | 235 DCHECK(base::MessageLoop::current()->type() == base::MessageLoop::TYPE_UI); |
236 if (!authentication_capture_.get()) { | 236 if (!authentication_capture_.get()) { |
237 LOG(WARNING) << "Call to UnlockOnLoginSuccess without previous " << | 237 LOG(WARNING) << "Call to UnlockOnLoginSuccess without previous " << |
238 "authentication success."; | 238 "authentication success."; |
239 return; | 239 return; |
240 } | 240 } |
241 | 241 |
242 VLOG(1) << "Calling session manager's UnlockScreen D-Bus method"; | 242 VLOG(1) << "Calling session manager's UnlockScreen D-Bus method"; |
243 DBusThreadManager::Get()->GetSessionManagerClient()->RequestUnlockScreen(); | 243 DBusThreadManager::Get()->GetSessionManagerClient()->RequestUnlockScreen(); |
244 | 244 |
245 if (login_status_consumer_) { | 245 if (login_status_consumer_) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 } | 305 } |
306 | 306 |
307 void ScreenLocker::SetLoginStatusConsumer( | 307 void ScreenLocker::SetLoginStatusConsumer( |
308 chromeos::LoginStatusConsumer* consumer) { | 308 chromeos::LoginStatusConsumer* consumer) { |
309 login_status_consumer_ = consumer; | 309 login_status_consumer_ = consumer; |
310 } | 310 } |
311 | 311 |
312 // static | 312 // static |
313 void ScreenLocker::Show() { | 313 void ScreenLocker::Show() { |
314 content::RecordAction(UserMetricsAction("ScreenLocker_Show")); | 314 content::RecordAction(UserMetricsAction("ScreenLocker_Show")); |
315 DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI); | 315 DCHECK(base::MessageLoop::current()->type() == base::MessageLoop::TYPE_UI); |
316 | 316 |
317 // Check whether the currently logged in user is a guest account and if so, | 317 // Check whether the currently logged in user is a guest account and if so, |
318 // refuse to lock the screen (crosbug.com/23764). | 318 // refuse to lock the screen (crosbug.com/23764). |
319 // For a demo user, we should never show the lock screen (crosbug.com/27647). | 319 // For a demo user, we should never show the lock screen (crosbug.com/27647). |
320 // TODO(flackr): We can allow lock screen for guest accounts when | 320 // TODO(flackr): We can allow lock screen for guest accounts when |
321 // unlock_on_input is supported by the WebUI screen locker. | 321 // unlock_on_input is supported by the WebUI screen locker. |
322 if (UserManager::Get()->IsLoggedInAsGuest() || | 322 if (UserManager::Get()->IsLoggedInAsGuest() || |
323 UserManager::Get()->IsLoggedInAsDemoUser()) { | 323 UserManager::Get()->IsLoggedInAsDemoUser()) { |
324 VLOG(1) << "Refusing to lock screen for guest/demo account"; | 324 VLOG(1) << "Refusing to lock screen for guest/demo account"; |
325 return; | 325 return; |
(...skipping 16 matching lines...) Expand all Loading... |
342 } else { | 342 } else { |
343 VLOG(1) << "ScreenLocker " << screen_locker_ << " already exists; " | 343 VLOG(1) << "ScreenLocker " << screen_locker_ << " already exists; " |
344 << " calling session manager's HandleLockScreenShown D-Bus method"; | 344 << " calling session manager's HandleLockScreenShown D-Bus method"; |
345 DBusThreadManager::Get()->GetSessionManagerClient()-> | 345 DBusThreadManager::Get()->GetSessionManagerClient()-> |
346 NotifyLockScreenShown(); | 346 NotifyLockScreenShown(); |
347 } | 347 } |
348 } | 348 } |
349 | 349 |
350 // static | 350 // static |
351 void ScreenLocker::Hide() { | 351 void ScreenLocker::Hide() { |
352 DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI); | 352 DCHECK(base::MessageLoop::current()->type() == base::MessageLoop::TYPE_UI); |
353 // For a guest/demo user, screen_locker_ would have never been initialized. | 353 // For a guest/demo user, screen_locker_ would have never been initialized. |
354 if (UserManager::Get()->IsLoggedInAsGuest() || | 354 if (UserManager::Get()->IsLoggedInAsGuest() || |
355 UserManager::Get()->IsLoggedInAsDemoUser()) { | 355 UserManager::Get()->IsLoggedInAsDemoUser()) { |
356 VLOG(1) << "Refusing to hide lock screen for guest/demo account"; | 356 VLOG(1) << "Refusing to hide lock screen for guest/demo account"; |
357 return; | 357 return; |
358 } | 358 } |
359 | 359 |
360 DCHECK(screen_locker_); | 360 DCHECK(screen_locker_); |
361 base::Callback<void(void)> callback = | 361 base::Callback<void(void)> callback = |
362 base::Bind(&ScreenLocker::ScheduleDeletion); | 362 base::Bind(&ScreenLocker::ScheduleDeletion); |
363 ash::Shell::GetInstance()->session_state_controller()-> | 363 ash::Shell::GetInstance()->session_state_controller()-> |
364 OnLockScreenHide(callback); | 364 OnLockScreenHide(callback); |
365 } | 365 } |
366 | 366 |
367 void ScreenLocker::ScheduleDeletion() { | 367 void ScreenLocker::ScheduleDeletion() { |
368 // Avoid possible multiple calls. | 368 // Avoid possible multiple calls. |
369 if (screen_locker_ == NULL) | 369 if (screen_locker_ == NULL) |
370 return; | 370 return; |
371 VLOG(1) << "Posting task to delete ScreenLocker " << screen_locker_; | 371 VLOG(1) << "Posting task to delete ScreenLocker " << screen_locker_; |
372 ScreenLocker* screen_locker = screen_locker_; | 372 ScreenLocker* screen_locker = screen_locker_; |
373 screen_locker_ = NULL; | 373 screen_locker_ = NULL; |
374 MessageLoopForUI::current()->DeleteSoon(FROM_HERE, screen_locker); | 374 base::MessageLoopForUI::current()->DeleteSoon(FROM_HERE, screen_locker); |
375 } | 375 } |
376 | 376 |
377 // static | 377 // static |
378 void ScreenLocker::InitClass() { | 378 void ScreenLocker::InitClass() { |
379 g_screen_lock_observer.Get(); | 379 g_screen_lock_observer.Get(); |
380 } | 380 } |
381 | 381 |
382 //////////////////////////////////////////////////////////////////////////////// | 382 //////////////////////////////////////////////////////////////////////////////// |
383 // ScreenLocker, private: | 383 // ScreenLocker, private: |
384 | 384 |
385 ScreenLocker::~ScreenLocker() { | 385 ScreenLocker::~ScreenLocker() { |
386 VLOG(1) << "Destroying ScreenLocker " << this; | 386 VLOG(1) << "Destroying ScreenLocker " << this; |
387 DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI); | 387 DCHECK(base::MessageLoop::current()->type() == base::MessageLoop::TYPE_UI); |
388 | 388 |
389 if (authenticator_) | 389 if (authenticator_) |
390 authenticator_->SetConsumer(NULL); | 390 authenticator_->SetConsumer(NULL); |
391 ClearErrors(); | 391 ClearErrors(); |
392 | 392 |
393 VLOG(1) << "Moving desktop background to unlocked container"; | 393 VLOG(1) << "Moving desktop background to unlocked container"; |
394 ash::Shell::GetInstance()-> | 394 ash::Shell::GetInstance()-> |
395 desktop_background_controller()->MoveDesktopToUnlockedContainer(); | 395 desktop_background_controller()->MoveDesktopToUnlockedContainer(); |
396 | 396 |
397 screen_locker_ = NULL; | 397 screen_locker_ = NULL; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 content::Details<bool>(&state)); | 429 content::Details<bool>(&state)); |
430 VLOG(1) << "Calling session manager's HandleLockScreenShown D-Bus method"; | 430 VLOG(1) << "Calling session manager's HandleLockScreenShown D-Bus method"; |
431 DBusThreadManager::Get()->GetSessionManagerClient()->NotifyLockScreenShown(); | 431 DBusThreadManager::Get()->GetSessionManagerClient()->NotifyLockScreenShown(); |
432 } | 432 } |
433 | 433 |
434 content::WebUI* ScreenLocker::GetAssociatedWebUI() { | 434 content::WebUI* ScreenLocker::GetAssociatedWebUI() { |
435 return delegate_->GetAssociatedWebUI(); | 435 return delegate_->GetAssociatedWebUI(); |
436 } | 436 } |
437 | 437 |
438 } // namespace chromeos | 438 } // namespace chromeos |
OLD | NEW |