OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 |
| 5 #ifndef COMPONENTS_KEYBOARD_LOCK_KEYBOARD_LOCK_HOST_H_ |
| 6 #define COMPONENTS_KEYBOARD_LOCK_KEYBOARD_LOCK_HOST_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <memory> |
| 10 #include <string> |
| 11 #include <vector> |
| 12 |
| 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" |
| 15 #include "components/keyboard_lock/active_key_event_filter_tracker.h" |
| 16 #include "components/keyboard_lock/key_event_filter.h" |
| 17 #include "components/keyboard_lock/key_hook_activator_collection.h" |
| 18 #include "components/keyboard_lock/key_hook_thread_wrapper.h" |
| 19 #include "ui/events/keycodes/keyboard_codes.h" |
| 20 |
| 21 class Browser; |
| 22 |
| 23 namespace base { |
| 24 class SingleThreadTaskRunner; |
| 25 } // namespace base |
| 26 |
| 27 namespace content { |
| 28 class WebContents; |
| 29 } // namespace content |
| 30 |
| 31 namespace keyboard_lock { |
| 32 |
| 33 class KeyHookThreadWrapper; |
| 34 |
| 35 class KeyboardLockHost final { |
| 36 public: |
| 37 KeyboardLockHost(Browser* owner, |
| 38 scoped_refptr<base::SingleThreadTaskRunner> runner); |
| 39 ~KeyboardLockHost(); |
| 40 |
| 41 // content/browser/keyboard_lock cannot depend on chrome/browser/ui. Providing |
| 42 // this function to bypass Browser class. Returns nullptr if no cooresponding |
| 43 // KeyboardLockHost found. |
| 44 static KeyboardLockHost* Find(const content::WebContents* contents); |
| 45 |
| 46 void SetReservedKeys(content::WebContents* contents, |
| 47 const std::vector<ui::KeyboardCode>& codes, |
| 48 base::Callback<void(bool)> on_result); |
| 49 |
| 50 void SetReservedKeyCodes(content::WebContents* contents, |
| 51 const std::vector<std::string>& codes, |
| 52 base::Callback<void(bool)> on_result); |
| 53 |
| 54 void ClearReservedKeys(content::WebContents* contents, |
| 55 base::Callback<void(bool)> on_result); |
| 56 |
| 57 private: |
| 58 static ui::KeyboardCode NativeKeycodeToKeyboardCode(uint32_t keycode); |
| 59 |
| 60 KeyEventFilter* filter() const; |
| 61 |
| 62 Browser* const owner_; |
| 63 const scoped_refptr<base::SingleThreadTaskRunner> runner_; |
| 64 |
| 65 KeyHookActivatorCollection key_hooks_; |
| 66 |
| 67 ActiveKeyEventFilterTracker active_key_event_filter_tracker_; |
| 68 |
| 69 KeyHookThreadWrapper key_hook_; |
| 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(KeyboardLockHost); |
| 72 }; |
| 73 |
| 74 } // namespace keyboard_lock |
| 75 |
| 76 #endif // COMPONENTS_KEYBOARD_LOCK_KEYBOARD_LOCK_HOST_H_ |
OLD | NEW |