OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "mojo/services/view_manager/window_manager_access_policy.h" |
| 6 |
| 7 #include "mojo/services/view_manager/access_policy_delegate.h" |
| 8 #include "mojo/services/view_manager/node.h" |
| 9 #include "mojo/services/view_manager/view.h" |
| 10 |
| 11 namespace mojo { |
| 12 namespace service { |
| 13 |
| 14 WindowManagerAccessPolicy::WindowManagerAccessPolicy( |
| 15 ConnectionSpecificId connection_id, |
| 16 AccessPolicyDelegate* delegate) |
| 17 : connection_id_(connection_id), |
| 18 delegate_(delegate) { |
| 19 } |
| 20 |
| 21 WindowManagerAccessPolicy::~WindowManagerAccessPolicy() { |
| 22 } |
| 23 |
| 24 bool WindowManagerAccessPolicy::CanRemoveNodeFromParent( |
| 25 const Node* node) const { |
| 26 return true; |
| 27 } |
| 28 |
| 29 bool WindowManagerAccessPolicy::CanAddNode(const Node* parent, |
| 30 const Node* child) const { |
| 31 return true; |
| 32 } |
| 33 |
| 34 bool WindowManagerAccessPolicy::CanReorderNode(const Node* node, |
| 35 const Node* relative_node, |
| 36 OrderDirection direction) const { |
| 37 return true; |
| 38 } |
| 39 |
| 40 bool WindowManagerAccessPolicy::CanDeleteNode(const Node* node) const { |
| 41 return node->id().connection_id == connection_id_; |
| 42 } |
| 43 |
| 44 bool WindowManagerAccessPolicy::CanDeleteView(const View* view) const { |
| 45 return view->id().connection_id == connection_id_; |
| 46 } |
| 47 |
| 48 bool WindowManagerAccessPolicy::CanSetView(const Node* node, |
| 49 const View* view) const { |
| 50 return !view || view->id().connection_id == connection_id_; |
| 51 } |
| 52 |
| 53 bool WindowManagerAccessPolicy::CanSetFocus(const Node* node) const { |
| 54 // TODO(beng): security. |
| 55 return true; |
| 56 } |
| 57 |
| 58 bool WindowManagerAccessPolicy::CanGetNodeTree(const Node* node) const { |
| 59 return true; |
| 60 } |
| 61 |
| 62 bool WindowManagerAccessPolicy::CanDescendIntoNodeForNodeTree( |
| 63 const Node* node) const { |
| 64 return true; |
| 65 } |
| 66 |
| 67 bool WindowManagerAccessPolicy::CanEmbed(const Node* node) const { |
| 68 return node->id().connection_id == connection_id_; |
| 69 } |
| 70 |
| 71 bool WindowManagerAccessPolicy::CanChangeNodeVisibility( |
| 72 const Node* node) const { |
| 73 return node->id().connection_id == connection_id_; |
| 74 } |
| 75 |
| 76 bool WindowManagerAccessPolicy::CanSetViewContents(const View* view) const { |
| 77 return view->id().connection_id == connection_id_; |
| 78 } |
| 79 |
| 80 bool WindowManagerAccessPolicy::CanSetNodeBounds(const Node* node) const { |
| 81 return node->id().connection_id == connection_id_; |
| 82 } |
| 83 |
| 84 bool WindowManagerAccessPolicy::ShouldNotifyOnHierarchyChange( |
| 85 const Node* node, |
| 86 const Node** new_parent, |
| 87 const Node** old_parent) const { |
| 88 // Notify if we've already told the window manager about the node, or if we've |
| 89 // already told the window manager about the parent. The later handles the |
| 90 // case of a node that wasn't parented to the root getting added to the root. |
| 91 return IsNodeKnown(node) || (*new_parent && IsNodeKnown(*new_parent)); |
| 92 } |
| 93 |
| 94 bool WindowManagerAccessPolicy::ShouldSendViewDeleted( |
| 95 const ViewId& view_id) const { |
| 96 return true; |
| 97 } |
| 98 |
| 99 bool WindowManagerAccessPolicy::IsNodeKnown(const Node* node) const { |
| 100 return delegate_->IsNodeKnownForAccessPolicy(node); |
| 101 } |
| 102 |
| 103 Id WindowManagerAccessPolicy::GetViewIdToSend(const Node* node, |
| 104 const View* view) const { |
| 105 return ViewIdToTransportId(view->id()); |
| 106 } |
| 107 |
| 108 } // namespace service |
| 109 } // namespace mojo |
OLD | NEW |