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

Side by Side Diff: mojo/services/view_manager/default_access_policy.cc

Issue 513923004: More viewmanager renaming: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sim30 Created 6 years, 3 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 "mojo/services/view_manager/default_access_policy.h" 5 #include "mojo/services/view_manager/default_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 DefaultAccessPolicy::DefaultAccessPolicy(ConnectionSpecificId connection_id, 13 DefaultAccessPolicy::DefaultAccessPolicy(ConnectionSpecificId connection_id,
14 AccessPolicyDelegate* delegate) 14 AccessPolicyDelegate* delegate)
15 : connection_id_(connection_id), 15 : connection_id_(connection_id),
16 delegate_(delegate) { 16 delegate_(delegate) {
17 } 17 }
18 18
19 DefaultAccessPolicy::~DefaultAccessPolicy() { 19 DefaultAccessPolicy::~DefaultAccessPolicy() {
20 } 20 }
21 21
22 bool DefaultAccessPolicy::CanRemoveNodeFromParent(const Node* node) const { 22 bool DefaultAccessPolicy::CanRemoveViewFromParent(
23 if (!WasCreatedByThisConnection(node)) 23 const ServerView* view) const {
24 return false; // Can only unparent nodes we created. 24 if (!WasCreatedByThisConnection(view))
25 return false; // Can only unparent views we created.
25 26
26 return IsNodeInRoots(node->parent()) || 27 return IsViewInRoots(view->parent()) ||
27 WasCreatedByThisConnection(node->parent()); 28 WasCreatedByThisConnection(view->parent());
28 } 29 }
29 30
30 bool DefaultAccessPolicy::CanAddNode(const Node* parent, 31 bool DefaultAccessPolicy::CanAddView(const ServerView* parent,
31 const Node* child) const { 32 const ServerView* child) const {
32 return WasCreatedByThisConnection(child) && 33 return WasCreatedByThisConnection(child) &&
33 (IsNodeInRoots(parent) || 34 (IsViewInRoots(parent) ||
34 (WasCreatedByThisConnection(parent) && 35 (WasCreatedByThisConnection(parent) &&
35 !delegate_->IsNodeRootOfAnotherConnectionForAccessPolicy(parent))); 36 !delegate_->IsViewRootOfAnotherConnectionForAccessPolicy(parent)));
36 } 37 }
37 38
38 bool DefaultAccessPolicy::CanReorderNode(const Node* node, 39 bool DefaultAccessPolicy::CanReorderView(const ServerView* view,
39 const Node* relative_node, 40 const ServerView* relative_view,
40 OrderDirection direction) const { 41 OrderDirection direction) const {
41 return WasCreatedByThisConnection(node) && 42 return WasCreatedByThisConnection(view) &&
42 WasCreatedByThisConnection(relative_node); 43 WasCreatedByThisConnection(relative_view);
43 } 44 }
44 45
45 bool DefaultAccessPolicy::CanDeleteNode(const Node* node) const { 46 bool DefaultAccessPolicy::CanDeleteView(const ServerView* view) const {
46 return WasCreatedByThisConnection(node); 47 return WasCreatedByThisConnection(view);
47 } 48 }
48 49
49 bool DefaultAccessPolicy::CanGetNodeTree(const Node* node) const { 50 bool DefaultAccessPolicy::CanGetViewTree(const ServerView* view) const {
50 return WasCreatedByThisConnection(node) || IsNodeInRoots(node); 51 return WasCreatedByThisConnection(view) || IsViewInRoots(view);
51 } 52 }
52 53
53 bool DefaultAccessPolicy::CanDescendIntoNodeForNodeTree( 54 bool DefaultAccessPolicy::CanDescendIntoViewForViewTree(
54 const Node* node) const { 55 const ServerView* view) const {
55 return WasCreatedByThisConnection(node) && 56 return WasCreatedByThisConnection(view) &&
56 !delegate_->IsNodeRootOfAnotherConnectionForAccessPolicy(node); 57 !delegate_->IsViewRootOfAnotherConnectionForAccessPolicy(view);
57 } 58 }
58 59
59 bool DefaultAccessPolicy::CanEmbed(const Node* node) const { 60 bool DefaultAccessPolicy::CanEmbed(const ServerView* view) const {
60 return WasCreatedByThisConnection(node); 61 return WasCreatedByThisConnection(view);
61 } 62 }
62 63
63 bool DefaultAccessPolicy::CanChangeNodeVisibility(const Node* node) const { 64 bool DefaultAccessPolicy::CanChangeViewVisibility(
64 return WasCreatedByThisConnection(node) || IsNodeInRoots(node); 65 const ServerView* view) const {
66 return WasCreatedByThisConnection(view) || IsViewInRoots(view);
65 } 67 }
66 68
67 bool DefaultAccessPolicy::CanSetNodeContents(const Node* node) const { 69 bool DefaultAccessPolicy::CanSetViewContents(const ServerView* view) const {
68 // Once a node embeds another app, the embedder app is no longer able to 70 // Once a view embeds another app, the embedder app is no longer able to
69 // call SetNodeContents() - this ability is transferred to the embedded app. 71 // call SetViewContents() - this ability is transferred to the embedded app.
70 if (delegate_->IsNodeRootOfAnotherConnectionForAccessPolicy(node)) 72 if (delegate_->IsViewRootOfAnotherConnectionForAccessPolicy(view))
71 return false; 73 return false;
72 return WasCreatedByThisConnection(node) || IsNodeInRoots(node); 74 return WasCreatedByThisConnection(view) || IsViewInRoots(view);
73 } 75 }
74 76
75 bool DefaultAccessPolicy::CanSetNodeBounds(const Node* node) const { 77 bool DefaultAccessPolicy::CanSetViewBounds(const ServerView* view) const {
76 return WasCreatedByThisConnection(node); 78 return WasCreatedByThisConnection(view);
77 } 79 }
78 80
79 bool DefaultAccessPolicy::ShouldNotifyOnHierarchyChange( 81 bool DefaultAccessPolicy::ShouldNotifyOnHierarchyChange(
80 const Node* node, 82 const ServerView* view,
81 const Node** new_parent, 83 const ServerView** new_parent,
82 const Node** old_parent) const { 84 const ServerView** old_parent) const {
83 if (!WasCreatedByThisConnection(node)) 85 if (!WasCreatedByThisConnection(view))
84 return false; 86 return false;
85 87
86 if (*new_parent && !WasCreatedByThisConnection(*new_parent) && 88 if (*new_parent && !WasCreatedByThisConnection(*new_parent) &&
87 !IsNodeInRoots(*new_parent)) { 89 !IsViewInRoots(*new_parent)) {
88 *new_parent = NULL; 90 *new_parent = NULL;
89 } 91 }
90 92
91 if (*old_parent && !WasCreatedByThisConnection(*old_parent) && 93 if (*old_parent && !WasCreatedByThisConnection(*old_parent) &&
92 !IsNodeInRoots(*old_parent)) { 94 !IsViewInRoots(*old_parent)) {
93 *old_parent = NULL; 95 *old_parent = NULL;
94 } 96 }
95 return true; 97 return true;
96 } 98 }
97 99
98 bool DefaultAccessPolicy::ShouldSendViewDeleted(const ViewId& view_id) const { 100 bool DefaultAccessPolicy::IsViewInRoots(const ServerView* view) const {
99 return view_id.connection_id == connection_id_;
100 }
101
102 bool DefaultAccessPolicy::IsNodeInRoots(const Node* node) const {
103 return delegate_->GetRootsForAccessPolicy().count( 101 return delegate_->GetRootsForAccessPolicy().count(
104 NodeIdToTransportId(node->id())) > 0; 102 ViewIdToTransportId(view->id())) > 0;
105 } 103 }
106 104
107 } // namespace service 105 } // namespace service
108 } // namespace mojo 106 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/view_manager/default_access_policy.h ('k') | mojo/services/view_manager/display_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698