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 auto iter = |
1180 allowed = true; | 1185 std::find(std::begin(event_type_whitelist), |
1181 break; | 1186 std::end(event_type_whitelist), matcher->type_matcher->type); |
1182 } | 1187 allowed = iter != std::end(event_type_whitelist); |
1188 } | |
1189 if (matcher->pointer_kind_matcher) { | |
1190 auto iter = std::find(std::begin(pointer_kind_whitelist), | |
1191 std::end(pointer_kind_whitelist), | |
1192 matcher->pointer_kind_matcher->pointer_kind); | |
1193 allowed = iter != std::end(pointer_kind_whitelist); | |
sadrul
2016/07/12 19:21:05
Actually, let's get rid of this whitelist. Just do
riajiang
2016/07/12 20:35:47
Done.
| |
1183 } | 1194 } |
1184 if (!allowed) { | 1195 if (!allowed) { |
1185 DVLOG(1) << "SetEventObserver event type not allowed"; | 1196 DVLOG(1) << "SetEventObserver event type not allowed"; |
1186 return; | 1197 return; |
1187 } | 1198 } |
1188 | 1199 |
1189 event_observer_matcher_.reset(new EventMatcher(*matcher)); | 1200 event_observer_matcher_.reset(new EventMatcher(*matcher)); |
1190 event_observer_id_ = observer_id; | 1201 event_observer_id_ = observer_id; |
1191 } | 1202 } |
1192 | 1203 |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1642 } | 1653 } |
1643 | 1654 |
1644 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( | 1655 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( |
1645 const ServerWindow* window) const { | 1656 const ServerWindow* window) const { |
1646 WindowTree* tree = window_server_->GetTreeWithRoot(window); | 1657 WindowTree* tree = window_server_->GetTreeWithRoot(window); |
1647 return tree && tree != this; | 1658 return tree && tree != this; |
1648 } | 1659 } |
1649 | 1660 |
1650 } // namespace ws | 1661 } // namespace ws |
1651 } // namespace ui | 1662 } // namespace ui |
OLD | NEW |