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 return; |
| 106 } |
99 if (session_started_ && | 107 if (session_started_ && |
100 chromeos::UserManager::Get()->CanCurrentUserLock()) { | 108 chromeos::UserManager::Get()->CanCurrentUserLock()) { |
101 chromeos::ScreenLocker::Show(); | 109 chromeos::ScreenLocker::Show(); |
102 } else { | 110 } else { |
103 // If the current user's session cannot be locked or the user has not | 111 // 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 | 112 // 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 | 113 // avoid complications with displaying the lock screen over the login |
106 // screen while remaining secure in the case the user walks away during | 114 // 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. | 115 // the sign-in steps. See crbug.com/112225 and crbug.com/110933. |
108 VLOG(1) << "Calling session manager's StopSession D-Bus method"; | 116 VLOG(1) << "Calling session manager's StopSession D-Bus method"; |
109 chromeos::DBusThreadManager::Get()-> | 117 chromeos::DBusThreadManager::Get()-> |
110 GetSessionManagerClient()->StopSession(); | 118 GetSessionManagerClient()->StopSession(); |
111 } | 119 } |
112 } | 120 } |
113 | 121 |
114 virtual void UnlockScreen() OVERRIDE { | 122 virtual void UnlockScreen() OVERRIDE { |
115 VLOG(1) << "Received UnlockScreen D-Bus signal from session manager"; | 123 VLOG(1) << "Received UnlockScreen D-Bus signal from session manager"; |
116 chromeos::ScreenLocker::Hide(); | 124 chromeos::ScreenLocker::Hide(); |
117 } | 125 } |
118 | 126 |
| 127 virtual void OnUserAddingFinished() OVERRIDE { |
| 128 chromeos::UserAddingScreen::Get()->RemoveObserver(this); |
| 129 LockScreen(); |
| 130 } |
| 131 |
119 private: | 132 private: |
120 bool session_started_; | 133 bool session_started_; |
121 content::NotificationRegistrar registrar_; | 134 content::NotificationRegistrar registrar_; |
122 std::string saved_previous_input_method_id_; | 135 std::string saved_previous_input_method_id_; |
123 std::string saved_current_input_method_id_; | 136 std::string saved_current_input_method_id_; |
124 std::vector<std::string> saved_active_input_method_list_; | 137 std::vector<std::string> saved_active_input_method_list_; |
125 | 138 |
126 DISALLOW_COPY_AND_ASSIGN(ScreenLockObserver); | 139 DISALLOW_COPY_AND_ASSIGN(ScreenLockObserver); |
127 }; | 140 }; |
128 | 141 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 content::Details<bool>(&state)); | 442 content::Details<bool>(&state)); |
430 VLOG(1) << "Calling session manager's HandleLockScreenShown D-Bus method"; | 443 VLOG(1) << "Calling session manager's HandleLockScreenShown D-Bus method"; |
431 DBusThreadManager::Get()->GetSessionManagerClient()->NotifyLockScreenShown(); | 444 DBusThreadManager::Get()->GetSessionManagerClient()->NotifyLockScreenShown(); |
432 } | 445 } |
433 | 446 |
434 content::WebUI* ScreenLocker::GetAssociatedWebUI() { | 447 content::WebUI* ScreenLocker::GetAssociatedWebUI() { |
435 return delegate_->GetAssociatedWebUI(); | 448 return delegate_->GetAssociatedWebUI(); |
436 } | 449 } |
437 | 450 |
438 } // namespace chromeos | 451 } // namespace chromeos |
OLD | NEW |