Index: components/mus/ws/window_tree.cc |
diff --git a/components/mus/ws/window_tree.cc b/components/mus/ws/window_tree.cc |
index f1dc0c89db7b249f99514aadae43252bfc10b238..82b123a5ecf692d136bcd108c08471ea61ec4bf3 100644 |
--- a/components/mus/ws/window_tree.cc |
+++ b/components/mus/ws/window_tree.cc |
@@ -1156,7 +1156,7 @@ 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->types_matcher) { |
DVLOG(1) << "SetEventObserver must specify an event type."; |
return; |
} |
@@ -1166,11 +1166,24 @@ void WindowTree::SetEventObserver(mojom::EventMatcherPtr matcher, |
ui::mojom::EventType::MOUSE_EXIT, ui::mojom::EventType::WHEEL, |
}; |
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) { |
+ if (matcher->type_matcher->type == event_type) { |
+ allowed = true; |
+ break; |
+ } |
} |
+ } else if (matcher->types_matcher) { |
+ bool exist = true; |
+ for (ui::mojom::EventType event_type : matcher->types_matcher->types) { |
+ if (std::find(std::begin(event_type_whitelist), |
+ std::end(event_type_whitelist), event_type) == |
+ std::end(event_type_whitelist)) { |
+ exist = false; |
+ break; |
+ } |
+ } |
+ if (exist) allowed = true; |
} |
if (!allowed) { |
DVLOG(1) << "SetEventObserver event type not allowed"; |