OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_BROWSER_API_VPN_PROVIDER_VPN_SERVICE_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_VPN_PROVIDER_VPN_SERVICE_H_ |
6 #define EXTENSIONS_BROWSER_API_VPN_PROVIDER_VPN_SERVICE_H_ | 6 #define EXTENSIONS_BROWSER_API_VPN_PROVIDER_VPN_SERVICE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 class NetworkStateHandler; | 46 class NetworkStateHandler; |
47 class ShillThirdPartyVpnDriverClient; | 47 class ShillThirdPartyVpnDriverClient; |
48 | 48 |
49 // The class manages the VPN configurations. | 49 // The class manages the VPN configurations. |
50 class VpnService : public KeyedService, | 50 class VpnService : public KeyedService, |
51 public NetworkConfigurationObserver, | 51 public NetworkConfigurationObserver, |
52 public NetworkStateHandlerObserver, | 52 public NetworkStateHandlerObserver, |
53 public extensions::ExtensionRegistryObserver { | 53 public extensions::ExtensionRegistryObserver { |
54 public: | 54 public: |
55 using SuccessCallback = base::Closure; | 55 using SuccessCallback = base::Closure; |
| 56 using StringCallback = base::Callback<void(const std::string& result)>; |
56 using FailureCallback = | 57 using FailureCallback = |
57 base::Callback<void(const std::string& error_name, | 58 base::Callback<void(const std::string& error_name, |
58 const std::string& error_message)>; | 59 const std::string& error_message)>; |
59 | 60 |
60 VpnService(content::BrowserContext* browser_context, | 61 VpnService(content::BrowserContext* browser_context, |
61 const std::string& userid_hash, | 62 const std::string& userid_hash, |
62 extensions::ExtensionRegistry* extension_registry, | 63 extensions::ExtensionRegistry* extension_registry, |
63 extensions::EventRouter* event_router, | 64 extensions::EventRouter* event_router, |
64 ShillThirdPartyVpnDriverClient* shill_client, | 65 ShillThirdPartyVpnDriverClient* shill_client, |
65 NetworkConfigurationHandler* network_configuration_handler, | 66 NetworkConfigurationHandler* network_configuration_handler, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 void DestroyConfiguration(const std::string& extension_id, | 120 void DestroyConfiguration(const std::string& extension_id, |
120 const std::string& configuration_id, | 121 const std::string& configuration_id, |
121 const SuccessCallback& success, | 122 const SuccessCallback& success, |
122 const FailureCallback& failure); | 123 const FailureCallback& failure); |
123 | 124 |
124 // Set |parameters| for the active VPN configuration after verifying that it | 125 // Set |parameters| for the active VPN configuration after verifying that it |
125 // belongs to the extension with id |extension_id|. | 126 // belongs to the extension with id |extension_id|. |
126 // Calls |success| or |failure| based on the outcome. | 127 // Calls |success| or |failure| based on the outcome. |
127 void SetParameters(const std::string& extension_id, | 128 void SetParameters(const std::string& extension_id, |
128 const base::DictionaryValue& parameters, | 129 const base::DictionaryValue& parameters, |
129 const SuccessCallback& success, | 130 const StringCallback& success, |
130 const FailureCallback& failure); | 131 const FailureCallback& failure); |
131 | 132 |
132 // Sends an IP packet contained in |data| to the active VPN configuration | 133 // Sends an IP packet contained in |data| to the active VPN configuration |
133 // after verifying that it belongs to the extension with id |extension_id|. | 134 // after verifying that it belongs to the extension with id |extension_id|. |
134 // Calls |success| or |failure| based on the outcome. | 135 // Calls |success| or |failure| based on the outcome. |
135 void SendPacket(const std::string& extension_id, | 136 void SendPacket(const std::string& extension_id, |
136 const std::vector<char>& data, | 137 const std::vector<char>& data, |
137 const SuccessCallback& success, | 138 const SuccessCallback& success, |
138 const FailureCallback& failure); | 139 const FailureCallback& failure); |
139 | 140 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 StringToConfigurationMap service_path_to_configuration_map_; | 237 StringToConfigurationMap service_path_to_configuration_map_; |
237 | 238 |
238 base::WeakPtrFactory<VpnService> weak_factory_; | 239 base::WeakPtrFactory<VpnService> weak_factory_; |
239 | 240 |
240 DISALLOW_COPY_AND_ASSIGN(VpnService); | 241 DISALLOW_COPY_AND_ASSIGN(VpnService); |
241 }; | 242 }; |
242 | 243 |
243 } // namespace chromeos | 244 } // namespace chromeos |
244 | 245 |
245 #endif // EXTENSIONS_BROWSER_API_VPN_PROVIDER_VPN_SERVICE_H_ | 246 #endif // EXTENSIONS_BROWSER_API_VPN_PROVIDER_VPN_SERVICE_H_ |
OLD | NEW |