scoped_simple_keyboard_hook.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. #ifndef UI_AURA_SCOPED_SIMPLE_KEYBOARD_HOOK_H_
  5. #define UI_AURA_SCOPED_SIMPLE_KEYBOARD_HOOK_H_
  6. #include "base/containers/flat_set.h"
  7. #include "third_party/abseil-cpp/absl/types/optional.h"
  8. #include "ui/aura/scoped_keyboard_hook.h"
  9. namespace ui {
  10. enum class DomCode;
  11. }
  12. namespace aura {
  13. // This subclass of ScopedKeyboardHook will not set up a system-level keyboard
  14. // hook or call into any WindowTreeHost methods for lock state or cleanup.
  15. // It allows for disabling system-level keyboard lock functionality while
  16. // continuing to support browser-level keyboard lock.
  17. // TODO(joedow): Remove this class after 'system-keyboard-lock' is removed.
  18. class ScopedSimpleKeyboardHook : public ScopedKeyboardHook {
  19. public:
  20. explicit ScopedSimpleKeyboardHook(
  21. absl::optional<base::flat_set<ui::DomCode>> dom_codes);
  22. ScopedSimpleKeyboardHook(const ScopedSimpleKeyboardHook&) = delete;
  23. ScopedSimpleKeyboardHook& operator=(const ScopedSimpleKeyboardHook&) = delete;
  24. ~ScopedSimpleKeyboardHook() override;
  25. // ScopedKeyboardHook override.
  26. bool IsKeyLocked(ui::DomCode dom_code) override;
  27. private:
  28. absl::optional<base::flat_set<ui::DomCode>> dom_codes_;
  29. };
  30. } // namespace aura
  31. #endif // UI_AURA_SCOPED_SIMPLE_KEYBOARD_HOOK_H_