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/autofill/content/browser/key_press_handler_manager.h" | |
6 | |
7 namespace autofill { | |
8 | |
9 KeyPressHandlerManager::KeyPressHandlerManager(Delegate* delegate) | |
10 : delegate_(delegate) {} | |
11 | |
12 KeyPressHandlerManager::~KeyPressHandlerManager() = default; | |
13 | |
14 void KeyPressHandlerManager::RegisterKeyPressHandler( | |
15 const content::RenderWidgetHost::KeyPressEventCallback& handler) { | |
16 // It would have been nice to be able to tell if two callbacks are just the | |
17 // 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.
| |
18 // have to have the same BindState), but it's the closest approximation | |
19 // available. | |
20 if (handler.is_null() || handler.Equals(handler_)) | |
21 return; | |
22 | |
23 if (!handler_.is_null()) | |
24 delegate_->RemoveHandler(handler_); | |
25 handler_ = handler; | |
26 delegate_->AddHandler(handler_); | |
27 } | |
28 | |
29 void KeyPressHandlerManager::RemoveKeyPressHandler() { | |
30 if (handler_.is_null()) | |
31 return; | |
32 | |
33 delegate_->RemoveHandler(handler_); | |
34 handler_.Reset(); | |
35 } | |
36 | |
37 } // namespace autofill | |
OLD | NEW |