15f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
25f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// found in the LICENSE file.
45f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
55f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#ifndef MOJO_SERVICES_VIEW_MANAGER_DEFAULT_ACCESS_POLICY_H_
65f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#define MOJO_SERVICES_VIEW_MANAGER_DEFAULT_ACCESS_POLICY_H_
75f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
85f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "base/basictypes.h"
95f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "mojo/services/view_manager/access_policy.h"
105f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
115f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)namespace mojo {
125f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)namespace service {
135f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
145f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class AccessPolicyDelegate;
155f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
165f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// AccessPolicy for all connections, except the window manager.
175f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class DefaultAccessPolicy : public AccessPolicy {
185f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) public:
195f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  DefaultAccessPolicy(ConnectionSpecificId connection_id,
205f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                      AccessPolicyDelegate* delegate);
215f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  virtual ~DefaultAccessPolicy();
225f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
235f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // AccessPolicy:
241320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual bool CanRemoveViewFromParent(const ServerView* view) const OVERRIDE;
251320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual bool CanAddView(const ServerView* parent,
261320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                          const ServerView* child) const OVERRIDE;
271320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual bool CanReorderView(const ServerView* view,
281320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                              const ServerView* relative_view,
295f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                              OrderDirection direction) const OVERRIDE;
301320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual bool CanDeleteView(const ServerView* view) const OVERRIDE;
311320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual bool CanGetViewTree(const ServerView* view) const OVERRIDE;
321320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual bool CanDescendIntoViewForViewTree(
331320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      const ServerView* view) const OVERRIDE;
341320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual bool CanEmbed(const ServerView* view) const OVERRIDE;
351320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual bool CanChangeViewVisibility(const ServerView* view) const OVERRIDE;
361320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual bool CanSetViewSurfaceId(const ServerView* view) const OVERRIDE;
371320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  virtual bool CanSetViewBounds(const ServerView* view) const OVERRIDE;
385f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  virtual bool ShouldNotifyOnHierarchyChange(
391320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      const ServerView* view,
401320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      const ServerView** new_parent,
411320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci      const ServerView** old_parent) const OVERRIDE;
425f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
435f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) private:
441320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  bool IsViewInRoots(const ServerView* view) const;
455f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
465f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  template <typename T>
475f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  bool WasCreatedByThisConnection(const T* t) const {
485f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    return t->id().connection_id == connection_id_;
495f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  }
505f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
515f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  const ConnectionSpecificId connection_id_;
525f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  AccessPolicyDelegate* delegate_;
535f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
545f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(DefaultAccessPolicy);
555f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)};
565f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
575f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)}  // namespace service
585f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)}  // namespace mojo
595f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
605f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#endif  // MOJO_SERVICES_VIEW_MANAGER_DEFAULT_ACCESS_POLICY_H_
61