Home | History | Annotate | Download | only in view_manager
      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 #ifndef MOJO_SERVICES_VIEW_MANAGER_DEFAULT_ACCESS_POLICY_H_
      6 #define MOJO_SERVICES_VIEW_MANAGER_DEFAULT_ACCESS_POLICY_H_
      7 
      8 #include "base/basictypes.h"
      9 #include "mojo/services/view_manager/access_policy.h"
     10 
     11 namespace mojo {
     12 namespace service {
     13 
     14 class AccessPolicyDelegate;
     15 
     16 // AccessPolicy for all connections, except the window manager.
     17 class DefaultAccessPolicy : public AccessPolicy {
     18  public:
     19   DefaultAccessPolicy(ConnectionSpecificId connection_id,
     20                       AccessPolicyDelegate* delegate);
     21   virtual ~DefaultAccessPolicy();
     22 
     23   // AccessPolicy:
     24   virtual bool CanRemoveViewFromParent(const ServerView* view) const OVERRIDE;
     25   virtual bool CanAddView(const ServerView* parent,
     26                           const ServerView* child) const OVERRIDE;
     27   virtual bool CanReorderView(const ServerView* view,
     28                               const ServerView* relative_view,
     29                               OrderDirection direction) const OVERRIDE;
     30   virtual bool CanDeleteView(const ServerView* view) const OVERRIDE;
     31   virtual bool CanGetViewTree(const ServerView* view) const OVERRIDE;
     32   virtual bool CanDescendIntoViewForViewTree(
     33       const ServerView* view) const OVERRIDE;
     34   virtual bool CanEmbed(const ServerView* view) const OVERRIDE;
     35   virtual bool CanChangeViewVisibility(const ServerView* view) const OVERRIDE;
     36   virtual bool CanSetViewSurfaceId(const ServerView* view) const OVERRIDE;
     37   virtual bool CanSetViewBounds(const ServerView* view) const OVERRIDE;
     38   virtual bool ShouldNotifyOnHierarchyChange(
     39       const ServerView* view,
     40       const ServerView** new_parent,
     41       const ServerView** old_parent) const OVERRIDE;
     42 
     43  private:
     44   bool IsViewInRoots(const ServerView* view) const;
     45 
     46   template <typename T>
     47   bool WasCreatedByThisConnection(const T* t) const {
     48     return t->id().connection_id == connection_id_;
     49   }
     50 
     51   const ConnectionSpecificId connection_id_;
     52   AccessPolicyDelegate* delegate_;
     53 
     54   DISALLOW_COPY_AND_ASSIGN(DefaultAccessPolicy);
     55 };
     56 
     57 }  // namespace service
     58 }  // namespace mojo
     59 
     60 #endif  // MOJO_SERVICES_VIEW_MANAGER_DEFAULT_ACCESS_POLICY_H_
     61