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

Unified Diff: services/ui/ws/event_dispatcher.cc

Issue 2520093003: WindowManagerClient::AddAccelerator() should take an array (Closed)
Patch Set: Forget to add these files to previous patch. Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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..56e816eed9097227b8820fe37765bbfc3eadb42c 100644
--- a/services/ui/ws/event_dispatcher.cc
+++ b/services/ui/ws/event_dispatcher.cc
@@ -244,16 +244,27 @@ 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.
mfomitchev 2016/11/22 22:44:16 Update the comment, but don't remove it please
- for (const auto& pair : accelerators_) {
- if (pair.first == id || accelerator->EqualEventMatcher(pair.second.get()))
- return false;
+bool EventDispatcher::AddAccelerator(
+ mojo::Array<ui::mojom::AcceleratorEventPtr> multi_accelerators) {
+ for (auto iter = multi_accelerators.begin(); iter != multi_accelerators.end();
+ ++iter) {
+ std::unique_ptr<Accelerator> accelerator(
+ new Accelerator(iter->get()->id, *(iter->get()->event_matcher)));
+
+ bool does_accelerator_exist = false;
mfomitchev 2016/11/22 22:44:16 accelerator_exists
thanhph 2016/11/24 16:10:13 Done.
+ for (const auto& pair : accelerators_)
mfomitchev 2016/11/22 22:44:16 You need braces for multi-line body
thanhph 2016/11/24 16:10:13 Done, thanks!
+ if (pair.first == iter->get()->id ||
+ accelerator->EqualEventMatcher(pair.second.get())) {
+ does_accelerator_exist = true;
+ break;
+ }
+
+ if (!does_accelerator_exist) {
+ accelerators_.insert(Entry(iter->get()->id, std::move(accelerator)));
+ return true;
mfomitchev 2016/11/22 22:44:16 This is a bit too early to return - you've just in
thanhph 2016/11/24 16:10:13 Done, thanks!
+ }
}
- accelerators_.insert(Entry(id, std::move(accelerator)));
- return true;
+ return false;
}
void EventDispatcher::RemoveAccelerator(uint32_t id) {

Powered by Google App Engine
This is Rietveld 408576698