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

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

Issue 10993078: Use extensions socket permission for TCP/UDP socket APIs in Pepper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove duplication Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 #ifndef CHROME_COMMON_EXTENSIONS_PERMISSIONS_SOCKET_PERMISSION_DATA_H_ 4 #ifndef CHROME_COMMON_EXTENSIONS_PERMISSIONS_SOCKET_PERMISSION_DATA_H_
5 #define CHROME_COMMON_EXTENSIONS_PERMISSIONS_SOCKET_PERMISSION_DATA_H_ 5 #define CHROME_COMMON_EXTENSIONS_PERMISSIONS_SOCKET_PERMISSION_DATA_H_
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "content/public/browser/socket_permission_request.h"
10
9 namespace extensions { 11 namespace extensions {
10 12
11 // A pattern that can be used to match socket permission. 13 // A pattern that can be used to match socket permission.
12 // <socket-permission-pattern> 14 // <socket-permission-pattern>
13 // := <op> | 15 // := <op> |
14 // <op> ':' <host> | 16 // <op> ':' <host> |
15 // <op> ':' ':' <port> | 17 // <op> ':' ':' <port> |
16 // <op> ':' <host> ':' <port> 18 // <op> ':' <host> ':' <port>
17 // <op> := 'tcp-connect' | 19 // <op> := 'tcp-connect' |
18 // 'tcp-listen' | 20 // 'tcp-listen' |
19 // 'udp-bind' | 21 // 'udp-bind' |
20 // 'udp-send-to' 22 // 'udp-send-to'
21 // <host> := '*' | 23 // <host> := '*' |
22 // '*.' <anychar except '/' and '*'>+ | 24 // '*.' <anychar except '/' and '*'>+ |
23 // <anychar except '/' and '*'>+ 25 // <anychar except '/' and '*'>+
24 // <port> := '*' | 26 // <port> := '*' |
25 // <port number between 0 and 65535>) 27 // <port number between 0 and 65535>)
26 class SocketPermissionData { 28 class SocketPermissionData {
27 public: 29 public:
28 enum OperationType {
29 NONE = 0,
30 TCP_CONNECT,
31 TCP_LISTEN,
32 UDP_BIND,
33 UDP_SEND_TO,
34 };
35
36 enum HostType { 30 enum HostType {
37 ANY_HOST, 31 ANY_HOST,
38 HOSTS_IN_DOMAINS, 32 HOSTS_IN_DOMAINS,
39 SPECIFIC_HOSTS, 33 SPECIFIC_HOSTS,
40 }; 34 };
41 35
42 SocketPermissionData(); 36 SocketPermissionData();
43 ~SocketPermissionData(); 37 ~SocketPermissionData();
44 38
45 // operators <, == are needed by container std::set and algorithms 39 // operators <, == are needed by container std::set and algorithms
46 // std::set_includes and std::set_differences. 40 // std::set_includes and std::set_differences.
47 bool operator<(const SocketPermissionData& rhs) const; 41 bool operator<(const SocketPermissionData& rhs) const;
48 bool operator==(const SocketPermissionData& rhs) const; 42 bool operator==(const SocketPermissionData& rhs) const;
49 43
50 bool Match(OperationType type, const std::string& host, int port) const; 44 bool Match(content::SocketPermissionRequest request) const;
51 45
52 bool Parse(const std::string& permission); 46 bool Parse(const std::string& permission);
53 47
54 HostType GetHostType() const; 48 HostType GetHostType() const;
55 const std::string GetHost() const; 49 const std::string GetHost() const;
56 50
57 const std::string& GetAsString() const; 51 const std::string& GetAsString() const;
58 52
59 private: 53 private:
60 void Reset(); 54 void Reset();
61 55
62 OperationType type_; 56 content::SocketPermissionRequest::OperationType type_;
jam 2012/10/18 15:37:15 why only bring in the enum here? i.e. why not the
dpolukhin 2012/10/18 18:01:00 This class represents pattern for matching not a r
jam 2012/10/18 18:17:06 I'm not sure I follow the distinction, i.e. why do
dpolukhin 2012/10/18 18:30:34 New SocketPermissionRequest has 1:1: correspondenc
jam 2012/10/18 21:21:34 so it's just a coincidence that they both have hos
Dmitry Polukhin 2012/10/19 09:24:00 They are related but not the same. But I did it be
63 std::string host_; 57 std::string host_;
64 bool match_subdomains_; 58 bool match_subdomains_;
65 int port_; 59 int port_;
66 mutable std::string spec_; 60 mutable std::string spec_;
67 }; 61 };
68 62
69 } // namespace extensions 63 } // namespace extensions
70 64
71 #endif // CHROME_COMMON_EXTENSIONS_PERMISSIONS_SOCKET_PERMISSION_DATA_H_ 65 #endif // CHROME_COMMON_EXTENSIONS_PERMISSIONS_SOCKET_PERMISSION_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698