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

Side by Side Diff: chrome/common/extensions/permissions/socket_permission_data.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 #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.
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 // operators <, == are needed by container std::set and algorithms
32 // std::set_includes and std::set_differences.
33 bool operator<(const SocketPermissionData& rhs) const;
34 bool operator==(const SocketPermissionData& rhs) const;
35
36 bool Match(OperationType type, const std::string& host, int port) const;
37
38 bool Parse(const std::string& permission);
39
40 const std::string& GetAsString() const;
41
42 private:
43 void Reset();
44
45 OperationType type_;
46 std::string host_;
47 bool match_subdomains_;
48 int port_;
49 mutable std::string spec_;
50 };
51
52 } // namespace extensions
53
54 #endif // CHROME_COMMON_EXTENSIONS_PERMISSIONS_SOCKET_PERMISSION_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698