OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "media/base/user_input_monitor.h" | 5 #include "media/base/user_input_monitor.h" |
6 | 6 |
7 #include <ApplicationServices/ApplicationServices.h> | 7 #include <ApplicationServices/ApplicationServices.h> |
8 | 8 |
9 namespace media { | 9 namespace media { |
10 namespace { | 10 namespace { |
11 | 11 |
12 class UserInputMonitorMac : public UserInputMonitor { | 12 class UserInputMonitorMac : public UserInputMonitor { |
13 public: | 13 public: |
14 UserInputMonitorMac(); | 14 UserInputMonitorMac(); |
15 virtual ~UserInputMonitorMac(); | 15 virtual ~UserInputMonitorMac(); |
16 | 16 |
17 virtual size_t GetKeyPressCount() const OVERRIDE; | 17 virtual size_t GetKeyPressCount() const OVERRIDE; |
18 | 18 |
19 private: | 19 private: |
| 20 virtual void StartKeyboardMonitoring() OVERRIDE; |
| 21 virtual void StopKeyboardMonitoring() OVERRIDE; |
20 virtual void StartMouseMonitoring() OVERRIDE; | 22 virtual void StartMouseMonitoring() OVERRIDE; |
21 virtual void StopMouseMonitoring() OVERRIDE; | 23 virtual void StopMouseMonitoring() OVERRIDE; |
22 virtual void StartKeyboardMonitoring() OVERRIDE; | |
23 virtual void StopKeyboardMonitoring() OVERRIDE; | |
24 | 24 |
25 DISALLOW_COPY_AND_ASSIGN(UserInputMonitorMac); | 25 DISALLOW_COPY_AND_ASSIGN(UserInputMonitorMac); |
26 }; | 26 }; |
27 | 27 |
28 UserInputMonitorMac::UserInputMonitorMac() {} | 28 UserInputMonitorMac::UserInputMonitorMac() {} |
29 | 29 |
30 UserInputMonitorMac::~UserInputMonitorMac() {} | 30 UserInputMonitorMac::~UserInputMonitorMac() {} |
31 | 31 |
32 size_t UserInputMonitorMac::GetKeyPressCount() const { | 32 size_t UserInputMonitorMac::GetKeyPressCount() const { |
33 // Use |kCGEventSourceStateHIDSystemState| since we only want to count | 33 // Use |kCGEventSourceStateHIDSystemState| since we only want to count |
34 // hardware generated events. | 34 // hardware generated events. |
35 return CGEventSourceCounterForEventType(kCGEventSourceStateHIDSystemState, | 35 return CGEventSourceCounterForEventType(kCGEventSourceStateHIDSystemState, |
36 kCGEventKeyDown); | 36 kCGEventKeyDown); |
37 } | 37 } |
38 | 38 |
| 39 void UserInputMonitorMac::StartKeyboardMonitoring() {} |
| 40 |
| 41 void UserInputMonitorMac::StopKeyboardMonitoring() {} |
| 42 |
39 // TODO(jiayl): add the impl. | 43 // TODO(jiayl): add the impl. |
40 void UserInputMonitorMac::StartMouseMonitoring() { NOTIMPLEMENTED(); } | 44 void UserInputMonitorMac::StartMouseMonitoring() { NOTIMPLEMENTED(); } |
41 | 45 |
42 // TODO(jiayl): add the impl. | 46 // TODO(jiayl): add the impl. |
43 void UserInputMonitorMac::StopMouseMonitoring() { NOTIMPLEMENTED(); } | 47 void UserInputMonitorMac::StopMouseMonitoring() { NOTIMPLEMENTED(); } |
44 | 48 |
45 void UserInputMonitorMac::StartKeyboardMonitoring() {} | |
46 | |
47 void UserInputMonitorMac::StopKeyboardMonitoring() {} | |
48 | |
49 } // namespace | 49 } // namespace |
50 | 50 |
51 scoped_ptr<UserInputMonitor> UserInputMonitor::Create( | 51 scoped_ptr<UserInputMonitor> UserInputMonitor::Create( |
52 const scoped_refptr<base::SingleThreadTaskRunner>& input_task_runner, | 52 const scoped_refptr<base::SingleThreadTaskRunner>& input_task_runner, |
53 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) { | 53 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) { |
54 return scoped_ptr<UserInputMonitor>(new UserInputMonitorMac()); | 54 return scoped_ptr<UserInputMonitor>(new UserInputMonitorMac()); |
55 } | 55 } |
56 | 56 |
57 } // namespace media | 57 } // namespace media |
OLD | NEW |