Index: chrome/common/extensions/permissions/socket_permission_data.h |
diff --git a/chrome/common/extensions/permissions/socket_permission_data.h b/chrome/common/extensions/permissions/socket_permission_data.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8d89103170c6e21d524c9cc34667c8be22b64255 |
--- /dev/null |
+++ b/chrome/common/extensions/permissions/socket_permission_data.h |
@@ -0,0 +1,52 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+#ifndef CHROME_COMMON_EXTENSIONS_PERMISSIONS_SOCKET_PERMISSION_DATA_H_ |
+#define CHROME_COMMON_EXTENSIONS_PERMISSIONS_SOCKET_PERMISSION_DATA_H_ |
+ |
+#include <string> |
+ |
+namespace extensions { |
+ |
+// A pattern that can be used to match socket permission. |
+// <socket-permission-pattern> |
+// := <op> | <op> ':' <host> | <op> ':' ':' <port> | |
+// <op> ':' <host> ':' <port> |
+// <op> := 'tcp-connect' | 'tcp-listen' | 'udp-bind' | 'udp-send-to' |
+// <host> := '*' | '*.' <anychar except '/' and '*'>+ |
+// <port> := '*' | <port number between 0 and 65535>) |
+class SocketPermissionData { |
+ public: |
+ enum OperationType { |
+ NONE = 0, |
+ TCP_CONNECT, |
+ TCP_LISTEN, |
+ UDP_BIND, |
+ UDP_SEND_TO, |
+ }; |
+ |
+ SocketPermissionData(); |
+ ~SocketPermissionData(); |
+ |
+ bool operator<(const SocketPermissionData& rhs) const; |
Mihai Parparita -not on Chrome
2012/08/10 00:16:16
The C++ style guide says " In particular, do not o
Peng
2012/08/13 16:26:10
Done. Have to keep them. They are also used by std
|
+ bool operator==(const SocketPermissionData& rhs) const; |
+ |
+ bool Match(OperationType type, const std::string& host, int port) const; |
+ |
+ bool Parse(const std::string& permission); |
+ |
+ const std::string& GetAsString() const; |
+ |
+ private: |
+ void Reset(); |
+ |
+ OperationType type_; |
+ std::string host_; |
+ bool match_subdomains_; |
+ int port_; |
+ mutable std::string spec_; |
+}; |
+ |
+} // namespace extensions |
+ |
+#endif // CHROME_COMMON_EXTENSIONS_PERMISSIONS_SOCKET_PERMISSION_DATA_H_ |