Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / extensions / common / api / sockets / sockets_manifest_permission.h
blob8aa8be20dd8930f8c7fef8ae095b57c5dc922137
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 class SocketsManifestPermission : public ManifestPermission {
26 public:
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
50 OVERRIDE;
51 virtual ManifestPermission* Union(const ManifestPermission* rhs) const
52 OVERRIDE;
53 virtual ManifestPermission* Intersect(const ManifestPermission* rhs) const
54 OVERRIDE;
56 const SocketPermissionEntrySet& entries() const { return permissions_; }
58 private:
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_