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

Side by Side Diff: components/mus/ws/window_tree.cc

Issue 2016443003: mus: Don't allow SetEventObserver to monitor key events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
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 "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 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 window == current_capture_window; 1132 window == current_capture_window;
1133 if (success) { 1133 if (success) {
1134 Operation op(this, window_server_, OperationType::RELEASE_CAPTURE); 1134 Operation op(this, window_server_, OperationType::RELEASE_CAPTURE);
1135 success = wms->SetCapture(nullptr, false); 1135 success = wms->SetCapture(nullptr, false);
1136 } 1136 }
1137 client()->OnChangeCompleted(change_id, success); 1137 client()->OnChangeCompleted(change_id, success);
1138 } 1138 }
1139 1139
1140 void WindowTree::SetEventObserver(mojom::EventMatcherPtr matcher, 1140 void WindowTree::SetEventObserver(mojom::EventMatcherPtr matcher,
1141 uint32_t observer_id) { 1141 uint32_t observer_id) {
1142 if (!matcher.is_null() && observer_id != 0) { 1142 if (matcher.is_null() || observer_id == 0) {
1143 event_observer_matcher_.reset(new EventMatcher(*matcher)); 1143 // Clear any existing event observer.
1144 event_observer_id_ = observer_id;
1145 } else {
1146 event_observer_matcher_.reset(); 1144 event_observer_matcher_.reset();
1147 event_observer_id_ = 0; 1145 event_observer_id_ = 0;
1146 return;
1148 } 1147 }
1148
1149 // Do not allow key events to be observed, as a compromised app could register
1150 // itself as an event observer and spy on keystrokes to another app.
1151 if (!matcher->type_matcher) {
1152 DVLOG(1) << "SetEventObserver must specify an event type.";
1153 return;
1154 }
1155 const mojom::EventType event_type_whitelist[] = {
1156 mojom::EventType::POINTER_CANCEL,
1157 mojom::EventType::POINTER_DOWN,
1158 mojom::EventType::POINTER_MOVE,
1159 mojom::EventType::POINTER_UP,
1160 mojom::EventType::MOUSE_EXIT,
1161 mojom::EventType::WHEEL,
1162 };
1163 bool allowed = false;
1164 for (mojom::EventType event_type : event_type_whitelist) {
1165 if (matcher->type_matcher->type == event_type) {
1166 allowed = true;
1167 break;
1168 }
1169 }
1170 if (!allowed) {
1171 DVLOG(1) << "SetEventObserver event type not allowed";
1172 return;
1173 }
1174
1175 event_observer_matcher_.reset(new EventMatcher(*matcher));
1176 event_observer_id_ = observer_id;
1149 } 1177 }
1150 1178
1151 void WindowTree::SetWindowBounds(uint32_t change_id, 1179 void WindowTree::SetWindowBounds(uint32_t change_id,
1152 Id window_id, 1180 Id window_id,
1153 mojo::RectPtr bounds) { 1181 mojo::RectPtr bounds) {
1154 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); 1182 ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id));
1155 if (window && ShouldRouteToWindowManager(window)) { 1183 if (window && ShouldRouteToWindowManager(window)) {
1156 const uint32_t wm_change_id = 1184 const uint32_t wm_change_id =
1157 window_server_->GenerateWindowManagerChangeId(this, change_id); 1185 window_server_->GenerateWindowManagerChangeId(this, change_id);
1158 // |window_id| may be a client id, use the id from the window to ensure 1186 // |window_id| may be a client id, use the id from the window to ensure
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1479 } 1507 }
1480 1508
1481 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( 1509 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy(
1482 const ServerWindow* window) const { 1510 const ServerWindow* window) const {
1483 WindowTree* tree = window_server_->GetTreeWithRoot(window); 1511 WindowTree* tree = window_server_->GetTreeWithRoot(window);
1484 return tree && tree != this; 1512 return tree && tree != this;
1485 } 1513 }
1486 1514
1487 } // namespace ws 1515 } // namespace ws
1488 } // namespace mus 1516 } // namespace mus
OLDNEW
« no previous file with comments | « no previous file | components/mus/ws/window_tree_unittest.cc » ('j') | components/mus/ws/window_tree_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698