Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: chrome/common/extensions/permissions/socket_permission.h

Issue 10692160: Support socket endpoint permissions for AppsV2 Socket API. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase and fix a unit test Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012 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.
4
5 #ifndef CHROME_COMMON_EXTENSIONS_PERMISSIONS_SOCKET_PERMISSION_H_
6 #define CHROME_COMMON_EXTENSIONS_PERMISSIONS_SOCKET_PERMISSION_H_
7
8 #include <set>
9 #include <string>
10
11 #include "chrome/common/extensions/permissions/api_permission.h"
12 #include "chrome/common/extensions/permissions/socket_permission_data.h"
13
14 namespace base {
15 class Value;
16 }
17
18 namespace IPC {
19 class Message;
20 }
21
22 namespace extensions {
23
24 class SocketPermission : public APIPermissionDetail {
25 public:
26 struct CheckParam : APIPermissionDetail::CheckParam {
27 CheckParam(SocketPermissionData::OperationType type,
28 const std::string& host,
29 int port)
30 : type(type),
31 host(host),
32 port(port) { }
33 SocketPermissionData::OperationType type;
34 std::string host;
35 int port;
36 };
37
38 explicit SocketPermission(const APIPermission* permission);
39
40 // Returns true if the given permission in param is allowed.
41 virtual bool Check(
42 const APIPermissionDetail::CheckParam* param) const OVERRIDE;
43
44 // Returns true if |detail| is a subset of this.
45 virtual bool Contains(const APIPermissionDetail* rhs) const OVERRIDE;
46
47 // Returns true if |detail| is equal to this.
48 virtual bool Equal(const APIPermissionDetail* rhs) const OVERRIDE;
49
50 // Parses the detail from |value|. Returns false if error happens.
51 virtual bool FromValue(const base::Value* value) OVERRIDE;
52
53 // Stores this into a new created |value|.
54 virtual void ToValue(base::Value** value) const OVERRIDE;
55
56 // Clones this.
57 virtual APIPermissionDetail* Clone() const OVERRIDE;
58
59 // Returns a new API permission detail which equals this - |detail|.
60 virtual APIPermissionDetail* Diff(
61 const APIPermissionDetail* rhs) const OVERRIDE;
62
63 // Returns a new API permission detail which equals the union of this and
64 // |detail|.
65 virtual APIPermissionDetail* Union(
66 const APIPermissionDetail* rhs) const OVERRIDE;
67
68 // Returns a new API permission detail which equals the intersect of this and
69 // |detail|.
70 virtual APIPermissionDetail* Intersect(
71 const APIPermissionDetail* rhs) const OVERRIDE;
72
73 // IPC functions
74 // Writes this into the given IPC message |m|.
75 virtual void Write(IPC::Message* m) const OVERRIDE;
76
77 // Reads from the given IPC message |m|.
78 virtual bool Read(const IPC::Message* m, PickleIterator* iter) OVERRIDE;
79
80 // Logs this detail.
81 virtual void Log(std::string* log) const OVERRIDE;
82
83 protected:
84 friend class base::RefCounted<APIPermissionDetail>;
85
86 virtual ~SocketPermission();
87
88 private:
89 std::set<SocketPermissionData> data_set_;
90 };
91
92 } // namespace extensions
93
94 #endif // CHROME_COMMON_EXTENSIONS_PERMISSIONS_SOCKET_PERMISSION_H_
OLDNEW
« no previous file with comments | « chrome/common/extensions/permissions/permissions_info.cc ('k') | chrome/common/extensions/permissions/socket_permission.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698