Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2722)

Unified Diff: components/keyboard_lock/active_key_event_filter_tracker.h

Issue 2879033002: Keyboard Lock Host implementation
Patch Set: Remove useless files Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/keyboard_lock/active_key_event_filter_tracker.h
diff --git a/components/keyboard_lock/active_key_event_filter_tracker.h b/components/keyboard_lock/active_key_event_filter_tracker.h
new file mode 100644
index 0000000000000000000000000000000000000000..edc167bce7577fffc9a83cb0647b87411b07d1fc
--- /dev/null
+++ b/components/keyboard_lock/active_key_event_filter_tracker.h
@@ -0,0 +1,35 @@
+// Copyright 2017 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.
+
+#ifndef COMPONENTS_KEYBOARD_LOCK_ACTIVE_KEY_EVENT_FILTER_TRACKER_H_
+#define COMPONENTS_KEYBOARD_LOCK_ACTIVE_KEY_EVENT_FILTER_TRACKER_H_
+
+#include "base/threading/thread_checker.h"
+
+namespace keyboard_lock {
+
+class KeyEventFilter;
+
+// Tracks the active KeyEventFilter.
+// All public functions must be executed in one thread.
+class ActiveKeyEventFilterTracker final {
+ public:
+ ActiveKeyEventFilterTracker();
+ ~ActiveKeyEventFilterTracker();
+
+ void set(KeyEventFilter* filter);
+ // If |filter| == |filter_|, set |filter_| to nullptr. It ensures no matter
+ // whether LostFocus or GotFocus is fired first, we can always get the latest
+ // active filter.
+ void erase(const KeyEventFilter* filter);
+ KeyEventFilter* get() const;
+
+ private:
+ KeyEventFilter* filter_ = nullptr;
+ base::ThreadChecker thread_checker_;
+};
+
+} // namespace keyboard_lock
+
+#endif // COMPONENTS_KEYBOARD_LOCK_ACTIVE_KEY_EVENT_FILTER_TRACKER_H_

Powered by Google App Engine
This is Rietveld 408576698