| 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" |
| 11 #include "ash/desktop_background/desktop_background_controller.h" | 11 #include "ash/desktop_background/desktop_background_controller.h" |
| 12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 13 #include "ash/wm/session_state_controller.h" | 13 #include "ash/wm/session_state_controller.h" |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/message_loop.h" | 18 #include "base/message_loop.h" |
| 19 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
| 20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
| 21 #include "base/timer.h" | 21 #include "base/timer.h" |
| 22 #include "base/utf_string_conversions.h" | 22 #include "base/utf_string_conversions.h" |
| 23 #include "chrome/browser/chromeos/login/authenticator.h" | 23 #include "chrome/browser/chromeos/login/authenticator.h" |
| 24 #include "chrome/browser/chromeos/login/login_performer.h" | 24 #include "chrome/browser/chromeos/login/login_performer.h" |
| 25 #include "chrome/browser/chromeos/login/login_utils.h" | 25 #include "chrome/browser/chromeos/login/login_utils.h" |
| 26 #include "chrome/browser/chromeos/login/user_adding_screen.h" |
| 26 #include "chrome/browser/chromeos/login/user_manager.h" | 27 #include "chrome/browser/chromeos/login/user_manager.h" |
| 27 #include "chrome/browser/chromeos/login/webui_screen_locker.h" | 28 #include "chrome/browser/chromeos/login/webui_screen_locker.h" |
| 28 #include "chrome/browser/lifetime/application_lifetime.h" | 29 #include "chrome/browser/lifetime/application_lifetime.h" |
| 29 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
| 30 #include "chrome/browser/profiles/profile_manager.h" | 31 #include "chrome/browser/profiles/profile_manager.h" |
| 31 #include "chrome/browser/signin/signin_manager.h" | 32 #include "chrome/browser/signin/signin_manager.h" |
| 32 #include "chrome/browser/signin/signin_manager_factory.h" | 33 #include "chrome/browser/signin/signin_manager_factory.h" |
| 33 #include "chrome/browser/sync/profile_sync_service.h" | 34 #include "chrome/browser/sync/profile_sync_service.h" |
| 34 #include "chrome/browser/sync/profile_sync_service_factory.h" | 35 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 35 #include "chrome/browser/ui/browser.h" | 36 #include "chrome/browser/ui/browser.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 52 | 53 |
| 53 namespace { | 54 namespace { |
| 54 | 55 |
| 55 // Timeout for unlock animation guard - some animations may be required to run | 56 // Timeout for unlock animation guard - some animations may be required to run |
| 56 // on successful authentication before unlocking, but we want to be sure that | 57 // on successful authentication before unlocking, but we want to be sure that |
| 57 // unlock happens even if animations are broken. | 58 // unlock happens even if animations are broken. |
| 58 const int kUnlockGuardTimeoutMs = 400; | 59 const int kUnlockGuardTimeoutMs = 400; |
| 59 | 60 |
| 60 // Observer to start ScreenLocker when the screen lock | 61 // Observer to start ScreenLocker when the screen lock |
| 61 class ScreenLockObserver : public chromeos::SessionManagerClient::Observer, | 62 class ScreenLockObserver : public chromeos::SessionManagerClient::Observer, |
| 62 public content::NotificationObserver { | 63 public content::NotificationObserver, |
| 64 public chromeos::UserAddingScreen::Observer { |
| 63 public: | 65 public: |
| 64 ScreenLockObserver() : session_started_(false) { | 66 ScreenLockObserver() : session_started_(false) { |
| 65 registrar_.Add(this, | 67 registrar_.Add(this, |
| 66 chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 68 chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
| 67 content::NotificationService::AllSources()); | 69 content::NotificationService::AllSources()); |
| 68 registrar_.Add(this, | 70 registrar_.Add(this, |
| 69 chrome::NOTIFICATION_SESSION_STARTED, | 71 chrome::NOTIFICATION_SESSION_STARTED, |
| 70 content::NotificationService::AllSources()); | 72 content::NotificationService::AllSources()); |
| 71 } | 73 } |
| 72 | 74 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 89 break; | 91 break; |
| 90 } | 92 } |
| 91 | 93 |
| 92 default: | 94 default: |
| 93 NOTREACHED(); | 95 NOTREACHED(); |
| 94 } | 96 } |
| 95 } | 97 } |
| 96 | 98 |
| 97 virtual void LockScreen() OVERRIDE { | 99 virtual void LockScreen() OVERRIDE { |
| 98 VLOG(1) << "Received LockScreen D-Bus signal from session manager"; | 100 VLOG(1) << "Received LockScreen D-Bus signal from session manager"; |
| 101 if (chromeos::UserAddingScreen::Get()->IsRunning()) { |
| 102 VLOG(1) << "Waiting for user adding screen to stop"; |
| 103 chromeos::UserAddingScreen::Get()->AddObserver(this); |
| 104 chromeos::UserAddingScreen::Get()->Cancel(); |
| 105 } |
| 99 if (session_started_ && | 106 if (session_started_ && |
| 100 chromeos::UserManager::Get()->CanCurrentUserLock()) { | 107 chromeos::UserManager::Get()->CanCurrentUserLock()) { |
| 101 chromeos::ScreenLocker::Show(); | 108 chromeos::ScreenLocker::Show(); |
| 102 } else { | 109 } else { |
| 103 // If the current user's session cannot be locked or the user has not | 110 // If the current user's session cannot be locked or the user has not |
| 104 // completed all sign-in steps yet, log out instead. The latter is done to | 111 // completed all sign-in steps yet, log out instead. The latter is done to |
| 105 // avoid complications with displaying the lock screen over the login | 112 // avoid complications with displaying the lock screen over the login |
| 106 // screen while remaining secure in the case the user walks away during | 113 // screen while remaining secure in the case the user walks away during |
| 107 // the sign-in steps. See crbug.com/112225 and crbug.com/110933. | 114 // the sign-in steps. See crbug.com/112225 and crbug.com/110933. |
| 108 VLOG(1) << "Calling session manager's StopSession D-Bus method"; | 115 VLOG(1) << "Calling session manager's StopSession D-Bus method"; |
| 109 chromeos::DBusThreadManager::Get()-> | 116 chromeos::DBusThreadManager::Get()-> |
| 110 GetSessionManagerClient()->StopSession(); | 117 GetSessionManagerClient()->StopSession(); |
| 111 } | 118 } |
| 112 } | 119 } |
| 113 | 120 |
| 114 virtual void UnlockScreen() OVERRIDE { | 121 virtual void UnlockScreen() OVERRIDE { |
| 115 VLOG(1) << "Received UnlockScreen D-Bus signal from session manager"; | 122 VLOG(1) << "Received UnlockScreen D-Bus signal from session manager"; |
| 116 chromeos::ScreenLocker::Hide(); | 123 chromeos::ScreenLocker::Hide(); |
| 117 } | 124 } |
| 118 | 125 |
| 126 virtual void OnUserAddingFinished() OVERRIDE { |
| 127 chromeos::UserAddingScreen::Get()->RemoveObserver(this); |
| 128 LockScreen(); |
| 129 } |
| 130 |
| 119 private: | 131 private: |
| 120 bool session_started_; | 132 bool session_started_; |
| 121 content::NotificationRegistrar registrar_; | 133 content::NotificationRegistrar registrar_; |
| 122 std::string saved_previous_input_method_id_; | 134 std::string saved_previous_input_method_id_; |
| 123 std::string saved_current_input_method_id_; | 135 std::string saved_current_input_method_id_; |
| 124 std::vector<std::string> saved_active_input_method_list_; | 136 std::vector<std::string> saved_active_input_method_list_; |
| 125 | 137 |
| 126 DISALLOW_COPY_AND_ASSIGN(ScreenLockObserver); | 138 DISALLOW_COPY_AND_ASSIGN(ScreenLockObserver); |
| 127 }; | 139 }; |
| 128 | 140 |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 content::Details<bool>(&state)); | 441 content::Details<bool>(&state)); |
| 430 VLOG(1) << "Calling session manager's HandleLockScreenShown D-Bus method"; | 442 VLOG(1) << "Calling session manager's HandleLockScreenShown D-Bus method"; |
| 431 DBusThreadManager::Get()->GetSessionManagerClient()->NotifyLockScreenShown(); | 443 DBusThreadManager::Get()->GetSessionManagerClient()->NotifyLockScreenShown(); |
| 432 } | 444 } |
| 433 | 445 |
| 434 content::WebUI* ScreenLocker::GetAssociatedWebUI() { | 446 content::WebUI* ScreenLocker::GetAssociatedWebUI() { |
| 435 return delegate_->GetAssociatedWebUI(); | 447 return delegate_->GetAssociatedWebUI(); |
| 436 } | 448 } |
| 437 | 449 |
| 438 } // namespace chromeos | 450 } // namespace chromeos |
| OLD | NEW |