summaryrefslogtreecommitdiff
path: root/media/base/user_input_monitor_mac.cc
blob: f70ee4d06a45d519fd97e42a365b45e08eedeacf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "media/base/user_input_monitor.h"

#include <ApplicationServices/ApplicationServices.h>

namespace media {
namespace {

class UserInputMonitorMac : public UserInputMonitor {
 public:
  UserInputMonitorMac();
  virtual ~UserInputMonitorMac();

  virtual size_t GetKeyPressCount() const OVERRIDE;

 private:
  virtual void StartKeyboardMonitoring() OVERRIDE;
  virtual void StopKeyboardMonitoring() OVERRIDE;
  virtual void StartMouseMonitoring() OVERRIDE;
  virtual void StopMouseMonitoring() OVERRIDE;

  DISALLOW_COPY_AND_ASSIGN(UserInputMonitorMac);
};

UserInputMonitorMac::UserInputMonitorMac() {}

UserInputMonitorMac::~UserInputMonitorMac() {}

size_t UserInputMonitorMac::GetKeyPressCount() const {
  // Use |kCGEventSourceStateHIDSystemState| since we only want to count
  // hardware generated events.
  return CGEventSourceCounterForEventType(kCGEventSourceStateHIDSystemState,
                                          kCGEventKeyDown);
}

void UserInputMonitorMac::StartKeyboardMonitoring() {}

void UserInputMonitorMac::StopKeyboardMonitoring() {}

// TODO(jiayl): add the impl.
void UserInputMonitorMac::StartMouseMonitoring() { NOTIMPLEMENTED(); }

// TODO(jiayl): add the impl.
void UserInputMonitorMac::StopMouseMonitoring() { NOTIMPLEMENTED(); }

}  // namespace

scoped_ptr<UserInputMonitor> UserInputMonitor::Create(
    const scoped_refptr<base::SingleThreadTaskRunner>& input_task_runner,
    const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) {
  return scoped_ptr<UserInputMonitor>(new UserInputMonitorMac());
}

}  // namespace media