1 // Copyright 2014 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.
5 #ifndef CHROME_BROWSER_CHROMEOS_EVENTS_EVENT_REWRITER_CONTROLLER_H_
6 #define CHROME_BROWSER_CHROMEOS_EVENTS_EVENT_REWRITER_CONTROLLER_H_
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h"
13 #include "ui/aura/env_observer.h"
14 #include "ui/events/event_rewriter.h"
22 // Owns |ui::EventRewriter|s and ensures that they are added to all root
23 // windows |EventSource|s, current and future, in the order that they are
25 class EventRewriterController
: public aura::EnvObserver
{
27 EventRewriterController();
28 ~EventRewriterController() override
;
30 // Takes ownership of an EventRewriter; can only be called before Init().
31 void AddEventRewriter(scoped_ptr
<ui::EventRewriter
> rewriter
);
33 // Add rewriters to any existing root windows; must be called once only
34 // after ash::Shell has been initialized.
37 // aura::EnvObserver overrides:
38 void OnWindowInitialized(aura::Window
* window
) override
{}
39 void OnHostInitialized(aura::WindowTreeHost
* host
) override
;
42 typedef std::list
<ui::EventSource
*> EventSourceList
;
43 typedef ScopedVector
<ui::EventRewriter
> EventRewriters
;
45 void AddToEventSource(ui::EventSource
* source
);
47 // The |EventRewriter|s managed by this controller.
48 EventRewriters rewriters_
;
50 // Whether the owned event rewriters have been added to existing
51 // root windows; after this no more rewriters can be added.
54 DISALLOW_COPY_AND_ASSIGN(EventRewriterController
);
57 } // namespace chromeos
59 #endif // CHROME_BROWSER_CHROMEOS_EVENTS_EVENT_REWRITER_CONTROLLER_H_