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_
11 #include "extensions/common/install_warning.h"
12 #include "extensions/common/permissions/manifest_permission.h"
13 #include "extensions/common/permissions/socket_permission_entry.h"
16 struct SocketPermissionRequest
;
19 namespace extensions
{
23 namespace extensions
{
25 class SocketsManifestPermission
: public ManifestPermission
{
27 typedef std::set
<SocketPermissionEntry
> SocketPermissionEntrySet
;
28 SocketsManifestPermission();
29 virtual ~SocketsManifestPermission();
31 // Tries to construct the info based on |value|, as it would have appeared in
32 // the manifest. Sets |error| and returns an empty scoped_ptr on failure.
33 static scoped_ptr
<SocketsManifestPermission
> FromValue(
34 const base::Value
& value
,
35 base::string16
* error
);
37 bool CheckRequest(const Extension
* extension
,
38 const content::SocketPermissionRequest
& request
) const;
40 void AddPermission(const SocketPermissionEntry
& entry
);
42 // extensions::ManifestPermission overrides.
43 virtual std::string
name() const OVERRIDE
;
44 virtual std::string
id() const OVERRIDE
;
45 virtual bool HasMessages() const OVERRIDE
;
46 virtual PermissionMessages
GetMessages() const OVERRIDE
;
47 virtual bool FromValue(const base::Value
* value
) OVERRIDE
;
48 virtual scoped_ptr
<base::Value
> ToValue() const OVERRIDE
;
49 virtual ManifestPermission
* Diff(const ManifestPermission
* rhs
) const
51 virtual ManifestPermission
* Union(const ManifestPermission
* rhs
) const
53 virtual ManifestPermission
* Intersect(const ManifestPermission
* rhs
) const
56 const SocketPermissionEntrySet
& entries() const { return permissions_
; }
59 bool AddAnyHostMessage(PermissionMessages
& messages
) const;
60 void AddSubdomainHostMessage(PermissionMessages
& messages
) const;
61 void AddSpecificHostMessage(PermissionMessages
& messages
) const;
62 void AddNetworkListMessage(PermissionMessages
& messages
) const;
64 SocketPermissionEntrySet permissions_
;
67 } // namespace extensions
69 #endif // EXTENSIONS_COMMON_API_SOCKETS_SOCKETS_MANIFEST_PERMISSION_H_