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

Side by Side Diff: components/keyboard_lock/register_once_key_hook.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 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 #include "components/keyboard_lock/register_once_key_hook.h"
6
7 namespace keyboard_lock {
8
9 RegisterOnceKeyHook::RegisterOnceKeyHook() = default;
10 RegisterOnceKeyHook::~RegisterOnceKeyHook() = default;
11
12 bool RegisterOnceKeyHook::RegisterKey(
13 const std::vector<ui::KeyboardCode>& codes) {
14 bool result = false;
15 if (count_ == 0) {
16 result = Register();
17 } else {
18 result = true;
19 }
20 count_ += codes.size();
21 return result;
22 }
23
24 bool RegisterOnceKeyHook::UnregisterKey(
25 const std::vector<ui::KeyboardCode>& codes) {
26 bool result = false;
27 if (count_ <= static_cast<int>(codes.size())) {
28 result = Unregister();
29 count_ = 0;
30 } else {
31 result = true;
32 count_ -= codes.size();
33 }
34 return result;
35 }
36
37 } // namespace keyboard_lock
OLDNEW
« no previous file with comments | « components/keyboard_lock/register_once_key_hook.h ('k') | components/keyboard_lock/sync_key_hook.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698