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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // 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 |
112 // avoid complications with displaying the lock screen over the login | 112 // avoid complications with displaying the lock screen over the login |
113 // 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 |
114 // 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. |
115 VLOG(1) << "Calling session manager's StopSession D-Bus method"; | 115 VLOG(1) << "Calling session manager's StopSession D-Bus method"; |
116 chromeos::DBusThreadManager::Get()-> | 116 chromeos::DBusThreadManager::Get()-> |
117 GetSessionManagerClient()->StopSession(); | 117 GetSessionManagerClient()->StopSession(); |
118 } | 118 } |
119 } | 119 } |
120 | 120 |
121 virtual void UnlockScreen() OVERRIDE { | |
122 VLOG(1) << "Received UnlockScreen D-Bus signal from session manager"; | |
123 chromeos::ScreenLocker::Hide(); | |
124 } | |
125 | |
126 virtual void OnUserAddingFinished() OVERRIDE { | 121 virtual void OnUserAddingFinished() OVERRIDE { |
127 chromeos::UserAddingScreen::Get()->RemoveObserver(this); | 122 chromeos::UserAddingScreen::Get()->RemoveObserver(this); |
128 LockScreen(); | 123 LockScreen(); |
129 } | 124 } |
130 | 125 |
131 private: | 126 private: |
132 bool session_started_; | 127 bool session_started_; |
133 content::NotificationRegistrar registrar_; | 128 content::NotificationRegistrar registrar_; |
134 std::string saved_previous_input_method_id_; | 129 std::string saved_previous_input_method_id_; |
135 std::string saved_current_input_method_id_; | 130 std::string saved_current_input_method_id_; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 } | 247 } |
253 | 248 |
254 void ScreenLocker::UnlockOnLoginSuccess() { | 249 void ScreenLocker::UnlockOnLoginSuccess() { |
255 DCHECK(base::MessageLoop::current()->type() == base::MessageLoop::TYPE_UI); | 250 DCHECK(base::MessageLoop::current()->type() == base::MessageLoop::TYPE_UI); |
256 if (!authentication_capture_.get()) { | 251 if (!authentication_capture_.get()) { |
257 LOG(WARNING) << "Call to UnlockOnLoginSuccess without previous " << | 252 LOG(WARNING) << "Call to UnlockOnLoginSuccess without previous " << |
258 "authentication success."; | 253 "authentication success."; |
259 return; | 254 return; |
260 } | 255 } |
261 | 256 |
262 VLOG(1) << "Calling session manager's UnlockScreen D-Bus method"; | |
263 DBusThreadManager::Get()->GetSessionManagerClient()->RequestUnlockScreen(); | |
264 | |
265 if (login_status_consumer_) { | 257 if (login_status_consumer_) { |
266 login_status_consumer_->OnLoginSuccess( | 258 login_status_consumer_->OnLoginSuccess( |
267 UserContext(authentication_capture_->username, | 259 UserContext(authentication_capture_->username, |
268 std::string(), // password | 260 std::string(), // password |
269 std::string()), // auth_code | 261 std::string()), // auth_code |
270 authentication_capture_->pending_requests, | 262 authentication_capture_->pending_requests, |
271 authentication_capture_->using_oauth); | 263 authentication_capture_->using_oauth); |
272 } | 264 } |
273 authentication_capture_.reset(); | 265 authentication_capture_.reset(); |
274 weak_factory_.InvalidateWeakPtrs(); | 266 weak_factory_.InvalidateWeakPtrs(); |
| 267 |
| 268 VLOG(1) << "Hiding the lock screen."; |
| 269 chromeos::ScreenLocker::Hide(); |
275 } | 270 } |
276 | 271 |
277 void ScreenLocker::Authenticate(const UserContext& user_context) { | 272 void ScreenLocker::Authenticate(const UserContext& user_context) { |
278 LOG_ASSERT(IsUserLoggedIn(user_context.username)) | 273 LOG_ASSERT(IsUserLoggedIn(user_context.username)) |
279 << "Invalid user trying to unlock."; | 274 << "Invalid user trying to unlock."; |
280 authentication_start_time_ = base::Time::Now(); | 275 authentication_start_time_ = base::Time::Now(); |
281 delegate_->SetInputEnabled(false); | 276 delegate_->SetInputEnabled(false); |
282 delegate_->OnAuthenticate(); | 277 delegate_->OnAuthenticate(); |
283 | 278 |
284 BrowserThread::PostTask( | 279 BrowserThread::PostTask( |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 base::Callback<void(void)> callback = | 369 base::Callback<void(void)> callback = |
375 base::Bind(&ScreenLocker::ScheduleDeletion); | 370 base::Bind(&ScreenLocker::ScheduleDeletion); |
376 ash::Shell::GetInstance()->lock_state_controller()-> | 371 ash::Shell::GetInstance()->lock_state_controller()-> |
377 OnLockScreenHide(callback); | 372 OnLockScreenHide(callback); |
378 } | 373 } |
379 | 374 |
380 void ScreenLocker::ScheduleDeletion() { | 375 void ScreenLocker::ScheduleDeletion() { |
381 // Avoid possible multiple calls. | 376 // Avoid possible multiple calls. |
382 if (screen_locker_ == NULL) | 377 if (screen_locker_ == NULL) |
383 return; | 378 return; |
384 VLOG(1) << "Posting task to delete ScreenLocker " << screen_locker_; | 379 VLOG(1) << "Deleting ScreenLocker " << screen_locker_; |
385 ScreenLocker* screen_locker = screen_locker_; | 380 delete screen_locker_; |
386 screen_locker_ = NULL; | 381 screen_locker_ = NULL; |
387 base::MessageLoopForUI::current()->DeleteSoon(FROM_HERE, screen_locker); | |
388 } | 382 } |
389 | 383 |
390 // static | 384 // static |
391 void ScreenLocker::InitClass() { | 385 void ScreenLocker::InitClass() { |
392 g_screen_lock_observer.Get(); | 386 g_screen_lock_observer.Get(); |
393 } | 387 } |
394 | 388 |
395 //////////////////////////////////////////////////////////////////////////////// | 389 //////////////////////////////////////////////////////////////////////////////// |
396 // ScreenLocker, private: | 390 // ScreenLocker, private: |
397 | 391 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 | 444 |
451 bool ScreenLocker::IsUserLoggedIn(const std::string& username) { | 445 bool ScreenLocker::IsUserLoggedIn(const std::string& username) { |
452 for (UserList::const_iterator it = users_.begin(); it != users_.end(); ++it) { | 446 for (UserList::const_iterator it = users_.begin(); it != users_.end(); ++it) { |
453 if ((*it)->email() == username) | 447 if ((*it)->email() == username) |
454 return true; | 448 return true; |
455 } | 449 } |
456 return false; | 450 return false; |
457 } | 451 } |
458 | 452 |
459 } // namespace chromeos | 453 } // namespace chromeos |
460 | |
OLD | NEW |