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

Unified Diff: components/keyboard_lock/key_hook_activator_collection.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/key_hook_activator_collection.h
diff --git a/components/keyboard_lock/key_hook_activator_collection.h b/components/keyboard_lock/key_hook_activator_collection.h
new file mode 100644
index 0000000000000000000000000000000000000000..c33ecd2c97555605fbd5727f514b7cd74d428ff5
--- /dev/null
+++ b/components/keyboard_lock/key_hook_activator_collection.h
@@ -0,0 +1,51 @@
+// 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_KEY_HOOK_ACTIVATOR_COLLECTION_H_
+#define COMPONENTS_KEYBOARD_LOCK_KEY_HOOK_ACTIVATOR_COLLECTION_H_
+
+#include <map>
+#include <memory>
+
+#include "base/threading/thread_checker.h"
+#include "components/keyboard_lock/key_hook_activator.h"
+
+namespace content {
+class WebContents;
+} // namespace content
+
+namespace keyboard_lock {
+
+class KeyHookActivator;
+
+// A collection of KeyHookActivator instances.
+// All the public functions can only be called in one thread.
+class KeyHookActivatorCollection final {
+ public:
+ KeyHookActivatorCollection();
+ ~KeyHookActivatorCollection();
+
+ // Returning a nullptr if no KeyHookActivator has been registered for
+ // |contents|.
+ KeyHookActivator* Find(const content::WebContents* contents) const;
+
+ void Insert(const content::WebContents* contents,
+ std::unique_ptr<KeyHookActivator> key_hook);
+
+ // Do nothing if |contents| is not found in the collection: web page may call
+ // cancelKeyboardLock() without calling requestKeyboardLock() before.
+ void Erase(const content::WebContents* contents);
+
+ private:
+ // GUARDED_BY(thread_checker_)
+ std::map<const content::WebContents*, std::unique_ptr<KeyHookActivator>>
+ activators_;
+
+ // Ensures |activators_| is only accessed in |runner_| thread.
+ base::ThreadChecker thread_checker_;
+};
+
+} // namespace keyboard_lock
+
+#endif // COMPONENTS_KEYBOARD_LOCK_KEY_HOOK_ACTIVATOR_COLLECTION_H_
« no previous file with comments | « components/keyboard_lock/key_hook_activator.h ('k') | components/keyboard_lock/key_hook_activator_collection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698