summaryrefslogtreecommitdiff
path: root/chromium/ui/aura/scoped_keyboard_hook.cc
blob: 68348c16f75720ad52ce9c7e2a34e7597fa4acfe (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
// Copyright 2018 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 "ui/aura/scoped_keyboard_hook.h"

#include "base/macros.h"
#include "ui/aura/window_tree_host.h"

namespace aura {

ScopedKeyboardHook::ScopedKeyboardHook() = default;

ScopedKeyboardHook::ScopedKeyboardHook(
    base::WeakPtr<WindowTreeHost> window_tree_host)
    : window_tree_host_(window_tree_host) {
  DCHECK(window_tree_host_);
}

ScopedKeyboardHook::~ScopedKeyboardHook() {
  DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
  if (window_tree_host_)
    window_tree_host_->ReleaseSystemKeyEventCapture();
}

bool ScopedKeyboardHook::IsKeyLocked(int native_key_code) {
  return window_tree_host_ && window_tree_host_->IsKeyLocked(native_key_code);
}

}  // namespace aura