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

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

Issue 23703008: Add network-status socket permission. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ' Created 7 years, 3 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 "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/common/extensions/permissions/api_permission.h" 10 #include "chrome/common/extensions/permissions/api_permission.h"
11 #include "content/public/common/socket_permission_request.h" 11 #include "content/public/common/socket_permission_request.h"
12 12
13 namespace extensions { 13 namespace extensions {
14 14
15 // A pattern that can be used to match socket permission. 15 // A pattern that can be used to match socket permission.
16 // <socket-permission-pattern> 16 // <socket-permission-pattern>
17 // := <op> | 17 // := <op> |
18 // <op> ':' <host> | 18 // <op> ':' <host> |
19 // <op> ':' ':' <port> | 19 // <op> ':' ':' <port> |
20 // <op> ':' <host> ':' <port> | 20 // <op> ':' <host> ':' <port> |
21 // 'udp-multicast-membership' 21 // 'udp-multicast-membership'
22 // <op> := 'tcp-connect' | 22 // <op> := 'tcp-connect' |
23 // 'tcp-listen' | 23 // 'tcp-listen' |
24 // 'udp-bind' | 24 // 'udp-bind' |
25 // 'udp-send-to' 25 // 'udp-send-to' |
26 // 'udp-multicast-membership' |
27 // 'resolve-host' |
28 // 'resolve-proxy' |
29 // 'network-state'
26 // <host> := '*' | 30 // <host> := '*' |
27 // '*.' <anychar except '/' and '*'>+ | 31 // '*.' <anychar except '/' and '*'>+ |
28 // <anychar except '/' and '*'>+ 32 // <anychar except '/' and '*'>+
29 // <port> := '*' | 33 // <port> := '*' |
30 // <port number between 0 and 65535>) 34 // <port number between 0 and 65535>)
31 // The multicast membership permission implies a permission to any address. 35 // The multicast membership permission implies a permission to any address.
32 class SocketPermissionData { 36 class SocketPermissionData {
33 public: 37 public:
34 enum HostType { 38 enum HostType {
35 ANY_HOST, 39 ANY_HOST,
(...skipping 12 matching lines...) Expand all
48 // Check if |param| (which must be a SocketPermissionData::CheckParam) 52 // Check if |param| (which must be a SocketPermissionData::CheckParam)
49 // matches the spec of |this|. 53 // matches the spec of |this|.
50 bool Check(const APIPermission::CheckParam* param) const; 54 bool Check(const APIPermission::CheckParam* param) const;
51 55
52 // Convert |this| into a base::Value. 56 // Convert |this| into a base::Value.
53 scoped_ptr<base::Value> ToValue() const; 57 scoped_ptr<base::Value> ToValue() const;
54 58
55 // Populate |this| from a base::Value. 59 // Populate |this| from a base::Value.
56 bool FromValue(const base::Value* value); 60 bool FromValue(const base::Value* value);
57 61
62 // Returns true if the permission type can be bound to a host or port.
63 bool IsAddressBoundType() const;
64
58 HostType GetHostType() const; 65 HostType GetHostType() const;
59 const std::string GetHost() const; 66 const std::string GetHost() const;
60 67
61 const content::SocketPermissionRequest& pattern() const { return pattern_; } 68 const content::SocketPermissionRequest& pattern() const { return pattern_; }
62 const bool& match_subdomains() const { return match_subdomains_; } 69 const bool& match_subdomains() const { return match_subdomains_; }
63 70
64 // These accessors are provided for IPC_STRUCT_TRAITS_MEMBER. Please 71 // These accessors are provided for IPC_STRUCT_TRAITS_MEMBER. Please
65 // think twice before using them for anything else. 72 // think twice before using them for anything else.
66 content::SocketPermissionRequest& pattern(); 73 content::SocketPermissionRequest& pattern();
67 bool& match_subdomains(); 74 bool& match_subdomains();
(...skipping 10 matching lines...) Expand all
78 void Reset(); 85 void Reset();
79 86
80 content::SocketPermissionRequest pattern_; 87 content::SocketPermissionRequest pattern_;
81 bool match_subdomains_; 88 bool match_subdomains_;
82 mutable std::string spec_; 89 mutable std::string spec_;
83 }; 90 };
84 91
85 } // namespace extensions 92 } // namespace extensions
86 93
87 #endif // CHROME_COMMON_EXTENSIONS_PERMISSIONS_SOCKET_PERMISSION_DATA_H_ 94 #endif // CHROME_COMMON_EXTENSIONS_PERMISSIONS_SOCKET_PERMISSION_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698