| 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/power/login_lock_state_notifier.h" | 5 #include "chrome/browser/chromeos/power/login_lock_state_notifier.h" |
| 6 | 6 |
| 7 #include "ash/common/login_status.h" | 7 #include "ash/common/login_status.h" |
| 8 #include "ash/common/system/tray/system_tray_delegate.h" | 8 #include "ash/common/system/tray/system_tray_delegate.h" |
| 9 #include "ash/common/wm_shell.h" | 9 #include "ash/common/wm_shell.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
| 13 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 13 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
| 14 #include "chrome/browser/chromeos/power/session_state_controller_delegate_chrome
os.h" | |
| 15 #include "content/public/browser/notification_service.h" | 14 #include "content/public/browser/notification_service.h" |
| 16 | 15 |
| 17 namespace ash { | 16 namespace ash { |
| 18 class LockStateControllerDelegate; | 17 class LockStateControllerDelegate; |
| 19 } | 18 } |
| 20 | 19 |
| 21 namespace chromeos { | 20 namespace chromeos { |
| 22 | 21 |
| 23 namespace { | 22 namespace { |
| 24 | 23 |
| 25 ash::LoginStatus GetCurrentLoginStatus() { | 24 ash::LoginStatus GetCurrentLoginStatus() { |
| 26 if (ash::WmShell::Get()->system_tray_delegate()) | 25 if (ash::WmShell::Get()->system_tray_delegate()) |
| 27 return ash::WmShell::Get()->system_tray_delegate()->GetUserLoginStatus(); | 26 return ash::WmShell::Get()->system_tray_delegate()->GetUserLoginStatus(); |
| 28 | 27 |
| 29 return ash::LoginStatus::NOT_LOGGED_IN; | 28 return ash::LoginStatus::NOT_LOGGED_IN; |
| 30 } | 29 } |
| 31 | 30 |
| 32 } // namespace | 31 } // namespace |
| 33 | 32 |
| 34 LoginLockStateNotifier::LoginLockStateNotifier() { | 33 LoginLockStateNotifier::LoginLockStateNotifier() { |
| 35 ash::Shell::GetInstance()->lock_state_controller()->SetDelegate( | |
| 36 std::unique_ptr<ash::LockStateControllerDelegate>( | |
| 37 new SessionStateControllerDelegateChromeos)); | |
| 38 | |
| 39 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_CHANGED, | 34 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_CHANGED, |
| 40 content::NotificationService::AllSources()); | 35 content::NotificationService::AllSources()); |
| 41 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, | 36 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, |
| 42 content::NotificationService::AllSources()); | 37 content::NotificationService::AllSources()); |
| 43 registrar_.Add(this, chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, | 38 registrar_.Add(this, chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, |
| 44 content::NotificationService::AllSources()); | 39 content::NotificationService::AllSources()); |
| 45 | 40 |
| 46 // Tell the controller about the initial state. | 41 // Tell the controller about the initial state. |
| 47 ash::Shell::GetInstance()->OnLoginStateChanged(GetCurrentLoginStatus()); | 42 ash::Shell::GetInstance()->OnLoginStateChanged(GetCurrentLoginStatus()); |
| 48 | 43 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 69 bool locked = *content::Details<bool>(details).ptr(); | 64 bool locked = *content::Details<bool>(details).ptr(); |
| 70 ash::Shell::GetInstance()->OnLockStateChanged(locked); | 65 ash::Shell::GetInstance()->OnLockStateChanged(locked); |
| 71 break; | 66 break; |
| 72 } | 67 } |
| 73 default: | 68 default: |
| 74 NOTREACHED() << "Unexpected notification " << type; | 69 NOTREACHED() << "Unexpected notification " << type; |
| 75 } | 70 } |
| 76 } | 71 } |
| 77 | 72 |
| 78 } // namespace chromeos | 73 } // namespace chromeos |
| OLD | NEW |