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 "third_party/skia/include/core/SkPoint.h" | 7 #include "third_party/skia/include/core/SkPoint.h" |
8 | 8 |
9 namespace media { | 9 namespace media { |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 void UserInputMonitor::OnMouseEvent(const SkIPoint& position) { | 64 void UserInputMonitor::OnMouseEvent(const SkIPoint& position) { |
65 base::AutoLock auto_lock(lock_); | 65 base::AutoLock auto_lock(lock_); |
66 FOR_EACH_OBSERVER( | 66 FOR_EACH_OBSERVER( |
67 MouseEventListener, mouse_listeners_, OnMouseMoved(position)); | 67 MouseEventListener, mouse_listeners_, OnMouseMoved(position)); |
68 } | 68 } |
69 | 69 |
70 void UserInputMonitor::OnKeyboardEvent(ui::EventType event, | 70 void UserInputMonitor::OnKeyboardEvent(ui::EventType event, |
71 ui::KeyboardCode key_code) { | 71 ui::KeyboardCode key_code) { |
72 base::AutoLock auto_lock(lock_); | 72 base::AutoLock auto_lock(lock_); |
73 // Updates the pressed keys and maybe notifies the key_stroke_listeners_. | 73 // Updates the pressed keys and maybe notifies the key_stroke_listeners_. |
74 // The Mac implementation does not listen to the the key down/up events, but | |
75 // polls the key state and only notifies UserInputMonitor when a key is down | |
76 // now but not in the previous polling. So we do not check/update | |
77 // |pressed_keys_| here. | |
74 if (event == ui::ET_KEY_PRESSED) { | 78 if (event == ui::ET_KEY_PRESSED) { |
79 #if !defined(OS_MACOSX) | |
75 if (pressed_keys_.find(key_code) != pressed_keys_.end()) | 80 if (pressed_keys_.find(key_code) != pressed_keys_.end()) |
76 return; | 81 return; |
77 pressed_keys_.insert(key_code); | 82 pressed_keys_.insert(key_code); |
83 #endif | |
84 | |
78 DVLOG(6) << "Key stroke detected."; | 85 DVLOG(6) << "Key stroke detected."; |
79 FOR_EACH_OBSERVER(KeyStrokeListener, key_stroke_listeners_, OnKeyStroke()); | 86 FOR_EACH_OBSERVER(KeyStrokeListener, key_stroke_listeners_, OnKeyStroke()); |
80 } else { | 87 } else { |
88 #if defined(OS_MACOSX) | |
89 DCHECK(false); | |
Mark Mentovai
2013/08/21 18:32:43
Oh, so NOTREACHED?
You still should write “return
jiayl
2013/08/21 22:58:22
Done.
| |
90 #endif | |
91 | |
81 DCHECK_EQ(ui::ET_KEY_RELEASED, event); | 92 DCHECK_EQ(ui::ET_KEY_RELEASED, event); |
82 DCHECK(pressed_keys_.find(key_code) != pressed_keys_.end()); | 93 DCHECK(pressed_keys_.find(key_code) != pressed_keys_.end()); |
83 pressed_keys_.erase(key_code); | 94 pressed_keys_.erase(key_code); |
84 } | 95 } |
85 } | 96 } |
86 | 97 |
87 } // namespace media | 98 } // namespace media |
OLD | NEW |