1 // Copyright 2013 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.
5 #ifndef EXTENSIONS_COMMON_PERMISSIONS_MANIFEST_PERMISSION_H_
6 #define EXTENSIONS_COMMON_PERMISSIONS_MANIFEST_PERMISSION_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "base/pickle.h"
12 #include "extensions/common/permissions/api_permission_set.h"
23 namespace extensions
{
25 // Represent the custom behavior of a top-level manifest entry contributing to
26 // permission messages and storage.
27 class ManifestPermission
{
30 virtual ~ManifestPermission();
32 // The manifest key this permission applies to.
33 virtual std::string
name() const = 0;
35 // Same as name(), needed for compatibility with APIPermission.
36 virtual std::string
id() const = 0;
38 // The set of permissions this manifest entry has. These permissions are used
39 // by PermissionMessageProvider to generate meaningful permission messages
41 virtual PermissionIDSet
GetPermissions() const = 0;
43 // Parses the ManifestPermission from |value|. Returns false if error happens.
44 virtual bool FromValue(const base::Value
* value
) = 0;
46 // Stores this into a new created Value.
47 virtual scoped_ptr
<base::Value
> ToValue() const = 0;
50 ManifestPermission
* Clone() const;
52 // Returns a new manifest permission which equals this - |rhs|.
53 virtual ManifestPermission
* Diff(const ManifestPermission
* rhs
) const = 0;
55 // Returns a new manifest permission which equals the union of this and |rhs|.
56 virtual ManifestPermission
* Union(const ManifestPermission
* rhs
) const = 0;
58 // Returns a new manifest permission which equals the intersect of this and
60 virtual ManifestPermission
* Intersect(const ManifestPermission
* rhs
)
63 // Returns true if |rhs| is a subset of this.
64 bool Contains(const ManifestPermission
* rhs
) const;
66 // Returns true if |rhs| is equal to this.
67 bool Equal(const ManifestPermission
* rhs
) const;
70 // Writes this into the given IPC message |m|.
71 void Write(IPC::Message
* m
) const;
73 // Reads from the given IPC message |m|.
74 bool Read(const IPC::Message
* m
, base::PickleIterator
* iter
);
76 // Logs this permission.
77 void Log(std::string
* log
) const;
80 DISALLOW_COPY_AND_ASSIGN(ManifestPermission
);
83 } // namespace extensions
85 #endif // EXTENSIONS_COMMON_PERMISSIONS_MANIFEST_PERMISSION_H_