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 "mojo/services/view_manager/window_manager_access_policy.h" | 5 #include "mojo/services/view_manager/window_manager_access_policy.h" |
6 | 6 |
7 #include "mojo/services/view_manager/access_policy_delegate.h" | 7 #include "mojo/services/view_manager/access_policy_delegate.h" |
8 #include "mojo/services/view_manager/node.h" | 8 #include "mojo/services/view_manager/server_view.h" |
9 | 9 |
10 namespace mojo { | 10 namespace mojo { |
11 namespace service { | 11 namespace service { |
12 | 12 |
13 // TODO(sky): document why this differs from default for each case. Maybe want | 13 // TODO(sky): document why this differs from default for each case. Maybe want |
14 // to subclass DefaultAccessPolicy. | 14 // to subclass DefaultAccessPolicy. |
15 | 15 |
16 WindowManagerAccessPolicy::WindowManagerAccessPolicy( | 16 WindowManagerAccessPolicy::WindowManagerAccessPolicy( |
17 ConnectionSpecificId connection_id, | 17 ConnectionSpecificId connection_id, |
18 AccessPolicyDelegate* delegate) | 18 AccessPolicyDelegate* delegate) |
19 : connection_id_(connection_id), | 19 : connection_id_(connection_id), |
20 delegate_(delegate) { | 20 delegate_(delegate) { |
21 } | 21 } |
22 | 22 |
23 WindowManagerAccessPolicy::~WindowManagerAccessPolicy() { | 23 WindowManagerAccessPolicy::~WindowManagerAccessPolicy() { |
24 } | 24 } |
25 | 25 |
26 bool WindowManagerAccessPolicy::CanRemoveNodeFromParent( | 26 bool WindowManagerAccessPolicy::CanRemoveViewFromParent( |
27 const Node* node) const { | 27 const ServerView* view) const { |
28 return true; | 28 return true; |
29 } | 29 } |
30 | 30 |
31 bool WindowManagerAccessPolicy::CanAddNode(const Node* parent, | 31 bool WindowManagerAccessPolicy::CanAddView(const ServerView* parent, |
32 const Node* child) const { | 32 const ServerView* child) const { |
33 return true; | 33 return true; |
34 } | 34 } |
35 | 35 |
36 bool WindowManagerAccessPolicy::CanReorderNode(const Node* node, | 36 bool WindowManagerAccessPolicy::CanReorderView(const ServerView* view, |
37 const Node* relative_node, | 37 const ServerView* relative_view, |
38 OrderDirection direction) const { | 38 OrderDirection direction) const { |
39 return true; | 39 return true; |
40 } | 40 } |
41 | 41 |
42 bool WindowManagerAccessPolicy::CanDeleteNode(const Node* node) const { | 42 bool WindowManagerAccessPolicy::CanDeleteView(const ServerView* view) const { |
43 return node->id().connection_id == connection_id_; | 43 return view->id().connection_id == connection_id_; |
44 } | 44 } |
45 | 45 |
46 bool WindowManagerAccessPolicy::CanGetNodeTree(const Node* node) const { | 46 bool WindowManagerAccessPolicy::CanGetViewTree(const ServerView* view) const { |
47 return true; | 47 return true; |
48 } | 48 } |
49 | 49 |
50 bool WindowManagerAccessPolicy::CanDescendIntoNodeForNodeTree( | 50 bool WindowManagerAccessPolicy::CanDescendIntoViewForViewTree( |
51 const Node* node) const { | 51 const ServerView* view) const { |
52 return true; | 52 return true; |
53 } | 53 } |
54 | 54 |
55 bool WindowManagerAccessPolicy::CanEmbed(const Node* node) const { | 55 bool WindowManagerAccessPolicy::CanEmbed(const ServerView* view) const { |
56 return node->id().connection_id == connection_id_; | 56 return view->id().connection_id == connection_id_; |
57 } | 57 } |
58 | 58 |
59 bool WindowManagerAccessPolicy::CanChangeNodeVisibility( | 59 bool WindowManagerAccessPolicy::CanChangeViewVisibility( |
60 const Node* node) const { | 60 const ServerView* view) const { |
61 return node->id().connection_id == connection_id_; | 61 return view->id().connection_id == connection_id_; |
62 } | 62 } |
63 | 63 |
64 bool WindowManagerAccessPolicy::CanSetNodeContents(const Node* node) const { | 64 bool WindowManagerAccessPolicy::CanSetViewContents( |
65 if (delegate_->IsNodeRootOfAnotherConnectionForAccessPolicy(node)) | 65 const ServerView* view) const { |
| 66 if (delegate_->IsViewRootOfAnotherConnectionForAccessPolicy(view)) |
66 return false; | 67 return false; |
67 return node->id().connection_id == connection_id_ || | 68 return view->id().connection_id == connection_id_ || |
68 (delegate_->GetRootsForAccessPolicy().count( | 69 (delegate_->GetRootsForAccessPolicy().count( |
69 NodeIdToTransportId(node->id())) > 0); | 70 ViewIdToTransportId(view->id())) > 0); |
70 } | 71 } |
71 | 72 |
72 bool WindowManagerAccessPolicy::CanSetNodeBounds(const Node* node) const { | 73 bool WindowManagerAccessPolicy::CanSetViewBounds(const ServerView* view) const { |
73 return node->id().connection_id == connection_id_; | 74 return view->id().connection_id == connection_id_; |
74 } | 75 } |
75 | 76 |
76 bool WindowManagerAccessPolicy::ShouldNotifyOnHierarchyChange( | 77 bool WindowManagerAccessPolicy::ShouldNotifyOnHierarchyChange( |
77 const Node* node, | 78 const ServerView* view, |
78 const Node** new_parent, | 79 const ServerView** new_parent, |
79 const Node** old_parent) const { | 80 const ServerView** old_parent) const { |
80 // Notify if we've already told the window manager about the node, or if we've | 81 // Notify if we've already told the window manager about the view, or if we've |
81 // already told the window manager about the parent. The later handles the | 82 // already told the window manager about the parent. The later handles the |
82 // case of a node that wasn't parented to the root getting added to the root. | 83 // case of a view that wasn't parented to the root getting added to the root. |
83 return IsNodeKnown(node) || (*new_parent && IsNodeKnown(*new_parent)); | 84 return IsViewKnown(view) || (*new_parent && IsViewKnown(*new_parent)); |
84 } | 85 } |
85 | 86 |
86 bool WindowManagerAccessPolicy::ShouldSendViewDeleted( | 87 bool WindowManagerAccessPolicy::IsViewKnown(const ServerView* view) const { |
87 const ViewId& view_id) const { | 88 return delegate_->IsViewKnownForAccessPolicy(view); |
88 return true; | |
89 } | |
90 | |
91 bool WindowManagerAccessPolicy::IsNodeKnown(const Node* node) const { | |
92 return delegate_->IsNodeKnownForAccessPolicy(node); | |
93 } | 89 } |
94 | 90 |
95 } // namespace service | 91 } // namespace service |
96 } // namespace mojo | 92 } // namespace mojo |
OLD | NEW |