Correct blacklist entry message
[chromium-blink-merge.git] / ui / views / focus / accelerator_handler_win.cc
blobea82daed717f324b00af2450fea8e86e84472afa
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/views/focus/accelerator_handler.h"
7 #include "ui/events/event.h"
8 #include "ui/events/keycodes/keyboard_code_conversion_win.h"
9 #include "ui/events/keycodes/keyboard_codes.h"
10 #include "ui/views/focus/focus_manager.h"
11 #include "ui/views/widget/widget.h"
13 namespace views {
15 AcceleratorHandler::AcceleratorHandler() {
18 bool AcceleratorHandler::Dispatch(const base::NativeEvent& msg) {
19 if (msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST) {
20 Widget* widget = Widget::GetTopLevelWidgetForNativeView(msg.hwnd);
21 FocusManager* focus_manager = widget ? widget->GetFocusManager() : NULL;
22 if (focus_manager) {
23 switch (msg.message) {
24 case WM_KEYDOWN:
25 case WM_SYSKEYDOWN: {
26 ui::KeyEvent event(msg, false);
27 if (!focus_manager->OnKeyEvent(event)) {
28 // Record that this key is pressed so we can remember not to
29 // translate and dispatch the associated WM_KEYUP.
30 pressed_keys_.insert(msg.wParam);
31 return true;
33 break;
35 case WM_KEYUP:
36 case WM_SYSKEYUP: {
37 std::set<WPARAM>::iterator iter = pressed_keys_.find(msg.wParam);
38 if (iter != pressed_keys_.end()) {
39 // Don't translate/dispatch the KEYUP since we have eaten the
40 // associated KEYDOWN.
41 pressed_keys_.erase(iter);
42 return true;
44 break;
50 TranslateMessage(&msg);
51 DispatchMessage(&msg);
52 return true;
55 } // namespace views