OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 | 4 |
5 #ifndef CHROME_COMMON_EXTENSIONS_API_SOCKETS_SOCKETS_HANDLER_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_API_SOCKETS_SOCKETS_HANDLER_H_ |
6 #define CHROME_COMMON_EXTENSIONS_API_SOCKETS_SOCKETS_HANDLER_H_ | 6 #define CHROME_COMMON_EXTENSIONS_API_SOCKETS_SOCKETS_HANDLER_H_ |
7 | 7 |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "chrome/common/extensions/extension.h" | 9 #include "chrome/common/extensions/extension.h" |
10 #include "chrome/common/extensions/manifest_handler.h" | 10 #include "chrome/common/extensions/manifest_handler.h" |
11 #include "chrome/common/extensions/permissions/socket_permission_data.h" | 11 #include "chrome/common/extensions/permissions/socket_permission_data.h" |
12 | 12 |
13 namespace extensions { | 13 namespace extensions { |
14 | 14 |
15 // Parses the "sockets" manifest key. | 15 // Parses the "sockets" manifest key. |
16 class SocketsHandler : public ManifestHandler { | 16 class SocketsHandler : public ManifestHandler { |
17 public: | 17 public: |
18 SocketsHandler(); | 18 SocketsHandler(); |
19 virtual ~SocketsHandler(); | 19 virtual ~SocketsHandler(); |
20 | 20 |
21 virtual bool Parse(Extension* extension, string16* error) OVERRIDE; | 21 virtual bool Parse(Extension* extension, string16* error) OVERRIDE; |
| 22 virtual void AddPermissionWarningMessages( |
| 23 const Extension* extension, |
| 24 std::vector<string16>& messages) const OVERRIDE; |
| 25 virtual void AddPermissionWarningMessagesDetails( |
| 26 const Extension* extension, |
| 27 std::vector<string16>& messages) const OVERRIDE; |
22 | 28 |
23 private: | 29 private: |
24 virtual const std::vector<std::string> Keys() const OVERRIDE; | 30 virtual const std::vector<std::string> Keys() const OVERRIDE; |
25 | 31 |
26 DISALLOW_COPY_AND_ASSIGN(SocketsHandler); | 32 DISALLOW_COPY_AND_ASSIGN(SocketsHandler); |
27 }; | 33 }; |
28 | 34 |
29 // The parsed form of the "sockets" manifest entry. | 35 // The parsed form of the "sockets" manifest entry. |
30 class SocketsManifestData : public Extension::ManifestData { | 36 class SocketsManifestData : public Extension::ManifestData { |
31 public: | 37 public: |
32 SocketsManifestData(); | 38 SocketsManifestData(); |
33 virtual ~SocketsManifestData(); | 39 virtual ~SocketsManifestData(); |
34 | 40 |
35 // Gets the ExternallyConnectableInfo for |extension|, or NULL if none was | 41 // Gets the SocketsManifestData for |extension|, or NULL if none was |
36 // specified. | 42 // specified. |
37 static SocketsManifestData* Get(const Extension* extension); | 43 static SocketsManifestData* Get(const Extension* extension); |
38 | 44 |
39 static bool CheckRequest(const Extension* extension, | 45 static bool CheckRequest(const Extension* extension, |
40 const content::SocketPermissionRequest& request); | 46 const content::SocketPermissionRequest& request); |
41 | 47 |
42 // Tries to construct the info based on |value|, as it would have appeared in | 48 // Tries to construct the info based on |value|, as it would have appeared in |
43 // the manifest. Sets |error| and returns an empty scoped_ptr on failure. | 49 // the manifest. Sets |error| and returns an empty scoped_ptr on failure. |
44 static scoped_ptr<SocketsManifestData> FromValue( | 50 static scoped_ptr<SocketsManifestData> FromValue( |
45 const base::Value& value, | 51 const base::Value& value, |
46 std::vector<InstallWarning>* install_warnings, | 52 std::vector<InstallWarning>* install_warnings, |
47 string16* error); | 53 string16* error); |
48 | 54 |
| 55 PermissionMessages GetPermissionMessages() const; |
| 56 |
49 private: | 57 private: |
50 typedef std::set<SocketPermissionEntry> PermissionSet; | 58 typedef std::set<SocketPermissionEntry> PermissionSet; |
51 | 59 |
52 static bool ParseHostPattern( | 60 static bool ParseHostPattern( |
53 SocketsManifestData* manifest_data, | 61 SocketsManifestData* manifest_data, |
54 content::SocketPermissionRequest::OperationType operation_type, | 62 content::SocketPermissionRequest::OperationType operation_type, |
55 const scoped_ptr<std::string>& value, | 63 const scoped_ptr<std::string>& value, |
56 string16* error); | 64 string16* error); |
57 | 65 |
58 void AddPermission(const SocketPermissionEntry& entry); | 66 void AddPermission(const SocketPermissionEntry& entry); |
59 | 67 |
60 bool CheckRequestImpl(const Extension* extension, | 68 bool CheckRequestImpl(const Extension* extension, |
61 const content::SocketPermissionRequest& request); | 69 const content::SocketPermissionRequest& request); |
62 | 70 |
| 71 bool AddAnyHostMessage(PermissionMessages& messages) const; |
| 72 void AddSubdomainHostMessage(PermissionMessages& messages) const; |
| 73 void AddSpecificHostMessage(PermissionMessages& messages) const; |
| 74 void AddNetworkListMessage(PermissionMessages& messages) const; |
| 75 |
63 PermissionSet permissions_; | 76 PermissionSet permissions_; |
64 }; | 77 }; |
65 | 78 |
66 } // namespace extensions | 79 } // namespace extensions |
67 | 80 |
68 #endif // CHROME_COMMON_EXTENSIONS_API_SOCKETS_SOCKETS_HANDLER_H_ | 81 #endif // CHROME_COMMON_EXTENSIONS_API_SOCKETS_SOCKETS_HANDLER_H_ |
OLD | NEW |