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 "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "grit/generated_resources.h" | 42 #include "grit/generated_resources.h" |
43 #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h" | 43 #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h" |
44 #include "ui/base/l10n/l10n_util.h" | 44 #include "ui/base/l10n/l10n_util.h" |
45 | 45 |
46 using content::BrowserThread; | 46 using content::BrowserThread; |
47 using content::UserMetricsAction; | 47 using content::UserMetricsAction; |
48 | 48 |
49 namespace { | 49 namespace { |
50 | 50 |
51 // Observer to start ScreenLocker when the screen lock | 51 // Observer to start ScreenLocker when the screen lock |
52 class ScreenLockObserver : public chromeos::PowerManagerClient::Observer, | 52 class ScreenLockObserver : public chromeos::SessionManagerClient::Observer, |
53 public content::NotificationObserver { | 53 public content::NotificationObserver { |
54 public: | 54 public: |
55 ScreenLockObserver() : session_started_(false) { | 55 ScreenLockObserver() : session_started_(false) { |
56 registrar_.Add(this, | 56 registrar_.Add(this, |
57 chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 57 chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
58 content::NotificationService::AllSources()); | 58 content::NotificationService::AllSources()); |
59 registrar_.Add(this, | 59 registrar_.Add(this, |
60 chrome::NOTIFICATION_SESSION_STARTED, | 60 chrome::NOTIFICATION_SESSION_STARTED, |
61 content::NotificationService::AllSources()); | 61 content::NotificationService::AllSources()); |
62 } | 62 } |
63 | 63 |
64 // NotificationObserver overrides: | 64 // NotificationObserver overrides: |
65 virtual void Observe(int type, | 65 virtual void Observe(int type, |
66 const content::NotificationSource& source, | 66 const content::NotificationSource& source, |
67 const content::NotificationDetails& details) OVERRIDE { | 67 const content::NotificationDetails& details) OVERRIDE { |
68 switch (type) { | 68 switch (type) { |
69 case chrome::NOTIFICATION_LOGIN_USER_CHANGED: { | 69 case chrome::NOTIFICATION_LOGIN_USER_CHANGED: { |
70 // Register Screen Lock only after a user has logged in. | 70 // Register Screen Lock only after a user has logged in. |
71 chromeos::PowerManagerClient* power_manager = | 71 chromeos::SessionManagerClient* session_manager = |
72 chromeos::DBusThreadManager::Get()->GetPowerManagerClient(); | 72 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); |
73 if (!power_manager->HasObserver(this)) | 73 if (!session_manager->HasObserver(this)) |
74 power_manager->AddObserver(this); | 74 session_manager->AddObserver(this); |
75 break; | 75 break; |
76 } | 76 } |
77 | 77 |
78 case chrome::NOTIFICATION_SESSION_STARTED: { | 78 case chrome::NOTIFICATION_SESSION_STARTED: { |
79 session_started_ = true; | 79 session_started_ = true; |
80 break; | 80 break; |
81 } | 81 } |
82 | 82 |
83 default: | 83 default: |
84 NOTREACHED(); | 84 NOTREACHED(); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 SigninManager* signin = SigninManagerFactory::GetForProfile(profile); | 192 SigninManager* signin = SigninManagerFactory::GetForProfile(profile); |
193 DCHECK(signin); | 193 DCHECK(signin); |
194 GoogleServiceSigninSuccessDetails details( | 194 GoogleServiceSigninSuccessDetails details( |
195 signin->GetAuthenticatedUsername(), | 195 signin->GetAuthenticatedUsername(), |
196 password); | 196 password); |
197 content::NotificationService::current()->Notify( | 197 content::NotificationService::current()->Notify( |
198 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, | 198 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, |
199 content::Source<Profile>(profile), | 199 content::Source<Profile>(profile), |
200 content::Details<const GoogleServiceSigninSuccessDetails>(&details)); | 200 content::Details<const GoogleServiceSigninSuccessDetails>(&details)); |
201 } | 201 } |
202 DBusThreadManager::Get()->GetPowerManagerClient()-> | 202 DBusThreadManager::Get()->GetSessionManagerClient()->RequestUnlockScreen(); |
203 NotifyScreenUnlockRequested(); | |
204 | 203 |
205 if (login_status_consumer_) | 204 if (login_status_consumer_) |
206 login_status_consumer_->OnLoginSuccess(username, password, pending_requests, | 205 login_status_consumer_->OnLoginSuccess(username, password, pending_requests, |
207 using_oauth); | 206 using_oauth); |
208 } | 207 } |
209 | 208 |
210 void ScreenLocker::Authenticate(const string16& password) { | 209 void ScreenLocker::Authenticate(const string16& password) { |
211 authentication_start_time_ = base::Time::Now(); | 210 authentication_start_time_ = base::Time::Now(); |
212 delegate_->SetInputEnabled(false); | 211 delegate_->SetInputEnabled(false); |
213 delegate_->OnAuthenticate(); | 212 delegate_->OnAuthenticate(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 if (browser && browser->window()->IsFullscreen()) { | 278 if (browser && browser->window()->IsFullscreen()) { |
280 browser->ToggleFullscreenMode(); | 279 browser->ToggleFullscreenMode(); |
281 } | 280 } |
282 | 281 |
283 if (!screen_locker_) { | 282 if (!screen_locker_) { |
284 DVLOG(1) << "Show: Locking screen"; | 283 DVLOG(1) << "Show: Locking screen"; |
285 ScreenLocker* locker = | 284 ScreenLocker* locker = |
286 new ScreenLocker(UserManager::Get()->GetLoggedInUser()); | 285 new ScreenLocker(UserManager::Get()->GetLoggedInUser()); |
287 locker->Init(); | 286 locker->Init(); |
288 } else { | 287 } else { |
289 // PowerManager re-sends lock screen signal if it doesn't | |
290 // receive the response within timeout. Just send complete | |
291 // signal. | |
292 DVLOG(1) << "Show: locker already exists. Just sending completion event."; | 288 DVLOG(1) << "Show: locker already exists. Just sending completion event."; |
293 DBusThreadManager::Get()->GetPowerManagerClient()-> | 289 DBusThreadManager::Get()->GetPowerManagerClient()-> |
294 NotifyScreenLockCompleted(); | 290 NotifyScreenLockCompleted(); |
295 } | 291 } |
296 } | 292 } |
297 | 293 |
298 // static | 294 // static |
299 void ScreenLocker::Hide() { | 295 void ScreenLocker::Hide() { |
300 DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI); | 296 DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI); |
301 // For a guest/demo user, screen_locker_ would have never been initialized. | 297 // For a guest/demo user, screen_locker_ would have never been initialized. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 bool state = true; | 342 bool state = true; |
347 content::NotificationService::current()->Notify( | 343 content::NotificationService::current()->Notify( |
348 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, | 344 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, |
349 content::Source<ScreenLocker>(this), | 345 content::Source<ScreenLocker>(this), |
350 content::Details<bool>(&state)); | 346 content::Details<bool>(&state)); |
351 DBusThreadManager::Get()->GetPowerManagerClient()-> | 347 DBusThreadManager::Get()->GetPowerManagerClient()-> |
352 NotifyScreenLockCompleted(); | 348 NotifyScreenLockCompleted(); |
353 } | 349 } |
354 | 350 |
355 } // namespace chromeos | 351 } // namespace chromeos |
OLD | NEW |