Include all dupe types (event when value is zero) in scan stats.
[chromium-blink-merge.git] / components / view_manager / event_dispatcher.h
blob9716f06b492d026cdd7d8aeaf99ba55d6ecfbf86
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.
5 #ifndef COMPONENTS_VIEW_MANAGER_EVENT_DISPATCHER_H_
6 #define COMPONENTS_VIEW_MANAGER_EVENT_DISPATCHER_H_
8 #include <set>
10 #include "base/basictypes.h"
11 #include "components/view_manager/public/interfaces/native_viewport.mojom.h"
13 namespace view_manager {
15 class ConnectionManager;
17 // Handles dispatching events to the right location as well as updating focus.
18 class EventDispatcher : public mojo::NativeViewportEventDispatcher {
19 public:
20 explicit EventDispatcher(ConnectionManager* connection_manager);
21 ~EventDispatcher() override;
23 void AddAccelerator(mojo::KeyboardCode keyboard_code, mojo::EventFlags flags);
24 void RemoveAccelerator(mojo::KeyboardCode keyboard_code,
25 mojo::EventFlags flags);
27 // NativeViewportEventDispatcher:
28 void OnEvent(mojo::EventPtr event, const OnEventCallback& callback) override;
30 private:
31 struct Accelerator {
32 Accelerator(mojo::KeyboardCode keyboard_code, mojo::EventFlags flags)
33 : keyboard_code(keyboard_code), flags(flags) {}
35 // So we can use this in a set.
36 bool operator<(const Accelerator& other) const {
37 if (keyboard_code == other.keyboard_code)
38 return flags < other.flags;
39 return keyboard_code < other.keyboard_code;
42 mojo::KeyboardCode keyboard_code;
43 mojo::EventFlags flags;
46 ConnectionManager* connection_manager_;
48 std::set<Accelerator> accelerators_;
50 DISALLOW_COPY_AND_ASSIGN(EventDispatcher);
53 } // namespace view_manager
55 #endif // COMPONENTS_VIEW_MANAGER_EVENT_DISPATCHER_H_