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/accessibility/system_event_observer.h" | 5 #include "chrome/browser/chromeos/accessibility/system_event_observer.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/accessibility_events.h" | 8 #include "chrome/browser/accessibility_events.h" |
9 #include "chrome/browser/chromeos/cros/cros_library.h" | 9 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 10 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" |
10 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
11 #include "chrome/common/chrome_notification_types.h" | 12 #include "chrome/common/chrome_notification_types.h" |
12 | 13 |
13 namespace chromeos { | 14 namespace chromeos { |
14 namespace accessibility { | 15 namespace accessibility { |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 SystemEventObserver* g_system_event_observer = NULL; | 19 SystemEventObserver* g_system_event_observer = NULL; |
19 | 20 |
20 } | 21 } |
21 | 22 |
22 SystemEventObserver::SystemEventObserver() { | 23 SystemEventObserver::SystemEventObserver() { |
23 CrosLibrary::Get()->GetPowerLibrary()->AddObserver(this); | |
24 CrosLibrary::Get()->GetScreenLockLibrary()->AddObserver(this); | 24 CrosLibrary::Get()->GetScreenLockLibrary()->AddObserver(this); |
25 } | 25 } |
26 | 26 |
27 SystemEventObserver::~SystemEventObserver() { | 27 SystemEventObserver::~SystemEventObserver() { |
28 CrosLibrary::Get()->GetScreenLockLibrary()->RemoveObserver(this); | 28 CrosLibrary::Get()->GetScreenLockLibrary()->RemoveObserver(this); |
29 CrosLibrary::Get()->GetPowerLibrary()->RemoveObserver(this); | |
30 } | 29 } |
31 | 30 |
32 void SystemEventObserver::SystemResumed() { | 31 void SystemEventObserver::SystemResumed() { |
33 Profile* profile = ProfileManager::GetDefaultProfile(); | 32 Profile* profile = ProfileManager::GetDefaultProfile(); |
34 WokeUpEventInfo info(profile); | 33 WokeUpEventInfo info(profile); |
35 SendAccessibilityNotification( | 34 SendAccessibilityNotification( |
36 chrome::NOTIFICATION_ACCESSIBILITY_WOKE_UP, &info); | 35 chrome::NOTIFICATION_ACCESSIBILITY_WOKE_UP, &info); |
37 } | 36 } |
38 | 37 |
39 void SystemEventObserver::LockScreen(ScreenLockLibrary* screen_lock_library) { | 38 void SystemEventObserver::LockScreen(ScreenLockLibrary* screen_lock_library) { |
40 } | 39 } |
41 | 40 |
42 void SystemEventObserver::UnlockScreen(ScreenLockLibrary* screen_lock_library) { | 41 void SystemEventObserver::UnlockScreen(ScreenLockLibrary* screen_lock_library) { |
43 Profile* profile = ProfileManager::GetDefaultProfile(); | 42 Profile* profile = ProfileManager::GetDefaultProfile(); |
44 ScreenUnlockedEventInfo info(profile); | 43 ScreenUnlockedEventInfo info(profile); |
45 SendAccessibilityNotification( | 44 SendAccessibilityNotification( |
46 chrome::NOTIFICATION_ACCESSIBILITY_SCREEN_UNLOCKED, &info); | 45 chrome::NOTIFICATION_ACCESSIBILITY_SCREEN_UNLOCKED, &info); |
47 } | 46 } |
48 | 47 |
49 void SystemEventObserver::UnlockScreenFailed( | 48 void SystemEventObserver::UnlockScreenFailed( |
50 ScreenLockLibrary* screen_lock_library) { | 49 ScreenLockLibrary* screen_lock_library) { |
51 } | 50 } |
52 | 51 |
53 // static | 52 // static |
54 void SystemEventObserver::Initialize() { | 53 void SystemEventObserver::Initialize() { |
55 DCHECK(!g_system_event_observer); | 54 DCHECK(!g_system_event_observer); |
56 g_system_event_observer = new SystemEventObserver(); | 55 g_system_event_observer = new SystemEventObserver(); |
57 VLOG(1) << "SystemEventObserver initialized"; | 56 VLOG(1) << "SystemEventObserver initialized"; |
| 57 DBusThreadManager::Get()->GetPowerManagerClient()-> |
| 58 AddObserver(g_system_event_observer); |
58 } | 59 } |
59 | 60 |
60 // static | 61 // static |
61 SystemEventObserver* SystemEventObserver::GetInstance() { | 62 SystemEventObserver* SystemEventObserver::GetInstance() { |
62 return g_system_event_observer; | 63 return g_system_event_observer; |
63 } | 64 } |
64 | 65 |
65 // static | 66 // static |
66 void SystemEventObserver::Shutdown() { | 67 void SystemEventObserver::Shutdown() { |
67 DCHECK(g_system_event_observer); | 68 DCHECK(g_system_event_observer); |
| 69 DBusThreadManager::Get()->GetPowerManagerClient()-> |
| 70 RemoveObserver(g_system_event_observer); |
68 delete g_system_event_observer; | 71 delete g_system_event_observer; |
69 g_system_event_observer = NULL; | 72 g_system_event_observer = NULL; |
70 VLOG(1) << "SystemEventObserver Shutdown completed"; | 73 VLOG(1) << "SystemEventObserver Shutdown completed"; |
71 } | 74 } |
72 | 75 |
73 } // namespace accessibility | 76 } // namespace accessibility |
74 } // namespace chromeos | 77 } // namespace chromeos |
OLD | NEW |