scoped_keyboard_hook.cc 866 B

123456789101112131415161718192021222324252627282930
  1. // Copyright 2018 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.
  4. #include "ui/aura/scoped_keyboard_hook.h"
  5. #include "ui/aura/window_tree_host.h"
  6. #include "ui/events/keycodes/dom/dom_code.h"
  7. namespace aura {
  8. ScopedKeyboardHook::ScopedKeyboardHook() = default;
  9. ScopedKeyboardHook::ScopedKeyboardHook(
  10. base::WeakPtr<WindowTreeHost> window_tree_host)
  11. : window_tree_host_(window_tree_host) {
  12. DCHECK(window_tree_host_);
  13. }
  14. ScopedKeyboardHook::~ScopedKeyboardHook() {
  15. DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
  16. if (window_tree_host_)
  17. window_tree_host_->ReleaseSystemKeyEventCapture();
  18. }
  19. bool ScopedKeyboardHook::IsKeyLocked(ui::DomCode dom_code) {
  20. return window_tree_host_ && window_tree_host_->IsKeyLocked(dom_code);
  21. }
  22. } // namespace aura