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

Unified 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, 9 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/services/view_manager/default_access_policy.cc
diff --git a/mojo/services/view_manager/default_access_policy.cc b/mojo/services/view_manager/default_access_policy.cc
new file mode 100644
index 0000000000000000000000000000000000000000..64da06d2eef2394c88b21b4d09710443c931fb8a
--- /dev/null
+++ b/mojo/services/view_manager/default_access_policy.cc
@@ -0,0 +1,112 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/services/view_manager/default_access_policy.h"
+
+#include "mojo/services/view_manager/access_policy_delegate.h"
+#include "mojo/services/view_manager/server_view.h"
+
+namespace view_manager {
+
+DefaultAccessPolicy::DefaultAccessPolicy(
+ mojo::ConnectionSpecificId connection_id,
+ AccessPolicyDelegate* delegate)
+ : connection_id_(connection_id), delegate_(delegate) {
+}
+
+DefaultAccessPolicy::~DefaultAccessPolicy() {
+}
+
+bool DefaultAccessPolicy::CanRemoveViewFromParent(
+ const ServerView* view) const {
+ if (!WasCreatedByThisConnection(view))
+ return false; // Can only unparent views we created.
+
+ return delegate_->IsRootForAccessPolicy(view->parent()->id()) ||
+ WasCreatedByThisConnection(view->parent());
+}
+
+bool DefaultAccessPolicy::CanAddView(const ServerView* parent,
+ const ServerView* child) const {
+ return WasCreatedByThisConnection(child) &&
+ (delegate_->IsRootForAccessPolicy(parent->id()) ||
+ (WasCreatedByThisConnection(parent) &&
+ !delegate_->IsViewRootOfAnotherConnectionForAccessPolicy(parent)));
+}
+
+bool DefaultAccessPolicy::CanReorderView(const ServerView* view,
+ const ServerView* relative_view,
+ mojo::OrderDirection direction) const {
+ return WasCreatedByThisConnection(view) &&
+ WasCreatedByThisConnection(relative_view);
+}
+
+bool DefaultAccessPolicy::CanDeleteView(const ServerView* view) const {
+ return WasCreatedByThisConnection(view);
+}
+
+bool DefaultAccessPolicy::CanGetViewTree(const ServerView* view) const {
+ return WasCreatedByThisConnection(view) ||
+ delegate_->IsRootForAccessPolicy(view->id());
+}
+
+bool DefaultAccessPolicy::CanDescendIntoViewForViewTree(
+ const ServerView* view) const {
+ return (WasCreatedByThisConnection(view) &&
+ !delegate_->IsViewRootOfAnotherConnectionForAccessPolicy(view)) ||
+ delegate_->IsRootForAccessPolicy(view->id());
+}
+
+bool DefaultAccessPolicy::CanEmbed(const ServerView* view) const {
+ return WasCreatedByThisConnection(view);
+}
+
+bool DefaultAccessPolicy::CanChangeViewVisibility(
+ const ServerView* view) const {
+ return WasCreatedByThisConnection(view) ||
+ delegate_->IsRootForAccessPolicy(view->id());
+}
+
+bool DefaultAccessPolicy::CanSetViewSurfaceId(const ServerView* view) const {
+ // Once a view embeds another app, the embedder app is no longer able to
+ // call SetViewSurfaceId() - this ability is transferred to the embedded app.
+ if (delegate_->IsViewRootOfAnotherConnectionForAccessPolicy(view))
+ return false;
+ return WasCreatedByThisConnection(view) ||
+ delegate_->IsRootForAccessPolicy(view->id());
+}
+
+bool DefaultAccessPolicy::CanSetViewBounds(const ServerView* view) const {
+ return WasCreatedByThisConnection(view);
+}
+
+bool DefaultAccessPolicy::CanSetViewProperties(const ServerView* view) const {
+ return WasCreatedByThisConnection(view);
+}
+
+bool DefaultAccessPolicy::ShouldNotifyOnHierarchyChange(
+ const ServerView* view,
+ const ServerView** new_parent,
+ const ServerView** old_parent) const {
+ if (!WasCreatedByThisConnection(view))
+ return false;
+
+ if (*new_parent && !WasCreatedByThisConnection(*new_parent) &&
+ !delegate_->IsRootForAccessPolicy((*new_parent)->id())) {
+ *new_parent = NULL;
+ }
+
+ if (*old_parent && !WasCreatedByThisConnection(*old_parent) &&
+ !delegate_->IsRootForAccessPolicy((*old_parent)->id())) {
+ *old_parent = NULL;
+ }
+ return true;
+}
+
+bool DefaultAccessPolicy::WasCreatedByThisConnection(
+ const ServerView* view) const {
+ return view->id().connection_id == connection_id_;
+}
+
+} // namespace view_manager
« 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