Chromium Code Reviews| Index: chrome/common/extensions/api/sockets/sockets_handler.h |
| diff --git a/chrome/common/extensions/api/sockets/sockets_handler.h b/chrome/common/extensions/api/sockets/sockets_handler.h |
| index 28594071754ed847da758d280c58f7f9f1e8085a..8bc640951f7b55cc2d2d924d01a929ddadbe7c40 100644 |
| --- a/chrome/common/extensions/api/sockets/sockets_handler.h |
| +++ b/chrome/common/extensions/api/sockets/sockets_handler.h |
| @@ -19,6 +19,9 @@ class SocketsHandler : public ManifestHandler { |
| virtual ~SocketsHandler(); |
| virtual bool Parse(Extension* extension, string16* error) OVERRIDE; |
| + virtual ManifestPermission* CreatePermission() OVERRIDE; |
| + virtual ManifestPermission* CreateInitialRequiredPermission( |
| + const Extension* extension) OVERRIDE; |
| private: |
| virtual const std::vector<std::string> Keys() const OVERRIDE; |
| @@ -29,10 +32,18 @@ class SocketsHandler : public ManifestHandler { |
| // The parsed form of the "sockets" manifest entry. |
| class SocketsManifestData : public Extension::ManifestData { |
| public: |
| + typedef std::set<SocketPermissionEntry> SocketPermissionEntrySet; |
| + enum PermissionKind { |
| + kNone = 0, |
| + kTcpPermission = 1 << 0, |
| + kUdpPermission = 1 << 1, |
| + kTcpServerPermission = 1 << 2 |
| + }; |
| + |
| SocketsManifestData(); |
| virtual ~SocketsManifestData(); |
| - // Gets the ExternallyConnectableInfo for |extension|, or NULL if none was |
| + // Gets the SocketsManifestData for |extension|, or NULL if none was |
| // specified. |
| static SocketsManifestData* Get(const Extension* extension); |
| @@ -46,21 +57,52 @@ class SocketsManifestData : public Extension::ManifestData { |
| std::vector<InstallWarning>* install_warnings, |
| string16* error); |
| - private: |
| - typedef std::set<SocketPermissionEntry> PermissionSet; |
| + // Stores this into a new created |value|. |
|
Yoyo Zhou
2013/11/13 02:57:07
nit: |value| would be used to name an argument. Sa
rpaquay
2013/11/13 21:28:55
Done.
|
| + scoped_ptr<base::Value> ToValue() const; |
| + |
| + bool HasMessages() const; |
| + PermissionMessages GetPermissionMessages() const; |
| + |
| + SocketsManifestData* Diff(const SocketsManifestData* rhs) const; |
| + SocketsManifestData* Union(const SocketsManifestData* rhs) const; |
| + SocketsManifestData* Intersect(const SocketsManifestData* rhs) const; |
| + bool Contains(const SocketsManifestData* rhs) const; |
| + bool Equal(const SocketsManifestData* rhs) const; |
| + SocketsManifestData* Clone() const; |
| + |
| + // IPC functions |
| + void Write(IPC::Message* m) const; |
| + bool Read(const IPC::Message* m, PickleIterator* iter); |
| + void Log(std::string* log) const; |
| + const SocketPermissionEntrySet& entries() const { return permissions_; } |
| + |
| + bool has_udp() const { return (kinds_ & kUdpPermission) != 0; } |
| + bool has_tcp() const { return (kinds_ & kTcpPermission) != 0; } |
| + bool has_tcp_server() const { return (kinds_ & kTcpServerPermission) != 0; } |
| + |
| + private: |
| static bool ParseHostPattern( |
| SocketsManifestData* manifest_data, |
| content::SocketPermissionRequest::OperationType operation_type, |
| const scoped_ptr<std::string>& value, |
| string16* error); |
| + scoped_ptr<std::string> CreateHostPattern( |
| + content::SocketPermissionRequest::OperationType operation_type) const; |
| + |
| void AddPermission(const SocketPermissionEntry& entry); |
| bool CheckRequestImpl(const Extension* extension, |
| const content::SocketPermissionRequest& request); |
| - PermissionSet permissions_; |
| + bool AddAnyHostMessage(PermissionMessages& messages) const; |
| + void AddSubdomainHostMessage(PermissionMessages& messages) const; |
| + void AddSpecificHostMessage(PermissionMessages& messages) const; |
| + void AddNetworkListMessage(PermissionMessages& messages) const; |
| + |
| + SocketPermissionEntrySet permissions_; |
| + int kinds_; // PermissionKind bits |
| }; |
| } // namespace extensions |