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 #ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_KEY_PRESS_HANDLER_MANAGER_H_ |
| 6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_KEY_PRESS_HANDLER_MANAGER_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "content/public/browser/render_widget_host.h" |
| 10 |
| 11 namespace autofill { |
| 12 |
| 13 // KeyPressHandlerManager allows registering a key press handler and ensuring |
| 14 // its unregistering in case of destruction of the manager or request for |
| 15 // registration of another handler. It still needs a Delegate implementation to |
| 16 // use the low-level handler registration API. |
| 17 |
| 18 class KeyPressHandlerManager { |
| 19 public: |
| 20 class Delegate { |
| 21 public: |
| 22 virtual void AddHandler( |
| 23 const content::RenderWidgetHost::KeyPressEventCallback& handler) = 0; |
| 24 virtual void RemoveHandler( |
| 25 const content::RenderWidgetHost::KeyPressEventCallback& handler) = 0; |
| 26 }; |
| 27 |
| 28 explicit KeyPressHandlerManager(Delegate* delegate); |
| 29 |
| 30 virtual ~KeyPressHandlerManager(); |
| 31 |
| 32 void RegisterKeyPressHandler( |
| 33 const content::RenderWidgetHost::KeyPressEventCallback& handler); |
| 34 |
| 35 void RemoveKeyPressHandler(); // Unregisters previous handler. |
| 36 |
| 37 private: |
| 38 Delegate* const delegate_; |
| 39 |
| 40 content::RenderWidgetHost::KeyPressEventCallback handler_; |
| 41 |
| 42 DISALLOW_COPY_AND_ASSIGN(KeyPressHandlerManager); |
| 43 }; |
| 44 |
| 45 } // namespace autofill |
| 46 |
| 47 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_KEY_PRESS_HANDLER_MANAGER_H_ |
OLD | NEW |