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

Side by Side 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 unified diff | Download patch
OLDNEW
(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_KEY_HOOK_ACTIVATOR_COLLECTION_H_
6 #define COMPONENTS_KEYBOARD_LOCK_KEY_HOOK_ACTIVATOR_COLLECTION_H_
7
8 #include <map>
9 #include <memory>
10
11 #include "base/threading/thread_checker.h"
12 #include "components/keyboard_lock/key_hook_activator.h"
13
14 namespace content {
15 class WebContents;
16 } // namespace content
17
18 namespace keyboard_lock {
19
20 class KeyHookActivator;
21
22 // A collection of KeyHookActivator instances.
23 // All the public functions can only be called in one thread.
24 class KeyHookActivatorCollection final {
25 public:
26 KeyHookActivatorCollection();
27 ~KeyHookActivatorCollection();
28
29 // Returning a nullptr if no KeyHookActivator has been registered for
30 // |contents|.
31 KeyHookActivator* Find(const content::WebContents* contents) const;
32
33 void Insert(const content::WebContents* contents,
34 std::unique_ptr<KeyHookActivator> key_hook);
35
36 // Do nothing if |contents| is not found in the collection: web page may call
37 // cancelKeyboardLock() without calling requestKeyboardLock() before.
38 void Erase(const content::WebContents* contents);
39
40 private:
41 // GUARDED_BY(thread_checker_)
42 std::map<const content::WebContents*, std::unique_ptr<KeyHookActivator>>
43 activators_;
44
45 // Ensures |activators_| is only accessed in |runner_| thread.
46 base::ThreadChecker thread_checker_;
47 };
48
49 } // namespace keyboard_lock
50
51 #endif // COMPONENTS_KEYBOARD_LOCK_KEY_HOOK_ACTIVATOR_COLLECTION_H_
OLDNEW
« 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