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/permission_message.h"
25 namespace extensions
{
27 // Represent the custom behavior of a top-level manifest entry contributing to
28 // permission messages and storage.
29 class ManifestPermission
{
32 virtual ~ManifestPermission();
34 // The manifest key this permission applies to.
35 virtual std::string
name() const = 0;
37 // Same as name(), needed for compatibility with APIPermission.
38 virtual std::string
id() const = 0;
40 // Returns true if this permission has any PermissionMessages.
41 virtual bool HasMessages() const = 0;
43 // Returns the localized permission messages of this permission.
44 virtual PermissionMessages
GetMessages() const = 0;
46 // Parses the ManifestPermission from |value|. Returns false if error happens.
47 virtual bool FromValue(const base::Value
* value
) = 0;
49 // Stores this into a new created Value.
50 virtual scoped_ptr
<base::Value
> ToValue() const = 0;
53 ManifestPermission
* Clone() const;
55 // Returns a new manifest permission which equals this - |rhs|.
56 virtual ManifestPermission
* Diff(const ManifestPermission
* rhs
) const = 0;
58 // Returns a new manifest permission which equals the union of this and |rhs|.
59 virtual ManifestPermission
* Union(const ManifestPermission
* rhs
) const = 0;
61 // Returns a new manifest permission which equals the intersect of this and
63 virtual ManifestPermission
* Intersect(const ManifestPermission
* rhs
)
66 // Returns true if |rhs| is a subset of this.
67 bool Contains(const ManifestPermission
* rhs
) const;
69 // Returns true if |rhs| is equal to this.
70 bool Equal(const ManifestPermission
* rhs
) const;
73 // Writes this into the given IPC message |m|.
74 void Write(IPC::Message
* m
) const;
76 // Reads from the given IPC message |m|.
77 bool Read(const IPC::Message
* m
, PickleIterator
* iter
);
79 // Logs this permission.
80 void Log(std::string
* log
) const;
83 DISALLOW_COPY_AND_ASSIGN(ManifestPermission
);
86 } // namespace extensions
88 #endif // EXTENSIONS_COMMON_PERMISSIONS_MANIFEST_PERMISSION_H_