Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Side by Side Diff: services/ui/ws/window_tree.cc

Issue 2125663002: mus: Add watcher for all touch events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a comment Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/views/mus/window_manager_connection.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 };
1177 bool allowed = false; 1178
1178 for (ui::mojom::EventType event_type : event_type_whitelist) { 1179 if (matcher->type_matcher) {
1179 if (matcher->type_matcher->type == event_type) { 1180 auto iter =
1180 allowed = true; 1181 std::find(std::begin(event_type_whitelist),
1181 break; 1182 std::end(event_type_whitelist), matcher->type_matcher->type);
1183 if (iter == std::end(event_type_whitelist)) {
1184 DVLOG(1) << "SetEventObserver event type not allowed";
1185 return;
1182 } 1186 }
1183 } 1187 }
1184 if (!allowed) { 1188 if (matcher->pointer_kind_matcher) {
1185 DVLOG(1) << "SetEventObserver event type not allowed"; 1189 ui::mojom::PointerKind pointer_kind =
1186 return; 1190 matcher->pointer_kind_matcher->pointer_kind;
1191 if (pointer_kind != ui::mojom::PointerKind::MOUSE &&
1192 pointer_kind != ui::mojom::PointerKind::TOUCH &&
1193 pointer_kind != ui::mojom::PointerKind::PEN) {
1194 DVLOG(1) << "SetEventObserver pointer kind not allowed";
1195 return;
1196 }
1187 } 1197 }
1188 1198
1189 event_observer_matcher_.reset(new EventMatcher(*matcher)); 1199 event_observer_matcher_.reset(new EventMatcher(*matcher));
1190 event_observer_id_ = observer_id; 1200 event_observer_id_ = observer_id;
1191 } 1201 }
1192 1202
1193 void WindowTree::SetWindowBounds(uint32_t change_id, 1203 void WindowTree::SetWindowBounds(uint32_t change_id,
1194 Id window_id, 1204 Id window_id,
1195 const gfx::Rect& bounds) { 1205 const gfx::Rect& bounds) {
1196 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); 1206 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id));
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 } 1652 }
1643 1653
1644 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( 1654 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy(
1645 const ServerWindow* window) const { 1655 const ServerWindow* window) const {
1646 WindowTree* tree = window_server_->GetTreeWithRoot(window); 1656 WindowTree* tree = window_server_->GetTreeWithRoot(window);
1647 return tree && tree != this; 1657 return tree && tree != this;
1648 } 1658 }
1649 1659
1650 } // namespace ws 1660 } // namespace ws
1651 } // namespace ui 1661 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/views/mus/window_manager_connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698