| 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 <memory> |
| 9 #include <string> | 10 #include <string> |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "base/callback.h" | 13 #include "base/callback.h" |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "chromeos/network/network_configuration_observer.h" | 16 #include "chromeos/network/network_configuration_observer.h" |
| 17 #include "chromeos/network/network_state_handler_observer.h" | 17 #include "chromeos/network/network_state_handler_observer.h" |
| 18 #include "components/keyed_service/core/keyed_service.h" | 18 #include "components/keyed_service/core/keyed_service.h" |
| 19 #include "extensions/browser/extension_event_histogram_value.h" | 19 #include "extensions/browser/extension_event_histogram_value.h" |
| 20 #include "extensions/browser/extension_registry_observer.h" | 20 #include "extensions/browser/extension_registry_observer.h" |
| 21 #include "extensions/common/api/vpn_provider.h" | 21 #include "extensions/common/api/vpn_provider.h" |
| 22 | 22 |
| 23 namespace base { | 23 namespace base { |
| 24 | 24 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 void OnCreateConfigurationSuccess(const SuccessCallback& callback, | 171 void OnCreateConfigurationSuccess(const SuccessCallback& callback, |
| 172 VpnConfiguration* configuration, | 172 VpnConfiguration* configuration, |
| 173 const std::string& service_path, | 173 const std::string& service_path, |
| 174 const std::string& guid); | 174 const std::string& guid); |
| 175 | 175 |
| 176 // Callback used to indicate that configuration creation failed. | 176 // Callback used to indicate that configuration creation failed. |
| 177 void OnCreateConfigurationFailure( | 177 void OnCreateConfigurationFailure( |
| 178 const FailureCallback& callback, | 178 const FailureCallback& callback, |
| 179 VpnConfiguration* configuration, | 179 VpnConfiguration* configuration, |
| 180 const std::string& error_name, | 180 const std::string& error_name, |
| 181 scoped_ptr<base::DictionaryValue> error_data); | 181 std::unique_ptr<base::DictionaryValue> error_data); |
| 182 | 182 |
| 183 // Callback used to indicate that removing a configuration succeeded. | 183 // Callback used to indicate that removing a configuration succeeded. |
| 184 void OnRemoveConfigurationSuccess(const SuccessCallback& callback); | 184 void OnRemoveConfigurationSuccess(const SuccessCallback& callback); |
| 185 | 185 |
| 186 // Callback used to indicate that removing a configuration failed. | 186 // Callback used to indicate that removing a configuration failed. |
| 187 void OnRemoveConfigurationFailure( | 187 void OnRemoveConfigurationFailure( |
| 188 const FailureCallback& callback, | 188 const FailureCallback& callback, |
| 189 const std::string& error_name, | 189 const std::string& error_name, |
| 190 scoped_ptr<base::DictionaryValue> error_data); | 190 std::unique_ptr<base::DictionaryValue> error_data); |
| 191 | 191 |
| 192 // Callback used to indicate that GetProperties was successful. | 192 // Callback used to indicate that GetProperties was successful. |
| 193 void OnGetPropertiesSuccess(const std::string& service_path, | 193 void OnGetPropertiesSuccess(const std::string& service_path, |
| 194 const base::DictionaryValue& dictionary); | 194 const base::DictionaryValue& dictionary); |
| 195 | 195 |
| 196 // Callback used to indicate that GetProperties failed. | 196 // Callback used to indicate that GetProperties failed. |
| 197 void OnGetPropertiesFailure(const std::string& error_name, | 197 void OnGetPropertiesFailure( |
| 198 scoped_ptr<base::DictionaryValue> error_data); | 198 const std::string& error_name, |
| 199 std::unique_ptr<base::DictionaryValue> error_data); |
| 199 | 200 |
| 200 // Creates and adds the configuration to the internal store. | 201 // Creates and adds the configuration to the internal store. |
| 201 VpnConfiguration* CreateConfigurationInternal( | 202 VpnConfiguration* CreateConfigurationInternal( |
| 202 const std::string& extension_id, | 203 const std::string& extension_id, |
| 203 const std::string& configuration_name, | 204 const std::string& configuration_name, |
| 204 const std::string& key); | 205 const std::string& key); |
| 205 | 206 |
| 206 // Removes configuration from the internal store and destroys it. | 207 // Removes configuration from the internal store and destroys it. |
| 207 void DestroyConfigurationInternal(VpnConfiguration* configuration); | 208 void DestroyConfigurationInternal(VpnConfiguration* configuration); |
| 208 | 209 |
| 209 // Verifies if |active_configuration_| exists and if the extension with id | 210 // Verifies if |active_configuration_| exists and if the extension with id |
| 210 // |extension_id| is authorized to access it. | 211 // |extension_id| is authorized to access it. |
| 211 bool DoesActiveConfigurationExistAndIsAccessAuthorized( | 212 bool DoesActiveConfigurationExistAndIsAccessAuthorized( |
| 212 const std::string& extension_id); | 213 const std::string& extension_id); |
| 213 | 214 |
| 214 // Send an event with name |event_name| and arguments |event_args| to the | 215 // Send an event with name |event_name| and arguments |event_args| to the |
| 215 // extension with id |extension_id|. | 216 // extension with id |extension_id|. |
| 216 void SendSignalToExtension(const std::string& extension_id, | 217 void SendSignalToExtension(const std::string& extension_id, |
| 217 extensions::events::HistogramValue histogram_value, | 218 extensions::events::HistogramValue histogram_value, |
| 218 const std::string& event_name, | 219 const std::string& event_name, |
| 219 scoped_ptr<base::ListValue> event_args); | 220 std::unique_ptr<base::ListValue> event_args); |
| 220 | 221 |
| 221 // Destroy configurations belonging to the extension. | 222 // Destroy configurations belonging to the extension. |
| 222 void DestroyConfigurationsForExtension( | 223 void DestroyConfigurationsForExtension( |
| 223 const extensions::Extension* extension); | 224 const extensions::Extension* extension); |
| 224 | 225 |
| 225 // Set the active configuration. | 226 // Set the active configuration. |
| 226 void SetActiveConfiguration(VpnConfiguration* configuration); | 227 void SetActiveConfiguration(VpnConfiguration* configuration); |
| 227 | 228 |
| 228 content::BrowserContext* browser_context_; | 229 content::BrowserContext* browser_context_; |
| 229 std::string userid_hash_; | 230 std::string userid_hash_; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 244 StringToConfigurationMap service_path_to_configuration_map_; | 245 StringToConfigurationMap service_path_to_configuration_map_; |
| 245 | 246 |
| 246 base::WeakPtrFactory<VpnService> weak_factory_; | 247 base::WeakPtrFactory<VpnService> weak_factory_; |
| 247 | 248 |
| 248 DISALLOW_COPY_AND_ASSIGN(VpnService); | 249 DISALLOW_COPY_AND_ASSIGN(VpnService); |
| 249 }; | 250 }; |
| 250 | 251 |
| 251 } // namespace chromeos | 252 } // namespace chromeos |
| 252 | 253 |
| 253 #endif // EXTENSIONS_BROWSER_API_VPN_PROVIDER_VPN_SERVICE_H_ | 254 #endif // EXTENSIONS_BROWSER_API_VPN_PROVIDER_VPN_SERVICE_H_ |
| OLD | NEW |