OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/mus/ws/window_tree.h" | 5 #include "components/mus/ws/window_tree.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 uint32_t observer_id) { | 1149 uint32_t observer_id) { |
1150 if (matcher.is_null() || observer_id == 0) { | 1150 if (matcher.is_null() || observer_id == 0) { |
1151 // Clear any existing event observer. | 1151 // Clear any existing event observer. |
1152 event_observer_matcher_.reset(); | 1152 event_observer_matcher_.reset(); |
1153 event_observer_id_ = 0; | 1153 event_observer_id_ = 0; |
1154 return; | 1154 return; |
1155 } | 1155 } |
1156 | 1156 |
1157 // Do not allow key events to be observed, as a compromised app could register | 1157 // Do not allow key events to be observed, as a compromised app could register |
1158 // itself as an event observer and spy on keystrokes to another app. | 1158 // itself as an event observer and spy on keystrokes to another app. |
1159 if (!matcher->type_matcher) { | 1159 if (!matcher->type_matcher && !matcher->types_matcher) { |
1160 DVLOG(1) << "SetEventObserver must specify an event type."; | 1160 DVLOG(1) << "SetEventObserver must specify an event type."; |
1161 return; | 1161 return; |
1162 } | 1162 } |
1163 const ui::mojom::EventType event_type_whitelist[] = { | 1163 const ui::mojom::EventType event_type_whitelist[] = { |
1164 ui::mojom::EventType::POINTER_CANCEL, ui::mojom::EventType::POINTER_DOWN, | 1164 ui::mojom::EventType::POINTER_CANCEL, ui::mojom::EventType::POINTER_DOWN, |
1165 ui::mojom::EventType::POINTER_MOVE, ui::mojom::EventType::POINTER_UP, | 1165 ui::mojom::EventType::POINTER_MOVE, ui::mojom::EventType::POINTER_UP, |
1166 ui::mojom::EventType::MOUSE_EXIT, ui::mojom::EventType::WHEEL, | 1166 ui::mojom::EventType::MOUSE_EXIT, ui::mojom::EventType::WHEEL, |
1167 }; | 1167 }; |
1168 bool allowed = false; | 1168 bool allowed = false; |
1169 for (ui::mojom::EventType event_type : event_type_whitelist) { | 1169 if (matcher->type_matcher) { |
1170 if (matcher->type_matcher->type == event_type) { | 1170 for (ui::mojom::EventType event_type : event_type_whitelist) { |
1171 allowed = true; | 1171 if (matcher->type_matcher->type == event_type) { |
1172 break; | 1172 allowed = true; |
| 1173 break; |
| 1174 } |
1173 } | 1175 } |
| 1176 } else if (matcher->types_matcher) { |
| 1177 bool exist = true; |
| 1178 for (ui::mojom::EventType event_type : matcher->types_matcher->types) { |
| 1179 if (std::find(std::begin(event_type_whitelist), |
| 1180 std::end(event_type_whitelist), event_type) == |
| 1181 std::end(event_type_whitelist)) { |
| 1182 exist = false; |
| 1183 break; |
| 1184 } |
| 1185 } |
| 1186 if (exist) allowed = true; |
1174 } | 1187 } |
1175 if (!allowed) { | 1188 if (!allowed) { |
1176 DVLOG(1) << "SetEventObserver event type not allowed"; | 1189 DVLOG(1) << "SetEventObserver event type not allowed"; |
1177 return; | 1190 return; |
1178 } | 1191 } |
1179 | 1192 |
1180 event_observer_matcher_.reset(new EventMatcher(*matcher)); | 1193 event_observer_matcher_.reset(new EventMatcher(*matcher)); |
1181 event_observer_id_ = observer_id; | 1194 event_observer_id_ = observer_id; |
1182 } | 1195 } |
1183 | 1196 |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1527 } | 1540 } |
1528 | 1541 |
1529 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( | 1542 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( |
1530 const ServerWindow* window) const { | 1543 const ServerWindow* window) const { |
1531 WindowTree* tree = window_server_->GetTreeWithRoot(window); | 1544 WindowTree* tree = window_server_->GetTreeWithRoot(window); |
1532 return tree && tree != this; | 1545 return tree && tree != this; |
1533 } | 1546 } |
1534 | 1547 |
1535 } // namespace ws | 1548 } // namespace ws |
1536 } // namespace mus | 1549 } // namespace mus |
OLD | NEW |