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

Unified Diff: components/keyboard_lock/key_event_interceptor_installer.h

Issue 2815023002: [System-Keyboard-Lock] Add KeyboardLockHost and KeyEventInterceptor (Closed)
Patch Set: More comments Created 3 years, 8 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_event_interceptor_installer.h
diff --git a/components/keyboard_lock/key_event_interceptor_installer.h b/components/keyboard_lock/key_event_interceptor_installer.h
new file mode 100644
index 0000000000000000000000000000000000000000..536c37dca5200b853c08036e52e2fc4471f9cc87
--- /dev/null
+++ b/components/keyboard_lock/key_event_interceptor_installer.h
@@ -0,0 +1,37 @@
+// 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_EVENT_INTERCEPTOR_INSTALLER_H_
+#define COMPONENTS_KEYBOARD_LOCK_KEY_EVENT_INTERCEPTOR_INSTALLER_H_
+
+#include "base/macros.h"
+#include "components/keyboard_lock/key_event_interceptor.h"
+
+namespace keyboard_lock {
+
+class KeyboardLockHost;
+
+// Installs itself as the default implementation of KeyEventInterceptor in
+// KeyboardLockHost.
+class KeyEventInterceptorInstaller : public KeyEventInterceptor {
Wez 2017/04/28 00:22:44 So this class installs itself as the current KeyEv
Hzj_jie 2017/04/28 20:02:03 Yes, but technically speaking, it won't be destruc
+ public:
+ ~KeyEventInterceptorInstaller() override;
+
+ protected:
+ // |host| should outlive this instance. The ownership of an instance of
+ // KeyEventInterceptorInstaller should be taken by KeyboardLockHost but not
+ // consumers. A typical derived class should provide a Create() function,
+ // calls Installer() function and returns a raw pointer from it.
Wez 2017/04/28 00:22:44 Why do we need this complexity? Couldn't the impl
Hzj_jie 2017/04/28 20:02:03 That's too dangerous, the setter is not accessible
+ explicit KeyEventInterceptorInstaller(KeyboardLockHost* host);
+ void Install();
+
+ private:
+ KeyboardLockHost* const host_;
+
+ DISALLOW_COPY_AND_ASSIGN(KeyEventInterceptorInstaller);
+};
+
+} // namespace keyboard_lock
+
+#endif // COMPONENTS_KEYBOARD_LOCK_KEY_EVENT_INTERCEPTOR_INSTALLER_H_

Powered by Google App Engine
This is Rietveld 408576698