| Index: services/ui/ws/event_dispatcher.cc
|
| diff --git a/services/ui/ws/event_dispatcher.cc b/services/ui/ws/event_dispatcher.cc
|
| index d6536cc9c8c5f50dd0a89caa1f0adcf42e9ded33..854d2a5aeb1b2f90697d92e210eba65ec410dda9 100644
|
| --- a/services/ui/ws/event_dispatcher.cc
|
| +++ b/services/ui/ws/event_dispatcher.cc
|
| @@ -244,16 +244,28 @@ void EventDispatcher::UpdateCursorProviderByLastKnownLocation() {
|
| }
|
| }
|
|
|
| -bool EventDispatcher::AddAccelerator(uint32_t id,
|
| - mojom::EventMatcherPtr event_matcher) {
|
| - std::unique_ptr<Accelerator> accelerator(new Accelerator(id, *event_matcher));
|
| - // If an accelerator with the same id or matcher already exists, then abort.
|
| - for (const auto& pair : accelerators_) {
|
| - if (pair.first == id || accelerator->EqualEventMatcher(pair.second.get()))
|
| - return false;
|
| +bool EventDispatcher::AddAccelerators(
|
| + std::vector<ui::mojom::AcceleratorPtr> accelerators) {
|
| + bool all_new_accelerators = true;
|
| + for (auto iter = accelerators.begin(); iter != accelerators.end(); ++iter) {
|
| + std::unique_ptr<Accelerator> accelerator(
|
| + new Accelerator(iter->get()->id, *(iter->get()->event_matcher)));
|
| +
|
| + // If an accelerator with the same id or matcher already exists, skip it.
|
| + bool accelerator_exists = false;
|
| + for (const auto& pair : accelerators_) {
|
| + if (pair.first == iter->get()->id ||
|
| + accelerator->EqualEventMatcher(pair.second.get())) {
|
| + accelerator_exists = true;
|
| + break;
|
| + }
|
| + }
|
| + if (accelerator_exists)
|
| + all_new_accelerators = false;
|
| + else
|
| + accelerators_.insert(Entry(iter->get()->id, std::move(accelerator)));
|
| }
|
| - accelerators_.insert(Entry(id, std::move(accelerator)));
|
| - return true;
|
| + return all_new_accelerators;
|
| }
|
|
|
| void EventDispatcher::RemoveAccelerator(uint32_t id) {
|
|
|