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 "services/ui/ws/window_tree.h" | 5 #include "services/ui/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 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1158 uint32_t observer_id) { | 1158 uint32_t observer_id) { |
1159 if (matcher.is_null() || observer_id == 0) { | 1159 if (matcher.is_null() || observer_id == 0) { |
1160 // Clear any existing event observer. | 1160 // Clear any existing event observer. |
1161 event_observer_matcher_.reset(); | 1161 event_observer_matcher_.reset(); |
1162 event_observer_id_ = 0; | 1162 event_observer_id_ = 0; |
1163 return; | 1163 return; |
1164 } | 1164 } |
1165 | 1165 |
1166 // Do not allow key events to be observed, as a compromised app could register | 1166 // Do not allow key events to be observed, as a compromised app could register |
1167 // itself as an event observer and spy on keystrokes to another app. | 1167 // itself as an event observer and spy on keystrokes to another app. |
1168 if (!matcher->type_matcher) { | 1168 if (!matcher->type_matcher && !matcher->pointer_kind_matcher) { |
1169 DVLOG(1) << "SetEventObserver must specify an event type."; | 1169 DVLOG(1) << "SetEventObserver must specify an event type."; |
1170 return; | 1170 return; |
1171 } | 1171 } |
1172 | |
1172 const ui::mojom::EventType event_type_whitelist[] = { | 1173 const ui::mojom::EventType event_type_whitelist[] = { |
1173 ui::mojom::EventType::POINTER_CANCEL, ui::mojom::EventType::POINTER_DOWN, | 1174 ui::mojom::EventType::POINTER_CANCEL, ui::mojom::EventType::POINTER_DOWN, |
1174 ui::mojom::EventType::POINTER_MOVE, ui::mojom::EventType::POINTER_UP, | 1175 ui::mojom::EventType::POINTER_MOVE, ui::mojom::EventType::POINTER_UP, |
1175 ui::mojom::EventType::MOUSE_EXIT, ui::mojom::EventType::WHEEL, | 1176 ui::mojom::EventType::MOUSE_EXIT, ui::mojom::EventType::WHEEL, |
1176 }; | 1177 }; |
1178 const ui::mojom::PointerKind pointer_kind_whitelist[] = { | |
1179 ui::mojom::PointerKind::MOUSE, ui::mojom::PointerKind::TOUCH, | |
1180 }; | |
1181 | |
1177 bool allowed = false; | 1182 bool allowed = false; |
1178 for (ui::mojom::EventType event_type : event_type_whitelist) { | 1183 if (matcher->type_matcher) { |
1179 if (matcher->type_matcher->type == event_type) { | 1184 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.
| |
1180 allowed = true; | 1185 if (matcher->type_matcher->type == event_type) { |
1181 break; | 1186 allowed = true; |
1187 break; | |
1188 } | |
1189 } | |
1190 } | |
1191 if (matcher->pointer_kind_matcher) { | |
1192 for (ui::mojom::PointerKind pointer : pointer_kind_whitelist) { | |
1193 if (matcher->pointer_kind_matcher->pointer_kind == pointer) { | |
1194 allowed = true; | |
1195 break; | |
1196 } | |
1182 } | 1197 } |
sadrul
2016/07/11 20:47:52
ditto
riajiang
2016/07/11 21:51:40
Done.
| |
1183 } | 1198 } |
1184 if (!allowed) { | 1199 if (!allowed) { |
1185 DVLOG(1) << "SetEventObserver event type not allowed"; | 1200 DVLOG(1) << "SetEventObserver event type not allowed"; |
1186 return; | 1201 return; |
1187 } | 1202 } |
1188 | 1203 |
1189 event_observer_matcher_.reset(new EventMatcher(*matcher)); | 1204 event_observer_matcher_.reset(new EventMatcher(*matcher)); |
1190 event_observer_id_ = observer_id; | 1205 event_observer_id_ = observer_id; |
1191 } | 1206 } |
1192 | 1207 |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1642 } | 1657 } |
1643 | 1658 |
1644 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( | 1659 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( |
1645 const ServerWindow* window) const { | 1660 const ServerWindow* window) const { |
1646 WindowTree* tree = window_server_->GetTreeWithRoot(window); | 1661 WindowTree* tree = window_server_->GetTreeWithRoot(window); |
1647 return tree && tree != this; | 1662 return tree && tree != this; |
1648 } | 1663 } |
1649 | 1664 |
1650 } // namespace ws | 1665 } // namespace ws |
1651 } // namespace ui | 1666 } // namespace ui |
OLD | NEW |