Chromium Code Reviews| Index: services/ui/ws/window_tree.cc |
| diff --git a/services/ui/ws/window_tree.cc b/services/ui/ws/window_tree.cc |
| index 8a62bdd534534c4c4b111647511e306071068afe..f4d798fd051fd8385b9864bb4c03cdebf16c7261 100644 |
| --- a/services/ui/ws/window_tree.cc |
| +++ b/services/ui/ws/window_tree.cc |
| @@ -1165,20 +1165,35 @@ void WindowTree::SetEventObserver(mojom::EventMatcherPtr matcher, |
| // Do not allow key events to be observed, as a compromised app could register |
| // itself as an event observer and spy on keystrokes to another app. |
| - if (!matcher->type_matcher) { |
| + if (!matcher->type_matcher && !matcher->pointer_kind_matcher) { |
| DVLOG(1) << "SetEventObserver must specify an event type."; |
| return; |
| } |
| + |
| const ui::mojom::EventType event_type_whitelist[] = { |
| ui::mojom::EventType::POINTER_CANCEL, ui::mojom::EventType::POINTER_DOWN, |
| ui::mojom::EventType::POINTER_MOVE, ui::mojom::EventType::POINTER_UP, |
| ui::mojom::EventType::MOUSE_EXIT, ui::mojom::EventType::WHEEL, |
| }; |
| + const ui::mojom::PointerKind pointer_kind_whitelist[] = { |
| + ui::mojom::PointerKind::MOUSE, ui::mojom::PointerKind::TOUCH, |
| + }; |
| + |
| bool allowed = false; |
| - for (ui::mojom::EventType event_type : event_type_whitelist) { |
| - if (matcher->type_matcher->type == event_type) { |
| - allowed = true; |
| - break; |
| + if (matcher->type_matcher) { |
| + for (ui::mojom::EventType event_type : event_type_whitelist) { |
|
sadrul
2016/07/11 20:47:51
Can you use std::find instead?
if (matcher->type
riajiang
2016/07/11 21:51:40
Done.
|
| + if (matcher->type_matcher->type == event_type) { |
| + allowed = true; |
| + break; |
| + } |
| + } |
| + } |
| + if (matcher->pointer_kind_matcher) { |
| + for (ui::mojom::PointerKind pointer : pointer_kind_whitelist) { |
| + if (matcher->pointer_kind_matcher->pointer_kind == pointer) { |
| + allowed = true; |
| + break; |
| + } |
| } |
|
sadrul
2016/07/11 20:47:52
ditto
riajiang
2016/07/11 21:51:40
Done.
|
| } |
| if (!allowed) { |