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

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

Issue 1049993002: Get mojo_shell building inside chromium checkout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix presubmit Created 5 years, 8 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
(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/default_access_policy.h"
6
7 #include "mojo/services/view_manager/access_policy_delegate.h"
8 #include "mojo/services/view_manager/server_view.h"
9
10 namespace view_manager {
11
12 DefaultAccessPolicy::DefaultAccessPolicy(
13 mojo::ConnectionSpecificId connection_id,
14 AccessPolicyDelegate* delegate)
15 : connection_id_(connection_id), delegate_(delegate) {
16 }
17
18 DefaultAccessPolicy::~DefaultAccessPolicy() {
19 }
20
21 bool DefaultAccessPolicy::CanRemoveViewFromParent(
22 const ServerView* view) const {
23 if (!WasCreatedByThisConnection(view))
24 return false; // Can only unparent views we created.
25
26 return delegate_->IsRootForAccessPolicy(view->parent()->id()) ||
27 WasCreatedByThisConnection(view->parent());
28 }
29
30 bool DefaultAccessPolicy::CanAddView(const ServerView* parent,
31 const ServerView* child) const {
32 return WasCreatedByThisConnection(child) &&
33 (delegate_->IsRootForAccessPolicy(parent->id()) ||
34 (WasCreatedByThisConnection(parent) &&
35 !delegate_->IsViewRootOfAnotherConnectionForAccessPolicy(parent)));
36 }
37
38 bool DefaultAccessPolicy::CanReorderView(const ServerView* view,
39 const ServerView* relative_view,
40 mojo::OrderDirection direction) const {
41 return WasCreatedByThisConnection(view) &&
42 WasCreatedByThisConnection(relative_view);
43 }
44
45 bool DefaultAccessPolicy::CanDeleteView(const ServerView* view) const {
46 return WasCreatedByThisConnection(view);
47 }
48
49 bool DefaultAccessPolicy::CanGetViewTree(const ServerView* view) const {
50 return WasCreatedByThisConnection(view) ||
51 delegate_->IsRootForAccessPolicy(view->id());
52 }
53
54 bool DefaultAccessPolicy::CanDescendIntoViewForViewTree(
55 const ServerView* view) const {
56 return (WasCreatedByThisConnection(view) &&
57 !delegate_->IsViewRootOfAnotherConnectionForAccessPolicy(view)) ||
58 delegate_->IsRootForAccessPolicy(view->id());
59 }
60
61 bool DefaultAccessPolicy::CanEmbed(const ServerView* view) const {
62 return WasCreatedByThisConnection(view);
63 }
64
65 bool DefaultAccessPolicy::CanChangeViewVisibility(
66 const ServerView* view) const {
67 return WasCreatedByThisConnection(view) ||
68 delegate_->IsRootForAccessPolicy(view->id());
69 }
70
71 bool DefaultAccessPolicy::CanSetViewSurfaceId(const ServerView* view) const {
72 // Once a view embeds another app, the embedder app is no longer able to
73 // call SetViewSurfaceId() - this ability is transferred to the embedded app.
74 if (delegate_->IsViewRootOfAnotherConnectionForAccessPolicy(view))
75 return false;
76 return WasCreatedByThisConnection(view) ||
77 delegate_->IsRootForAccessPolicy(view->id());
78 }
79
80 bool DefaultAccessPolicy::CanSetViewBounds(const ServerView* view) const {
81 return WasCreatedByThisConnection(view);
82 }
83
84 bool DefaultAccessPolicy::CanSetViewProperties(const ServerView* view) const {
85 return WasCreatedByThisConnection(view);
86 }
87
88 bool DefaultAccessPolicy::ShouldNotifyOnHierarchyChange(
89 const ServerView* view,
90 const ServerView** new_parent,
91 const ServerView** old_parent) const {
92 if (!WasCreatedByThisConnection(view))
93 return false;
94
95 if (*new_parent && !WasCreatedByThisConnection(*new_parent) &&
96 !delegate_->IsRootForAccessPolicy((*new_parent)->id())) {
97 *new_parent = NULL;
98 }
99
100 if (*old_parent && !WasCreatedByThisConnection(*old_parent) &&
101 !delegate_->IsRootForAccessPolicy((*old_parent)->id())) {
102 *old_parent = NULL;
103 }
104 return true;
105 }
106
107 bool DefaultAccessPolicy::WasCreatedByThisConnection(
108 const ServerView* view) const {
109 return view->id().connection_id == connection_id_;
110 }
111
112 } // namespace view_manager
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