Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: ash/mus/accelerators/accelerator_registrar_impl.h

Issue 2182633011: Replaces ::ui:: with ui:: in ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ASH_MUS_ACCELERATORS_ACCELERATOR_REGISTRAR_IMPL_H_ 5 #ifndef ASH_MUS_ACCELERATORS_ACCELERATOR_REGISTRAR_IMPL_H_
6 #define ASH_MUS_ACCELERATORS_ACCELERATOR_REGISTRAR_IMPL_H_ 6 #define ASH_MUS_ACCELERATORS_ACCELERATOR_REGISTRAR_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 11
12 #include "ash/mus/accelerators/accelerator_handler.h" 12 #include "ash/mus/accelerators/accelerator_handler.h"
13 #include "ash/mus/window_manager_observer.h" 13 #include "ash/mus/window_manager_observer.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "mojo/public/cpp/bindings/binding_set.h" 16 #include "mojo/public/cpp/bindings/binding_set.h"
17 #include "mojo/public/cpp/bindings/strong_binding.h" 17 #include "mojo/public/cpp/bindings/strong_binding.h"
18 #include "services/ui/public/interfaces/accelerator_registrar.mojom.h" 18 #include "services/ui/public/interfaces/accelerator_registrar.mojom.h"
19 #include "ui/base/accelerators/accelerator.h" 19 #include "ui/base/accelerators/accelerator.h"
20 20
21 namespace ash { 21 namespace ash {
22 namespace mus { 22 namespace mus {
23 23
24 class WindowManager; 24 class WindowManager;
25 25
26 // Manages AcceleratorHandlers from a particular AcceleratorRegistrar 26 // Manages AcceleratorHandlers from a particular AcceleratorRegistrar
27 // connection. This manages its own lifetime, and destroys itself when the 27 // connection. This manages its own lifetime, and destroys itself when the
28 // AcceleratorRegistrar and all its AcceleratorHandlers are disconnected. Upon 28 // AcceleratorRegistrar and all its AcceleratorHandlers are disconnected. Upon
29 // destruction, it calls the DestroyCallback. 29 // destruction, it calls the DestroyCallback.
30 class AcceleratorRegistrarImpl : public ::ui::mojom::AcceleratorRegistrar, 30 class AcceleratorRegistrarImpl : public ui::mojom::AcceleratorRegistrar,
31 public WindowManagerObserver, 31 public WindowManagerObserver,
32 public AcceleratorHandler, 32 public AcceleratorHandler,
33 public ui::AcceleratorTarget { 33 public ui::AcceleratorTarget {
34 public: 34 public:
35 using DestroyCallback = base::Callback<void(AcceleratorRegistrarImpl*)>; 35 using DestroyCallback = base::Callback<void(AcceleratorRegistrarImpl*)>;
36 AcceleratorRegistrarImpl(WindowManager* window_manager, 36 AcceleratorRegistrarImpl(WindowManager* window_manager,
37 uint16_t accelerator_namespace, 37 uint16_t accelerator_namespace,
38 mojo::InterfaceRequest<AcceleratorRegistrar> request, 38 mojo::InterfaceRequest<AcceleratorRegistrar> request,
39 const DestroyCallback& destroy_callback); 39 const DestroyCallback& destroy_callback);
40 40
41 void Destroy(); 41 void Destroy();
42 42
43 // Returns true if this AcceleratorRegistrar has an accelerator with the 43 // Returns true if this AcceleratorRegistrar has an accelerator with the
44 // specified id. 44 // specified id.
45 bool OwnsAccelerator(uint32_t accelerator_id) const; 45 bool OwnsAccelerator(uint32_t accelerator_id) const;
46 46
47 void ProcessAccelerator(uint32_t accelerator_id, const ui::Event& event); 47 void ProcessAccelerator(uint32_t accelerator_id, const ui::Event& event);
48 48
49 private: 49 private:
50 ~AcceleratorRegistrarImpl() override; 50 ~AcceleratorRegistrarImpl() override;
51 51
52 void OnBindingGone(); 52 void OnBindingGone();
53 void OnHandlerGone(); 53 void OnHandlerGone();
54 54
55 void RemoveAllAccelerators(); 55 void RemoveAllAccelerators();
56 56
57 // If |matcher| identifies a key-binding accelerator registers it and 57 // If |matcher| identifies a key-binding accelerator registers it and
58 // returns true, returns false otherwise. 58 // returns true, returns false otherwise.
59 bool AddAcceleratorForKeyBinding(uint32_t accelerator_id, 59 bool AddAcceleratorForKeyBinding(uint32_t accelerator_id,
60 const ::ui::mojom::EventMatcher& matcher, 60 const ui::mojom::EventMatcher& matcher,
61 const AddAcceleratorCallback& callback); 61 const AddAcceleratorCallback& callback);
62 62
63 // ::ui::mojom::AcceleratorRegistrar: 63 // ui::mojom::AcceleratorRegistrar:
64 void SetHandler(::ui::mojom::AcceleratorHandlerPtr handler) override; 64 void SetHandler(ui::mojom::AcceleratorHandlerPtr handler) override;
65 void AddAccelerator(uint32_t accelerator_id, 65 void AddAccelerator(uint32_t accelerator_id,
66 ::ui::mojom::EventMatcherPtr matcher, 66 ui::mojom::EventMatcherPtr matcher,
67 const AddAcceleratorCallback& callback) override; 67 const AddAcceleratorCallback& callback) override;
68 void RemoveAccelerator(uint32_t accelerator_id) override; 68 void RemoveAccelerator(uint32_t accelerator_id) override;
69 69
70 // AcceleratorHandler: 70 // AcceleratorHandler:
71 ui::mojom::EventResult OnAccelerator(uint32_t id, 71 ui::mojom::EventResult OnAccelerator(uint32_t id,
72 const ui::Event& event) override; 72 const ui::Event& event) override;
73 73
74 // WindowManagerObserver: 74 // WindowManagerObserver:
75 void OnWindowTreeClientDestroyed() override; 75 void OnWindowTreeClientDestroyed() override;
76 76
77 // AcceleratorTarget: 77 // AcceleratorTarget:
78 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; 78 bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
79 bool CanHandleAccelerators() const override; 79 bool CanHandleAccelerators() const override;
80 80
81 WindowManager* window_manager_; 81 WindowManager* window_manager_;
82 ::ui::mojom::AcceleratorHandlerPtr accelerator_handler_; 82 ui::mojom::AcceleratorHandlerPtr accelerator_handler_;
83 mojo::Binding<AcceleratorRegistrar> binding_; 83 mojo::Binding<AcceleratorRegistrar> binding_;
84 uint16_t accelerator_namespace_; 84 uint16_t accelerator_namespace_;
85 // Only contains non-keyboard accelerators. 85 // Only contains non-keyboard accelerators.
86 std::set<uint32_t> accelerators_; 86 std::set<uint32_t> accelerators_;
87 DestroyCallback destroy_callback_; 87 DestroyCallback destroy_callback_;
88 88
89 // Used only for keyboard accelerators. 89 // Used only for keyboard accelerators.
90 std::map<ui::Accelerator, uint16_t> keyboard_accelerator_to_id_; 90 std::map<ui::Accelerator, uint16_t> keyboard_accelerator_to_id_;
91 std::map<uint16_t, ui::Accelerator> id_to_keyboard_accelerator_; 91 std::map<uint16_t, ui::Accelerator> id_to_keyboard_accelerator_;
92 92
93 DISALLOW_COPY_AND_ASSIGN(AcceleratorRegistrarImpl); 93 DISALLOW_COPY_AND_ASSIGN(AcceleratorRegistrarImpl);
94 }; 94 };
95 95
96 } // namespace mus 96 } // namespace mus
97 } // namespace ash 97 } // namespace ash
98 98
99 #endif // ASH_MUS_ACCELERATORS_ACCELERATOR_REGISTRAR_IMPL_H_ 99 #endif // ASH_MUS_ACCELERATORS_ACCELERATOR_REGISTRAR_IMPL_H_
OLDNEW
« no previous file with comments | « ash/common/wm/overview/window_selector.cc ('k') | ash/mus/accelerators/accelerator_registrar_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698