Extensions: Remove the legacy GetMessages/HasMessages
[chromium-blink-merge.git] / extensions / common / permissions / manifest_permission.h
blob31e6ffc4daf010b0ca8376be36eee8b3c5b4d747
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_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "base/pickle.h"
12 #include "extensions/common/permissions/api_permission_set.h"
13 #include "extensions/common/permissions/coalesced_permission_message.h"
14 #include "extensions/common/permissions/permission_message.h"
16 namespace base {
17 class PickleIterator;
18 class Value;
21 namespace IPC {
22 class Message;
25 namespace extensions {
27 // Represent the custom behavior of a top-level manifest entry contributing to
28 // permission messages and storage.
29 class ManifestPermission {
30 public:
31 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 // The set of permissions this manifest entry has. These permissions are used
41 // by PermissionMessageProvider to generate meaningful permission messages
42 // for the app.
43 virtual PermissionIDSet GetPermissions() const = 0;
45 // Parses the ManifestPermission from |value|. Returns false if error happens.
46 virtual bool FromValue(const base::Value* value) = 0;
48 // Stores this into a new created Value.
49 virtual scoped_ptr<base::Value> ToValue() const = 0;
51 // Clones this.
52 ManifestPermission* Clone() const;
54 // Returns a new manifest permission which equals this - |rhs|.
55 virtual ManifestPermission* Diff(const ManifestPermission* rhs) const = 0;
57 // Returns a new manifest permission which equals the union of this and |rhs|.
58 virtual ManifestPermission* Union(const ManifestPermission* rhs) const = 0;
60 // Returns a new manifest permission which equals the intersect of this and
61 // |rhs|.
62 virtual ManifestPermission* Intersect(const ManifestPermission* rhs)
63 const = 0;
65 // Returns true if |rhs| is a subset of this.
66 bool Contains(const ManifestPermission* rhs) const;
68 // Returns true if |rhs| is equal to this.
69 bool Equal(const ManifestPermission* rhs) const;
71 // IPC functions
72 // Writes this into the given IPC message |m|.
73 void Write(IPC::Message* m) const;
75 // Reads from the given IPC message |m|.
76 bool Read(const IPC::Message* m, base::PickleIterator* iter);
78 // Logs this permission.
79 void Log(std::string* log) const;
81 private:
82 DISALLOW_COPY_AND_ASSIGN(ManifestPermission);
85 } // namespace extensions
87 #endif // EXTENSIONS_COMMON_PERMISSIONS_MANIFEST_PERMISSION_H_