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 #include "components/keyboard_lock/key_hook_activator_collection.h" |
| 6 |
| 7 #include <utility> |
| 8 |
| 9 namespace keyboard_lock { |
| 10 |
| 11 KeyHookActivatorCollection::KeyHookActivatorCollection() = default; |
| 12 KeyHookActivatorCollection::~KeyHookActivatorCollection() = default; |
| 13 |
| 14 KeyHookActivator* KeyHookActivatorCollection::Find( |
| 15 const content::WebContents* contents) const { |
| 16 DCHECK(thread_checker_.CalledOnValidThread()); |
| 17 auto it = activators_.find(contents); |
| 18 if (it == activators_.end()) { |
| 19 return nullptr; |
| 20 } |
| 21 return it->second.get(); |
| 22 } |
| 23 |
| 24 void KeyHookActivatorCollection::Insert( |
| 25 const content::WebContents* contents, |
| 26 std::unique_ptr<KeyHookActivator> key_hook) { |
| 27 DCHECK(thread_checker_.CalledOnValidThread()); |
| 28 auto result = activators_.insert( |
| 29 std::make_pair(contents, std::move(key_hook))); |
| 30 DCHECK(result.second); |
| 31 } |
| 32 |
| 33 void KeyHookActivatorCollection::Erase(const content::WebContents* contents) { |
| 34 DCHECK(thread_checker_.CalledOnValidThread()); |
| 35 activators_.erase(contents); |
| 36 } |
| 37 |
| 38 } // namespace keyboard_lock |
OLD | NEW |