Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / extensions / common / api / sockets / sockets_manifest_permission.h
blobb6636d259884a00cf984e06a030d1f4baf3ea69c
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.
5 #ifndef EXTENSIONS_COMMON_API_SOCKETS_SOCKETS_MANIFEST_PERMISSION_H_
6 #define EXTENSIONS_COMMON_API_SOCKETS_SOCKETS_MANIFEST_PERMISSION_H_
8 #include <set>
9 #include <vector>
11 #include "extensions/common/install_warning.h"
12 #include "extensions/common/permissions/manifest_permission.h"
13 #include "extensions/common/permissions/socket_permission_entry.h"
15 namespace content {
16 struct SocketPermissionRequest;
19 namespace extensions {
20 class Extension;
23 namespace extensions {
25 typedef std::set<SocketPermissionEntry> SocketPermissionEntrySet;
27 class SocketsManifestPermission : public ManifestPermission {
28 public:
29 SocketsManifestPermission();
30 ~SocketsManifestPermission() override;
32 // Tries to construct the info based on |value|, as it would have appeared in
33 // the manifest. Sets |error| and returns an empty scoped_ptr on failure.
34 static scoped_ptr<SocketsManifestPermission> FromValue(
35 const base::Value& value,
36 base::string16* error);
38 bool CheckRequest(const Extension* extension,
39 const content::SocketPermissionRequest& request) const;
41 void AddPermission(const SocketPermissionEntry& entry);
43 // extensions::ManifestPermission overrides.
44 std::string name() const override;
45 std::string id() const override;
46 PermissionIDSet GetPermissions() const override;
47 bool HasMessages() const override;
48 PermissionMessages GetMessages() const override;
49 bool FromValue(const base::Value* value) override;
50 scoped_ptr<base::Value> ToValue() const override;
51 ManifestPermission* Diff(const ManifestPermission* rhs) const override;
52 ManifestPermission* Union(const ManifestPermission* rhs) const override;
53 ManifestPermission* Intersect(const ManifestPermission* rhs) const override;
55 const SocketPermissionEntrySet& entries() const { return permissions_; }
57 // Adds the permissions from |sockets| into the permission lists |ids| and
58 // |messages|. If either is NULL, that list is ignored.
59 static void AddSocketHostPermissions(const SocketPermissionEntrySet& sockets,
60 PermissionIDSet* ids,
61 PermissionMessages* messages);
63 SocketPermissionEntrySet permissions_;
66 } // namespace extensions
68 #endif // EXTENSIONS_COMMON_API_SOCKETS_SOCKETS_MANIFEST_PERMISSION_H_