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