OLD | NEW |
---|---|
(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 "chrome/common/extensions/permissions/api_permission.h" | |
9 #include "chrome/common/extensions/permissions/socket_permission_data.h" | |
10 | |
11 namespace extensions { | |
12 | |
13 class SocketPermission : public APIPermissionDetail { | |
14 public: | |
15 struct CheckParam : APIPermissionDetail::CheckParam { | |
16 CheckParam(SocketPermissionData::OperationType type, | |
17 const std::string& host, | |
18 int port) | |
19 : type(type), | |
20 host(host), | |
21 port(port) { } | |
22 SocketPermissionData::OperationType type; | |
23 std::string host; | |
24 int port; | |
25 }; | |
26 | |
27 explicit SocketPermission(const APIPermission* permission); | |
28 | |
29 // Returns true if the given permission in param is allowed. | |
30 virtual bool Check( | |
31 const APIPermissionDetail::CheckParam* param) const OVERRIDE; | |
32 | |
33 // Returns true if |detail| is a subset of this. | |
34 virtual bool Contains(const APIPermissionDetail* rhs) const OVERRIDE; | |
35 | |
36 // Returns true if |detail| is equal to this. | |
37 virtual bool Equal(const APIPermissionDetail* rhs) const OVERRIDE; | |
38 | |
39 // Parses the detail from |value|. Returns false if error happens. | |
40 virtual bool FromValue(const base::Value* value) OVERRIDE; | |
41 | |
42 // Stores this into a new created |value|. | |
43 virtual void ToValue(base::Value** value) const OVERRIDE; | |
44 | |
45 // Clones this. | |
46 virtual APIPermissionDetail* Clone() const OVERRIDE; | |
47 | |
48 // Returns a new API permission detail which equals this - |detail|. | |
49 virtual APIPermissionDetail* Diff( | |
50 const APIPermissionDetail* rhs) const OVERRIDE; | |
51 | |
52 // Returns a new API permission detail which equals the union of this and | |
53 // |detail|. | |
54 virtual APIPermissionDetail* Union( | |
55 const APIPermissionDetail* rhs) const OVERRIDE; | |
56 | |
57 // Returns a new API permission detail which equals the intersect of this and | |
58 // |detail|. | |
59 virtual APIPermissionDetail* Intersect( | |
60 const APIPermissionDetail* rhs) const OVERRIDE; | |
61 | |
62 // IPC functions | |
63 // Writes this into the given IPC message |m|. | |
64 virtual void Write(IPC::Message* m) const OVERRIDE; | |
65 | |
66 // Reads from the given IPC message |m|. | |
67 virtual bool Read(const IPC::Message* m, PickleIterator* iter) OVERRIDE; | |
68 | |
69 // Logs this detail. | |
70 virtual void Log(std::string* log) const OVERRIDE; | |
71 | |
72 protected: | |
73 friend base::RefCounted<APIPermissionDetail>; | |
74 | |
75 virtual ~SocketPermission(); | |
76 | |
77 private: | |
miket_OOO
2012/08/06 21:04:06
You should #include <set>, as well as other stuff
Peng
2012/08/07 21:31:55
Done.
| |
78 std::set<SocketPermissionData> data_set_; | |
79 }; | |
80 | |
81 } // namespace extensions | |
82 | |
83 #endif // CHROME_COMMON_EXTENSIONS_PERMISSIONS_SOCKET_PERMISSION_H_ | |
OLD | NEW |