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 | |
1177 bool allowed = false; | 1179 bool allowed = false; |
1178 for (ui::mojom::EventType event_type : event_type_whitelist) { | 1180 if (matcher->type_matcher) { |
1179 if (matcher->type_matcher->type == event_type) { | 1181 auto iter = |
1180 allowed = true; | 1182 std::find(std::begin(event_type_whitelist), |
1181 break; | 1183 std::end(event_type_whitelist), matcher->type_matcher->type); |
1182 } | 1184 allowed = iter != std::end(event_type_whitelist); |
James Cook
2016/07/12 23:22:59
nit: I think this would be clearer with an early r
sadrul
2016/07/13 00:28:30
Good catch! +1
riajiang
2016/07/13 15:40:21
Done.
| |
1185 } | |
1186 if (matcher->pointer_kind_matcher) { | |
1187 ui::mojom::PointerKind pointer_kind = | |
1188 matcher->pointer_kind_matcher->pointer_kind; | |
1189 allowed = pointer_kind == ui::mojom::PointerKind::MOUSE || | |
msw
2016/07/12 22:23:11
q: Will we imminently add other PointerKind types
sadrul
2016/07/13 00:28:30
I don't really expect new pointer-kinds (I think s
| |
1190 pointer_kind == ui::mojom::PointerKind::TOUCH || | |
1191 pointer_kind == ui::mojom::PointerKind::PEN; | |
1183 } | 1192 } |
1184 if (!allowed) { | 1193 if (!allowed) { |
1185 DVLOG(1) << "SetEventObserver event type not allowed"; | 1194 DVLOG(1) << "SetEventObserver event type not allowed"; |
1186 return; | 1195 return; |
1187 } | 1196 } |
1188 | 1197 |
1189 event_observer_matcher_.reset(new EventMatcher(*matcher)); | 1198 event_observer_matcher_.reset(new EventMatcher(*matcher)); |
1190 event_observer_id_ = observer_id; | 1199 event_observer_id_ = observer_id; |
1191 } | 1200 } |
1192 | 1201 |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1642 } | 1651 } |
1643 | 1652 |
1644 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( | 1653 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( |
1645 const ServerWindow* window) const { | 1654 const ServerWindow* window) const { |
1646 WindowTree* tree = window_server_->GetTreeWithRoot(window); | 1655 WindowTree* tree = window_server_->GetTreeWithRoot(window); |
1647 return tree && tree != this; | 1656 return tree && tree != this; |
1648 } | 1657 } |
1649 | 1658 |
1650 } // namespace ws | 1659 } // namespace ws |
1651 } // namespace ui | 1660 } // namespace ui |
OLD | NEW |