| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 18 matching lines...) Expand all Loading... |
| 29 #include "chrome/browser/chromeos/login/user_manager.h" | 29 #include "chrome/browser/chromeos/login/user_manager.h" |
| 30 #include "chrome/browser/chromeos/login/webui_screen_locker.h" | 30 #include "chrome/browser/chromeos/login/webui_screen_locker.h" |
| 31 #include "chrome/browser/profiles/profile.h" | 31 #include "chrome/browser/profiles/profile.h" |
| 32 #include "chrome/browser/profiles/profile_manager.h" | 32 #include "chrome/browser/profiles/profile_manager.h" |
| 33 #include "chrome/browser/sync/profile_sync_service.h" | 33 #include "chrome/browser/sync/profile_sync_service.h" |
| 34 #include "chrome/browser/ui/browser.h" | 34 #include "chrome/browser/ui/browser.h" |
| 35 #include "chrome/browser/ui/browser_list.h" | 35 #include "chrome/browser/ui/browser_list.h" |
| 36 #include "chrome/browser/ui/browser_window.h" | 36 #include "chrome/browser/ui/browser_window.h" |
| 37 #include "chrome/common/chrome_notification_types.h" | 37 #include "chrome/common/chrome_notification_types.h" |
| 38 #include "chrome/common/chrome_switches.h" | 38 #include "chrome/common/chrome_switches.h" |
| 39 #include "content/browser/user_metrics.h" | |
| 40 #include "content/public/browser/browser_thread.h" | 39 #include "content/public/browser/browser_thread.h" |
| 41 #include "content/public/browser/notification_service.h" | 40 #include "content/public/browser/notification_service.h" |
| 41 #include "content/public/browser/user_metrics.h" |
| 42 #include "googleurl/src/gurl.h" | 42 #include "googleurl/src/gurl.h" |
| 43 #include "grit/generated_resources.h" | 43 #include "grit/generated_resources.h" |
| 44 #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h" | 44 #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h" |
| 45 #include "ui/base/l10n/l10n_util.h" | 45 #include "ui/base/l10n/l10n_util.h" |
| 46 | 46 |
| 47 #if defined(TOOLKIT_USES_GTK) | 47 #if defined(TOOLKIT_USES_GTK) |
| 48 #include "chrome/browser/chromeos/legacy_window_manager/wm_ipc.h" | 48 #include "chrome/browser/chromeos/legacy_window_manager/wm_ipc.h" |
| 49 #endif | 49 #endif |
| 50 | 50 |
| 51 #if !defined(USE_AURA) | 51 #if !defined(USE_AURA) |
| 52 #include "chrome/browser/chromeos/login/screen_locker_views.h" | 52 #include "chrome/browser/chromeos/login/screen_locker_views.h" |
| 53 #endif | 53 #endif |
| 54 | 54 |
| 55 using content::BrowserThread; | 55 using content::BrowserThread; |
| 56 using content::UserMetricsAction; |
| 56 | 57 |
| 57 namespace { | 58 namespace { |
| 58 | 59 |
| 59 // Observer to start ScreenLocker when the screen lock | 60 // Observer to start ScreenLocker when the screen lock |
| 60 class ScreenLockObserver : public chromeos::PowerManagerClient::Observer, | 61 class ScreenLockObserver : public chromeos::PowerManagerClient::Observer, |
| 61 public content::NotificationObserver { | 62 public content::NotificationObserver { |
| 62 public: | 63 public: |
| 63 ScreenLockObserver() { | 64 ScreenLockObserver() { |
| 64 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 65 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
| 65 content::NotificationService::AllSources()); | 66 content::NotificationService::AllSources()); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 if (UseWebUILockScreen()) | 211 if (UseWebUILockScreen()) |
| 211 delegate_.reset(new WebUIScreenLocker(this)); | 212 delegate_.reset(new WebUIScreenLocker(this)); |
| 212 else | 213 else |
| 213 delegate_.reset(new ScreenLockerViews(this)); | 214 delegate_.reset(new ScreenLockerViews(this)); |
| 214 #endif | 215 #endif |
| 215 delegate_->LockScreen(unlock_on_input_); | 216 delegate_->LockScreen(unlock_on_input_); |
| 216 } | 217 } |
| 217 | 218 |
| 218 void ScreenLocker::OnLoginFailure(const LoginFailure& error) { | 219 void ScreenLocker::OnLoginFailure(const LoginFailure& error) { |
| 219 DVLOG(1) << "OnLoginFailure"; | 220 DVLOG(1) << "OnLoginFailure"; |
| 220 UserMetrics::RecordAction(UserMetricsAction("ScreenLocker_OnLoginFailure")); | 221 content::RecordAction(UserMetricsAction("ScreenLocker_OnLoginFailure")); |
| 221 if (authentication_start_time_.is_null()) { | 222 if (authentication_start_time_.is_null()) { |
| 222 LOG(ERROR) << "authentication_start_time_ is not set"; | 223 LOG(ERROR) << "authentication_start_time_ is not set"; |
| 223 } else { | 224 } else { |
| 224 base::TimeDelta delta = base::Time::Now() - authentication_start_time_; | 225 base::TimeDelta delta = base::Time::Now() - authentication_start_time_; |
| 225 VLOG(1) << "Authentication failure time: " << delta.InSecondsF(); | 226 VLOG(1) << "Authentication failure time: " << delta.InSecondsF(); |
| 226 UMA_HISTOGRAM_TIMES("ScreenLocker.AuthenticationFailureTime", delta); | 227 UMA_HISTOGRAM_TIMES("ScreenLocker.AuthenticationFailureTime", delta); |
| 227 } | 228 } |
| 228 | 229 |
| 229 EnableInput(); | 230 EnableInput(); |
| 230 // Don't enable signout button here as we're showing | 231 // Don't enable signout button here as we're showing |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 } | 318 } |
| 318 | 319 |
| 319 void ScreenLocker::EnableInput() { | 320 void ScreenLocker::EnableInput() { |
| 320 delegate_->SetInputEnabled(true); | 321 delegate_->SetInputEnabled(true); |
| 321 } | 322 } |
| 322 | 323 |
| 323 void ScreenLocker::Signout() { | 324 void ScreenLocker::Signout() { |
| 324 // TODO(flackr): For proper functionality, check if (error_info) is NULL | 325 // TODO(flackr): For proper functionality, check if (error_info) is NULL |
| 325 // (crbug.com/105267). | 326 // (crbug.com/105267). |
| 326 delegate_->ClearErrors(); | 327 delegate_->ClearErrors(); |
| 327 UserMetrics::RecordAction(UserMetricsAction("ScreenLocker_Signout")); | 328 content::RecordAction(UserMetricsAction("ScreenLocker_Signout")); |
| 328 #if defined(TOOLKIT_USES_GTK) | 329 #if defined(TOOLKIT_USES_GTK) |
| 329 WmIpc::instance()->NotifyAboutSignout(); | 330 WmIpc::instance()->NotifyAboutSignout(); |
| 330 #endif | 331 #endif |
| 331 DBusThreadManager::Get()->GetSessionManagerClient()->StopSession(); | 332 DBusThreadManager::Get()->GetSessionManagerClient()->StopSession(); |
| 332 | 333 |
| 333 // Don't hide yet the locker because the chrome screen may become visible | 334 // Don't hide yet the locker because the chrome screen may become visible |
| 334 // briefly. | 335 // briefly. |
| 335 } | 336 } |
| 336 | 337 |
| 337 void ScreenLocker::ShowErrorMessage(const string16& message, | 338 void ScreenLocker::ShowErrorMessage(const string16& message, |
| 338 bool sign_out_only) { | 339 bool sign_out_only) { |
| 339 delegate_->SetInputEnabled(!sign_out_only); | 340 delegate_->SetInputEnabled(!sign_out_only); |
| 340 delegate_->SetSignoutEnabled(sign_out_only); | 341 delegate_->SetSignoutEnabled(sign_out_only); |
| 341 delegate_->ShowErrorMessage(message, sign_out_only); | 342 delegate_->ShowErrorMessage(message, sign_out_only); |
| 342 } | 343 } |
| 343 | 344 |
| 344 void ScreenLocker::SetLoginStatusConsumer( | 345 void ScreenLocker::SetLoginStatusConsumer( |
| 345 chromeos::LoginStatusConsumer* consumer) { | 346 chromeos::LoginStatusConsumer* consumer) { |
| 346 login_status_consumer_ = consumer; | 347 login_status_consumer_ = consumer; |
| 347 } | 348 } |
| 348 | 349 |
| 349 // static | 350 // static |
| 350 void ScreenLocker::Show() { | 351 void ScreenLocker::Show() { |
| 351 DVLOG(1) << "In ScreenLocker::Show"; | 352 DVLOG(1) << "In ScreenLocker::Show"; |
| 352 UserMetrics::RecordAction(UserMetricsAction("ScreenLocker_Show")); | 353 content::RecordAction(UserMetricsAction("ScreenLocker_Show")); |
| 353 DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI); | 354 DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI); |
| 354 | 355 |
| 355 // Check whether the currently logged in user is a guest account and if so, | 356 // Check whether the currently logged in user is a guest account and if so, |
| 356 // refuse to lock the screen (crosbug.com/23764). | 357 // refuse to lock the screen (crosbug.com/23764). |
| 357 // TODO(flackr): We can allow lock screen for guest accounts when | 358 // TODO(flackr): We can allow lock screen for guest accounts when |
| 358 // unlock_on_input is supported by the WebUI screen locker. | 359 // unlock_on_input is supported by the WebUI screen locker. |
| 359 if (UserManager::Get()->logged_in_user().email().empty()) { | 360 if (UserManager::Get()->logged_in_user().email().empty()) { |
| 360 DVLOG(1) << "Show: Refusing to lock screen for guest account."; | 361 DVLOG(1) << "Show: Refusing to lock screen for guest account."; |
| 361 return; | 362 return; |
| 362 } | 363 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 bool state = true; | 455 bool state = true; |
| 455 content::NotificationService::current()->Notify( | 456 content::NotificationService::current()->Notify( |
| 456 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, | 457 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, |
| 457 content::Source<ScreenLocker>(this), | 458 content::Source<ScreenLocker>(this), |
| 458 content::Details<bool>(&state)); | 459 content::Details<bool>(&state)); |
| 459 DBusThreadManager::Get()->GetPowerManagerClient()-> | 460 DBusThreadManager::Get()->GetPowerManagerClient()-> |
| 460 NotifyScreenLockCompleted(); | 461 NotifyScreenLockCompleted(); |
| 461 } | 462 } |
| 462 | 463 |
| 463 } // namespace chromeos | 464 } // namespace chromeos |
| OLD | NEW |