Chromium Code Reviews| Index: services/ui/ws/event_dispatcher.cc |
| diff --git a/services/ui/ws/event_dispatcher.cc b/services/ui/ws/event_dispatcher.cc |
| index 18d3dafec9e8931a6c7d07153eea00cb36ce9e12..0e45b010cd3a8f500dde58a8edbb51e2a257d6bd 100644 |
| --- a/services/ui/ws/event_dispatcher.cc |
| +++ b/services/ui/ws/event_dispatcher.cc |
| @@ -252,10 +252,24 @@ void EventDispatcher::UpdateCursorProviderByLastKnownLocation() { |
| bool EventDispatcher::AddAccelerator(uint32_t id, |
| mojom::EventMatcherPtr event_matcher) { |
| std::unique_ptr<Accelerator> accelerator(new Accelerator(id, *event_matcher)); |
| + bool is_duplicate; |
|
mfomitchev
2017/01/26 16:03:36
Nit: Move the declarations below the comment.
thanhph1
2017/01/26 19:33:38
Done.
|
| + std::string error_message; |
| + |
| // 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())) |
| + if (pair.first == id) { |
| + error_message = "duplicate accelerator id."; |
|
mfomitchev
2017/01/26 16:03:36
Nit: Capitalize the first letter. Same for below e
thanhph1
2017/01/26 19:33:38
Done.
|
| + is_duplicate = true; |
| + } else if (accelerator->EqualEventMatcher(pair.second.get())) { |
| + error_message = "duplicate accelerator matcher."; |
| + is_duplicate = true; |
| + } |
| + if (is_duplicate) { |
| + DVLOG(1) << error_message << " accelerator id=" << accelerator->id() |
|
mfomitchev
2017/01/26 16:03:36
Maybe use LOG(ERROR) instead of DVLOG(1) - we prob
thanhph1
2017/01/26 19:33:38
Done.
|
| + << " type=" << event_matcher->type_matcher->type |
| + << " flags=" << event_matcher->flags_matcher->flags; |
| return false; |
| + } |
| } |
| accelerators_.insert(Entry(id, std::move(accelerator))); |
| return true; |