Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Unified Diff: media/base/user_input_monitor.h

Issue 21183002: Adding key press detection in the browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/base/user_input_monitor.h
diff --git a/media/base/user_input_monitor.h b/media/base/user_input_monitor.h
new file mode 100644
index 0000000000000000000000000000000000000000..a99aa5a401684ddb59c65839a91ab3b39688cf80
--- /dev/null
+++ b/media/base/user_input_monitor.h
@@ -0,0 +1,69 @@
+// Copyright (c) 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.
+
+#ifndef MEDIA_BASE_USER_INPUT_MONITOR_H_
+#define MEDIA_BASE_USER_INPUT_MONITOR_H_
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "ui/base/events/event_constants.h"
+#include "ui/base/keycodes/keyboard_codes.h"
+
+struct SkIPoint;
+
+namespace base {
+class SingleThreadTaskRunner;
+} // namespace base
+
+namespace media {
+
+// Called on the |observer_task_runner|.
+class UserInputObserver {
+ public:
+ // Called when the mouse is moved.
+ virtual void OnMouseMoved(const SkIPoint& position) = 0;
+ // Called when a key is pressed or released.
+ // |event| can only be ui::ET_KEY_PRESSED or ui::ET_KEY_RELEASED.
+ virtual void OnKeyboardEvent(ui::EventType event,
+ ui::KeyboardCode key_code) = 0;
+
+ protected:
+ virtual ~UserInputObserver() {}
+};
+
+// Monitors and notifies about mouse movements and keyboard events.
+class UserInputMonitor {
+ public:
+ // Bit masks for specifying input events of interest.
+ enum InputEvent {
+ MOUSE_MOVEMENT = 0x1,
Sergey Ulanov 2013/08/08 01:25:48 MOUSE_EVENT (enum name and the other already have
jiayl 2013/08/09 23:30:14 Removed now.
+ KEYBOARD_EVENT = 0x2,
+ };
+
+ virtual ~UserInputMonitor() {}
+
+ // Creates a platform-specific instance of UserInputMonitor.
+ // |input_task_runner| is the task runner for an IO thread.
+ // |ui_task_runner| is the task runner for a UI thread.
+ // |observer_task_runner| is the task runner to run callbacks to the
+ // |observer|.
+ // |input_event_mask| specifies the events the caller is interested to
+ // receive notifications for.
+ // |observer| is the notification receiver and dereferenced on the
+ // |observer_task_runner|.
+ static scoped_ptr<UserInputMonitor> Create(
+ const scoped_refptr<base::SingleThreadTaskRunner>& input_task_runner,
+ const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner,
+ const scoped_refptr<base::SingleThreadTaskRunner>& observer_task_runner,
+ uint8 input_event_mask,
+ const base::WeakPtr<UserInputObserver>& observer);
+
+ protected:
+ UserInputMonitor() {}
+};
+
+} // namespace media
+
+#endif // MEDIA_BASE_USER_INPUT_MONITOR_H_

Powered by Google App Engine
This is Rietveld 408576698