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 #ifndef CHROME_COMMON_EXTENSIONS_PERMISSIONS_SOCKET_PERMISSION_DATA_H_ | |
5 #define CHROME_COMMON_EXTENSIONS_PERMISSIONS_SOCKET_PERMISSION_DATA_H_ | |
6 | |
7 #include <string> | |
8 | |
9 namespace extensions { | |
10 | |
11 // A pattern that can be used to match socket permission. | |
miket_OOO
2012/08/06 21:04:06
This seems to be a very unit-testable class, but t
Peng
2012/08/07 21:31:55
Done
| |
12 // <socket-permission-pattern> | |
13 // := <op> | <op> ':' <host> | <op> ':' ':' <port> | | |
14 // <op> ':' <host> ':' <port> | |
15 // <op> := 'tcp-connect' | 'tcp-listen' | 'udp-bind' | 'udp-send-to' | |
16 // <host> := '*' | '*.' <anychar except '/' and '*'>+ | |
17 // <port> := '*' | <port number between 0 and 65535>) | |
18 class SocketPermissionData { | |
19 public: | |
20 enum OperationType { | |
21 NONE = 0, | |
22 TCP_CONNECT, | |
23 TCP_LISTEN, | |
24 UDP_BIND, | |
25 UDP_SEND_TO, | |
26 }; | |
27 | |
28 SocketPermissionData(); | |
29 ~SocketPermissionData(); | |
30 | |
31 bool operator<(const SocketPermissionData& rhs) const; | |
32 bool operator==(const SocketPermissionData& rhs) const; | |
33 | |
34 bool Match(OperationType type, const std::string& host, int port) const; | |
35 | |
36 bool Parse(const std::string& permission); | |
37 | |
38 const std::string& GetAsString() const; | |
39 | |
40 private: | |
41 OperationType type_; | |
42 std::string host_; | |
43 bool match_subdomains_; | |
44 int port_; | |
45 mutable std::string spec_; | |
46 }; | |
47 | |
48 } // namespace extensions | |
49 | |
50 #endif // CHROME_COMMON_EXTENSIONS_PERMISSIONS_SOCKET_PERMISSION_DATA_H_ | |
OLD | NEW |