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

Unified Diff: components/autofill/content/browser/key_press_handler_manager.h

Issue 2762233004: Fix autofill popup controller key press callback registration (Closed)
Patch Set: Fix typo 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/autofill/content/browser/key_press_handler_manager.h
diff --git a/components/autofill/content/browser/key_press_handler_manager.h b/components/autofill/content/browser/key_press_handler_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..916ca9df3bb92b7fa8a20242350d78a64e4f53b6
--- /dev/null
+++ b/components/autofill/content/browser/key_press_handler_manager.h
@@ -0,0 +1,47 @@
+// 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_AUTOFILL_CONTENT_BROWSER_KEY_PRESS_HANDLER_MANAGER_H_
+#define COMPONENTS_AUTOFILL_CONTENT_BROWSER_KEY_PRESS_HANDLER_MANAGER_H_
+
+#include "base/macros.h"
+#include "content/public/browser/render_widget_host.h"
+
+namespace autofill {
+
+// KeyPressHandlerManager allows registering a key press handler and ensuring
+// its unregistering in case of destruction of the manager or request for
+// registration of another handler. It still needs a Delegate implementation to
+// use the low-level handler registration API.
+
+class KeyPressHandlerManager {
+ public:
+ class Delegate {
+ public:
+ virtual void AddHandler(
+ const content::RenderWidgetHost::KeyPressEventCallback& handler) = 0;
+ virtual void RemoveHandler(
+ const content::RenderWidgetHost::KeyPressEventCallback& handler) = 0;
+ };
+
+ explicit KeyPressHandlerManager(Delegate* delegate);
+
+ virtual ~KeyPressHandlerManager();
+
+ void RegisterKeyPressHandler(
+ const content::RenderWidgetHost::KeyPressEventCallback& handler);
+
+ void RemoveKeyPressHandler(); // Unregisters previous handler.
+
+ private:
+ Delegate* const delegate_;
+
+ content::RenderWidgetHost::KeyPressEventCallback handler_;
+
+ DISALLOW_COPY_AND_ASSIGN(KeyPressHandlerManager);
+};
+
+} // namespace autofill
+
+#endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_KEY_PRESS_HANDLER_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698