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

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

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 #include "ash/mus/accelerators/accelerator_registrar_impl.h" 5 #include "ash/mus/accelerators/accelerator_registrar_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/common/accelerators/accelerator_controller.h" 10 #include "ash/common/accelerators/accelerator_controller.h"
11 #include "ash/common/wm_shell.h" 11 #include "ash/common/wm_shell.h"
12 #include "ash/mus/accelerators/accelerator_ids.h" 12 #include "ash/mus/accelerators/accelerator_ids.h"
13 #include "ash/mus/root_window_controller.h" 13 #include "ash/mus/root_window_controller.h"
14 #include "ash/mus/window_manager.h" 14 #include "ash/mus/window_manager.h"
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "services/ui/public/cpp/window_manager_delegate.h" 16 #include "services/ui/public/cpp/window_manager_delegate.h"
17 #include "ui/events/event.h" 17 #include "ui/events/event.h"
18 18
19 namespace ash { 19 namespace ash {
20 namespace mus { 20 namespace mus {
21 21
22 namespace { 22 namespace {
23 23
24 void CallAddAcceleratorCallback( 24 void CallAddAcceleratorCallback(
25 const ::ui::mojom::AcceleratorRegistrar::AddAcceleratorCallback& callback, 25 const ui::mojom::AcceleratorRegistrar::AddAcceleratorCallback& callback,
26 bool result) { 26 bool result) {
27 callback.Run(result); 27 callback.Run(result);
28 } 28 }
29 29
30 // Returns true if |event_matcher| corresponds to matching an Accelerator. 30 // Returns true if |event_matcher| corresponds to matching an Accelerator.
31 bool IsMatcherForKeyAccelerator(const ui::mojom::EventMatcher& event_matcher) { 31 bool IsMatcherForKeyAccelerator(const ui::mojom::EventMatcher& event_matcher) {
32 return ( 32 return (
33 event_matcher.accelerator_phase == 33 event_matcher.accelerator_phase ==
34 ui::mojom::AcceleratorPhase::PRE_TARGET && 34 ui::mojom::AcceleratorPhase::PRE_TARGET &&
35 event_matcher.type_matcher && 35 event_matcher.type_matcher &&
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 WmShell::Get()->accelerator_controller()->UnregisterAll(this); 123 WmShell::Get()->accelerator_controller()->UnregisterAll(this);
124 keyboard_accelerator_to_id_.clear(); 124 keyboard_accelerator_to_id_.clear();
125 id_to_keyboard_accelerator_.clear(); 125 id_to_keyboard_accelerator_.clear();
126 126
127 accelerators_.clear(); 127 accelerators_.clear();
128 } 128 }
129 129
130 bool AcceleratorRegistrarImpl::AddAcceleratorForKeyBinding( 130 bool AcceleratorRegistrarImpl::AddAcceleratorForKeyBinding(
131 uint32_t accelerator_id, 131 uint32_t accelerator_id,
132 const ::ui::mojom::EventMatcher& matcher, 132 const ui::mojom::EventMatcher& matcher,
133 const AddAcceleratorCallback& callback) { 133 const AddAcceleratorCallback& callback) {
134 if (!IsMatcherForKeyAccelerator(matcher)) 134 if (!IsMatcherForKeyAccelerator(matcher))
135 return false; 135 return false;
136 136
137 const ui::Accelerator accelerator = EventMatcherToAccelerator(matcher); 137 const ui::Accelerator accelerator = EventMatcherToAccelerator(matcher);
138 if (keyboard_accelerator_to_id_.count(accelerator)) { 138 if (keyboard_accelerator_to_id_.count(accelerator)) {
139 callback.Run(false); 139 callback.Run(false);
140 return true; 140 return true;
141 } 141 }
142 142
(...skipping 13 matching lines...) Expand all
156 156
157 const uint16_t local_id = GetAcceleratorLocalId(accelerator_id); 157 const uint16_t local_id = GetAcceleratorLocalId(accelerator_id);
158 keyboard_accelerator_to_id_[accelerator] = local_id; 158 keyboard_accelerator_to_id_[accelerator] = local_id;
159 id_to_keyboard_accelerator_[local_id] = accelerator; 159 id_to_keyboard_accelerator_[local_id] = accelerator;
160 accelerator_controller->Register(accelerator, this); 160 accelerator_controller->Register(accelerator, this);
161 callback.Run(true); 161 callback.Run(true);
162 return true; 162 return true;
163 } 163 }
164 164
165 void AcceleratorRegistrarImpl::SetHandler( 165 void AcceleratorRegistrarImpl::SetHandler(
166 ::ui::mojom::AcceleratorHandlerPtr handler) { 166 ui::mojom::AcceleratorHandlerPtr handler) {
167 accelerator_handler_ = std::move(handler); 167 accelerator_handler_ = std::move(handler);
168 accelerator_handler_.set_connection_error_handler(base::Bind( 168 accelerator_handler_.set_connection_error_handler(base::Bind(
169 &AcceleratorRegistrarImpl::OnHandlerGone, base::Unretained(this))); 169 &AcceleratorRegistrarImpl::OnHandlerGone, base::Unretained(this)));
170 } 170 }
171 171
172 void AcceleratorRegistrarImpl::AddAccelerator( 172 void AcceleratorRegistrarImpl::AddAccelerator(
173 uint32_t accelerator_id, 173 uint32_t accelerator_id,
174 ::ui::mojom::EventMatcherPtr matcher, 174 ui::mojom::EventMatcherPtr matcher,
175 const AddAcceleratorCallback& callback) { 175 const AddAcceleratorCallback& callback) {
176 if (!accelerator_handler_ || accelerator_id > 0xFFFF) { 176 if (!accelerator_handler_ || accelerator_id > 0xFFFF) {
177 // The |accelerator_id| is too large, and it can't be handled correctly. 177 // The |accelerator_id| is too large, and it can't be handled correctly.
178 callback.Run(false); 178 callback.Run(false);
179 DVLOG(1) << "AddAccelerator failed because of bogus id"; 179 DVLOG(1) << "AddAccelerator failed because of bogus id";
180 return; 180 return;
181 } 181 }
182 182
183 uint32_t namespaced_accelerator_id = ComputeAcceleratorId( 183 uint32_t namespaced_accelerator_id = ComputeAcceleratorId(
184 accelerator_namespace_, static_cast<uint16_t>(accelerator_id)); 184 accelerator_namespace_, static_cast<uint16_t>(accelerator_id));
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 ui::Event::Clone(key_event)); 254 ui::Event::Clone(key_event));
255 return true; 255 return true;
256 } 256 }
257 257
258 bool AcceleratorRegistrarImpl::CanHandleAccelerators() const { 258 bool AcceleratorRegistrarImpl::CanHandleAccelerators() const {
259 return true; 259 return true;
260 } 260 }
261 261
262 } // namespace mus 262 } // namespace mus
263 } // namespace ash 263 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/accelerators/accelerator_registrar_impl.h ('k') | ash/mus/accelerators/accelerator_registrar_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698