| 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 21 matching lines...) Expand all Loading... |
| 32 #include "chrome/browser/profiles/profile.h" | 32 #include "chrome/browser/profiles/profile.h" |
| 33 #include "chrome/browser/profiles/profile_manager.h" | 33 #include "chrome/browser/profiles/profile_manager.h" |
| 34 #include "chrome/browser/sync/profile_sync_service.h" | 34 #include "chrome/browser/sync/profile_sync_service.h" |
| 35 #include "chrome/browser/ui/browser.h" | 35 #include "chrome/browser/ui/browser.h" |
| 36 #include "chrome/browser/ui/browser_list.h" | 36 #include "chrome/browser/ui/browser_list.h" |
| 37 #include "chrome/browser/ui/browser_window.h" | 37 #include "chrome/browser/ui/browser_window.h" |
| 38 #include "chrome/common/chrome_notification_types.h" | 38 #include "chrome/common/chrome_notification_types.h" |
| 39 #include "chrome/common/chrome_switches.h" | 39 #include "chrome/common/chrome_switches.h" |
| 40 #include "content/browser/browser_thread.h" | 40 #include "content/browser/browser_thread.h" |
| 41 #include "content/browser/user_metrics.h" | 41 #include "content/browser/user_metrics.h" |
| 42 #include "content/common/notification_service.h" | 42 #include "content/public/browser/notification_service.h" |
| 43 #include "googleurl/src/gurl.h" | 43 #include "googleurl/src/gurl.h" |
| 44 #include "grit/generated_resources.h" | 44 #include "grit/generated_resources.h" |
| 45 #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h" | 45 #include "third_party/cros_system_api/window_manager/chromeos_wm_ipc_enums.h" |
| 46 #include "ui/base/l10n/l10n_util.h" | 46 #include "ui/base/l10n/l10n_util.h" |
| 47 | 47 |
| 48 #if defined(TOOLKIT_USES_GTK) | 48 #if defined(TOOLKIT_USES_GTK) |
| 49 #include "chrome/browser/chromeos/wm_ipc.h" | 49 #include "chrome/browser/chromeos/wm_ipc.h" |
| 50 #endif | 50 #endif |
| 51 | 51 |
| 52 namespace { | 52 namespace { |
| 53 | 53 |
| 54 // Observer to start ScreenLocker when the screen lock | 54 // Observer to start ScreenLocker when the screen lock |
| 55 class ScreenLockObserver : public chromeos::ScreenLockLibrary::Observer, | 55 class ScreenLockObserver : public chromeos::ScreenLockLibrary::Observer, |
| 56 public content::NotificationObserver { | 56 public content::NotificationObserver { |
| 57 public: | 57 public: |
| 58 ScreenLockObserver() { | 58 ScreenLockObserver() { |
| 59 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 59 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
| 60 NotificationService::AllSources()); | 60 content::NotificationService::AllSources()); |
| 61 } | 61 } |
| 62 | 62 |
| 63 // NotificationObserver overrides: | 63 // NotificationObserver overrides: |
| 64 virtual void Observe(int type, | 64 virtual void Observe(int type, |
| 65 const content::NotificationSource& source, | 65 const content::NotificationSource& source, |
| 66 const content::NotificationDetails& details) OVERRIDE { | 66 const content::NotificationDetails& details) OVERRIDE { |
| 67 if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED) { | 67 if (type == chrome::NOTIFICATION_LOGIN_USER_CHANGED) { |
| 68 // Register Screen Lock after login screen to make sure | 68 // Register Screen Lock after login screen to make sure |
| 69 // we don't show the screen lock on top of the login screen by accident. | 69 // we don't show the screen lock on top of the login screen by accident. |
| 70 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) | 70 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 | 414 |
| 415 //////////////////////////////////////////////////////////////////////////////// | 415 //////////////////////////////////////////////////////////////////////////////// |
| 416 // ScreenLocker, private: | 416 // ScreenLocker, private: |
| 417 | 417 |
| 418 ScreenLocker::~ScreenLocker() { | 418 ScreenLocker::~ScreenLocker() { |
| 419 DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI); | 419 DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI); |
| 420 ClearErrors(); | 420 ClearErrors(); |
| 421 | 421 |
| 422 screen_locker_ = NULL; | 422 screen_locker_ = NULL; |
| 423 bool state = false; | 423 bool state = false; |
| 424 NotificationService::current()->Notify( | 424 content::NotificationService::current()->Notify( |
| 425 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, | 425 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, |
| 426 content::Source<ScreenLocker>(this), | 426 content::Source<ScreenLocker>(this), |
| 427 content::Details<bool>(&state)); | 427 content::Details<bool>(&state)); |
| 428 if (CrosLibrary::Get()->EnsureLoaded()) | 428 if (CrosLibrary::Get()->EnsureLoaded()) |
| 429 CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenUnlockCompleted(); | 429 CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenUnlockCompleted(); |
| 430 } | 430 } |
| 431 | 431 |
| 432 void ScreenLocker::SetAuthenticator(Authenticator* authenticator) { | 432 void ScreenLocker::SetAuthenticator(Authenticator* authenticator) { |
| 433 authenticator_ = authenticator; | 433 authenticator_ = authenticator; |
| 434 } | 434 } |
| 435 | 435 |
| 436 void ScreenLocker::ScreenLockReady() { | 436 void ScreenLocker::ScreenLockReady() { |
| 437 VLOG(1) << "ScreenLockReady: sending completed signal to power manager."; | 437 VLOG(1) << "ScreenLockReady: sending completed signal to power manager."; |
| 438 locked_ = true; | 438 locked_ = true; |
| 439 base::TimeDelta delta = base::Time::Now() - start_time_; | 439 base::TimeDelta delta = base::Time::Now() - start_time_; |
| 440 VLOG(1) << "Screen lock time: " << delta.InSecondsF(); | 440 VLOG(1) << "Screen lock time: " << delta.InSecondsF(); |
| 441 UMA_HISTOGRAM_TIMES("ScreenLocker.ScreenLockTime", delta); | 441 UMA_HISTOGRAM_TIMES("ScreenLocker.ScreenLockTime", delta); |
| 442 | 442 |
| 443 bool state = true; | 443 bool state = true; |
| 444 NotificationService::current()->Notify( | 444 content::NotificationService::current()->Notify( |
| 445 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, | 445 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, |
| 446 content::Source<ScreenLocker>(this), | 446 content::Source<ScreenLocker>(this), |
| 447 content::Details<bool>(&state)); | 447 content::Details<bool>(&state)); |
| 448 if (CrosLibrary::Get()->EnsureLoaded()) | 448 if (CrosLibrary::Get()->EnsureLoaded()) |
| 449 CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenLockCompleted(); | 449 CrosLibrary::Get()->GetScreenLockLibrary()->NotifyScreenLockCompleted(); |
| 450 } | 450 } |
| 451 | 451 |
| 452 } // namespace chromeos | 452 } // namespace chromeos |
| OLD | NEW |