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

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

Issue 2762233004: Fix autofill popup controller key press callback registration (Closed)
Patch Set: Fixed browsertests 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.cc
diff --git a/components/autofill/content/browser/key_press_handler_manager.cc b/components/autofill/content/browser/key_press_handler_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..db4c2387685363b43c4fcf1a66f32505758637ee
--- /dev/null
+++ b/components/autofill/content/browser/key_press_handler_manager.cc
@@ -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.
+
+#include "components/autofill/content/browser/key_press_handler_manager.h"
+
+namespace autofill {
+
+KeyPressHandlerManager::KeyPressHandlerManager(Delegate* delegate)
+ : delegate_(delegate) {}
+
+KeyPressHandlerManager::~KeyPressHandlerManager() = default;
+
+void KeyPressHandlerManager::RegisterKeyPressHandler(
+ const content::RenderWidgetHost::KeyPressEventCallback& handler) {
+ // It would have been nice to be able to tell if two callbacks are just the
+ // same function with the same bound arguments. That's not Equals() does (they
Mathieu 2017/04/05 18:58:21 *what Equals() does
vabr (Chromium) 2017/04/06 05:39:58 Done.
+ // have to have the same BindState), but it's the closest approximation
+ // available.
+ if (handler.is_null() || handler.Equals(handler_))
+ return;
+
+ if (!handler_.is_null())
+ delegate_->RemoveHandler(handler_);
+ handler_ = handler;
+ delegate_->AddHandler(handler_);
+}
+
+void KeyPressHandlerManager::RemoveKeyPressHandler() {
+ if (handler_.is_null())
+ return;
+
+ delegate_->RemoveHandler(handler_);
+ handler_.Reset();
+}
+
+} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698