Chromium Code Reviews| Index: ui/events/scoped_target_handler.h |
| diff --git a/ui/events/scoped_target_handler.h b/ui/events/scoped_target_handler.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..48913b1c8e80e10813999156be1b862805740845 |
| --- /dev/null |
| +++ b/ui/events/scoped_target_handler.h |
| @@ -0,0 +1,38 @@ |
| +// Copyright 2015 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 UI_EVENTS_SCOPED_TARGET_HANDLER_H_ |
| +#define UI_EVENTS_SCOPED_TARGET_HANDLER_H_ |
| + |
| +#include "base/macros.h" |
| +#include "ui/events/events_export.h" |
| + |
| +namespace ui { |
| + |
| +class EventHandler; |
| +class EventTarget; |
| + |
|
bruthig
2015/11/19 16:49:53
Some class level documentation would be useful her
varkha
2015/11/19 23:34:35
Done.
|
| +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.
|
| + public: |
| + ScopedTargetHandler(EventTarget* target, EventHandler* handler); |
| + virtual ~ScopedTargetHandler(); |
| + |
| + EventHandler* original_target_handler() { return original_handler_; } |
| + |
| + private: |
| + // An EventTarget that is used to set and restore |original_handler_|. |
| + EventTarget* target_; |
| + |
| + // New handler that is set on |target_| for the lifetime of |this|. |
| + EventHandler* handler_; |
| + |
| + // An EventHandler that gets restored on |target_| when |this| is destroyed. |
| + EventHandler* original_handler_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ScopedTargetHandler); |
| +}; |
| + |
| +} // namespace ui |
| + |
| +#endif // UI_EVENTS_SCOPED_TARGET_HANDLER_H_ |