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/power_button_observer.h" | 5 #include "chrome/browser/chromeos/power/power_button_observer.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/system/user/login_status.h" | 8 #include "ash/system/user/login_status.h" |
9 #include "ash/wm/power_button_controller.h" | 9 #include "ash/wm/power_button_controller.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 registrar_.Add( | 44 registrar_.Add( |
45 this, | 45 this, |
46 content::NOTIFICATION_APP_TERMINATING, | 46 content::NOTIFICATION_APP_TERMINATING, |
47 content::NotificationService::AllSources()); | 47 content::NotificationService::AllSources()); |
48 registrar_.Add( | 48 registrar_.Add( |
49 this, | 49 this, |
50 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, | 50 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, |
51 content::NotificationService::AllSources()); | 51 content::NotificationService::AllSources()); |
52 | 52 |
53 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); | 53 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); |
| 54 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); |
54 | 55 |
55 // Tell the controller about the initial state. | 56 // Tell the controller about the initial state. |
56 ash::Shell::GetInstance()->OnLoginStateChanged(GetCurrentLoginStatus()); | 57 ash::Shell::GetInstance()->OnLoginStateChanged(GetCurrentLoginStatus()); |
57 | 58 |
58 const ScreenLocker* locker = ScreenLocker::default_screen_locker(); | 59 const ScreenLocker* locker = ScreenLocker::default_screen_locker(); |
59 bool locked = locker && locker->locked(); | 60 bool locked = locker && locker->locked(); |
60 ash::Shell::GetInstance()->OnLockStateChanged(locked); | 61 ash::Shell::GetInstance()->OnLockStateChanged(locked); |
61 } | 62 } |
62 | 63 |
63 PowerButtonObserver::~PowerButtonObserver() { | 64 PowerButtonObserver::~PowerButtonObserver() { |
| 65 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); |
64 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); | 66 DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver(this); |
65 } | 67 } |
66 | 68 |
67 void PowerButtonObserver::Observe(int type, | 69 void PowerButtonObserver::Observe(int type, |
68 const content::NotificationSource& source, | 70 const content::NotificationSource& source, |
69 const content::NotificationDetails& details) { | 71 const content::NotificationDetails& details) { |
70 switch (type) { | 72 switch (type) { |
71 case chrome::NOTIFICATION_LOGIN_USER_CHANGED: { | 73 case chrome::NOTIFICATION_LOGIN_USER_CHANGED: { |
72 ash::Shell::GetInstance()->OnLoginStateChanged(GetCurrentLoginStatus()); | 74 ash::Shell::GetInstance()->OnLoginStateChanged(GetCurrentLoginStatus()); |
73 break; | 75 break; |
(...skipping 21 matching lines...) Expand all Loading... |
95 bool down, const base::TimeTicks& timestamp) { | 97 bool down, const base::TimeTicks& timestamp) { |
96 ash::Shell::GetInstance()->power_button_controller()-> | 98 ash::Shell::GetInstance()->power_button_controller()-> |
97 OnLockButtonEvent(down, timestamp); | 99 OnLockButtonEvent(down, timestamp); |
98 } | 100 } |
99 | 101 |
100 void PowerButtonObserver::LockScreen() { | 102 void PowerButtonObserver::LockScreen() { |
101 ash::Shell::GetInstance()->power_button_controller()->OnStartingLock(); | 103 ash::Shell::GetInstance()->power_button_controller()->OnStartingLock(); |
102 } | 104 } |
103 | 105 |
104 } // namespace chromeos | 106 } // namespace chromeos |
OLD | NEW |