Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 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 UI_EVENTS_SCOPED_TARGET_HANDLER_H_ | |
| 6 #define UI_EVENTS_SCOPED_TARGET_HANDLER_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "ui/events/events_export.h" | |
| 10 | |
| 11 namespace ui { | |
| 12 | |
| 13 class EventHandler; | |
| 14 class EventTarget; | |
| 15 | |
|
bruthig
2015/11/19 16:49:53
Some class level documentation would be useful her
varkha
2015/11/19 23:34:35
Done.
| |
| 16 class EVENTS_EXPORT ScopedTargetHandler { | |
|
bruthig
2015/11/19 16:49:53
I envisioned that ScopedTargetHandler (or general
varkha
2015/11/19 23:34:35
Done.
| |
| 17 public: | |
| 18 ScopedTargetHandler(EventTarget* target, EventHandler* handler); | |
| 19 virtual ~ScopedTargetHandler(); | |
| 20 | |
| 21 EventHandler* original_target_handler() { return original_handler_; } | |
| 22 | |
| 23 private: | |
| 24 // An EventTarget that is used to set and restore |original_handler_|. | |
| 25 EventTarget* target_; | |
| 26 | |
| 27 // New handler that is set on |target_| for the lifetime of |this|. | |
| 28 EventHandler* handler_; | |
| 29 | |
| 30 // An EventHandler that gets restored on |target_| when |this| is destroyed. | |
| 31 EventHandler* original_handler_; | |
| 32 | |
| 33 DISALLOW_COPY_AND_ASSIGN(ScopedTargetHandler); | |
| 34 }; | |
| 35 | |
| 36 } // namespace ui | |
| 37 | |
| 38 #endif // UI_EVENTS_SCOPED_TARGET_HANDLER_H_ | |
| OLD | NEW |