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

Unified Diff: components/keyboard_lock/key_hook_activator_collection.cc

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.cc
diff --git a/components/keyboard_lock/key_hook_activator_collection.cc b/components/keyboard_lock/key_hook_activator_collection.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f677860d3ab89faee00fe57138be7e0fbd34916f
--- /dev/null
+++ b/components/keyboard_lock/key_hook_activator_collection.cc
@@ -0,0 +1,38 @@
+// 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.
+
+#include "components/keyboard_lock/key_hook_activator_collection.h"
+
+#include <utility>
+
+namespace keyboard_lock {
+
+KeyHookActivatorCollection::KeyHookActivatorCollection() = default;
+KeyHookActivatorCollection::~KeyHookActivatorCollection() = default;
+
+KeyHookActivator* KeyHookActivatorCollection::Find(
+ const content::WebContents* contents) const {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ auto it = activators_.find(contents);
+ if (it == activators_.end()) {
+ return nullptr;
+ }
+ return it->second.get();
+}
+
+void KeyHookActivatorCollection::Insert(
+ const content::WebContents* contents,
+ std::unique_ptr<KeyHookActivator> key_hook) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ auto result = activators_.insert(
+ std::make_pair(contents, std::move(key_hook)));
+ DCHECK(result.second);
+}
+
+void KeyHookActivatorCollection::Erase(const content::WebContents* contents) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ activators_.erase(contents);
+}
+
+} // namespace keyboard_lock
« no previous file with comments | « components/keyboard_lock/key_hook_activator_collection.h ('k') | components/keyboard_lock/key_hook_activator_thread_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698