summaryrefslogtreecommitdiffstats
path: root/chrome/views/accelerator_handler.cc
blob: 1ac028301546e827412ff59f9319be28cde25d6f (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
// Copyright (c) 2006-2008 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 "chrome/views/accelerator_handler.h"

#include "chrome/views/focus_manager.h"

namespace ChromeViews {

AcceleratorHandler::AcceleratorHandler() {
}

bool AcceleratorHandler::Dispatch(const MSG& msg) {
  bool process_message = true;
  if ((msg.message == WM_KEYDOWN) || (msg.message == WM_SYSKEYDOWN)) {
    ChromeViews::FocusManager* focus_manager =
        ChromeViews::FocusManager::GetFocusManager(msg.hwnd);
    if (focus_manager) {
      // FocusManager::OnKeyDown returns false if this message has been
      // consumed and should not be propogated further
      if (!focus_manager->OnKeyDown(msg.hwnd, msg.message, msg.wParam,
                                    msg.lParam)) {
        process_message = false;
      }
    }
  }
  if (process_message) {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
  }

  return true;
}

}