Chromium Code Reviews| 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> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/scoped_ptr.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/app_window/app_window_registry.h" | |
|
bartfab (slow)
2015/03/10 13:28:41
Nit: No longer needed.
| |
| 19 #include "extensions/browser/extension_registry_observer.h" | 20 #include "extensions/browser/extension_registry_observer.h" |
| 20 #include "extensions/common/api/vpn_provider.h" | 21 #include "extensions/common/api/vpn_provider.h" |
| 21 | 22 |
| 22 namespace base { | 23 namespace base { |
| 23 | 24 |
| 24 class DictionaryValue; | 25 class DictionaryValue; |
| 25 class ListValue; | 26 class ListValue; |
| 26 | 27 |
| 27 } // namespace base | 28 } // namespace base |
| 28 | 29 |
| 29 namespace content { | 30 namespace content { |
| 30 | 31 |
| 31 class BrowserContext; | 32 class BrowserContext; |
| 32 | 33 |
| 33 } // namespace content | 34 } // namespace content |
| 34 | 35 |
| 35 namespace extensions { | 36 namespace extensions { |
| 36 | 37 |
| 38 class AppWindow; | |
|
bartfab (slow)
2015/03/10 13:28:41
Nit: No longer needed.
| |
| 37 class EventRouter; | 39 class EventRouter; |
| 38 class ExtensionRegistry; | 40 class ExtensionRegistry; |
| 39 | 41 |
| 40 } // namespace extensions | 42 } // namespace extensions |
| 41 | 43 |
| 42 namespace chromeos { | 44 namespace chromeos { |
| 43 | 45 |
| 44 class NetworkConfigurationHandler; | 46 class NetworkConfigurationHandler; |
| 45 class NetworkProfileHandler; | 47 class NetworkProfileHandler; |
| 46 class NetworkStateHandler; | 48 class NetworkStateHandler; |
| 47 class ShillThirdPartyVpnDriverClient; | 49 class ShillThirdPartyVpnDriverClient; |
| 48 | 50 |
| 49 // The class manages the VPN configurations. | 51 // The class manages the VPN configurations. |
| 50 class VpnService : public KeyedService, | 52 class VpnService : public KeyedService, |
| 53 public extensions::AppWindowRegistry::Observer, | |
|
bartfab (slow)
2015/03/10 13:28:41
Nit: No longer needed.
| |
| 51 public NetworkConfigurationObserver, | 54 public NetworkConfigurationObserver, |
| 52 public NetworkStateHandlerObserver, | 55 public NetworkStateHandlerObserver, |
| 53 public extensions::ExtensionRegistryObserver { | 56 public extensions::ExtensionRegistryObserver { |
| 54 public: | 57 public: |
| 55 using SuccessCallback = base::Closure; | 58 using SuccessCallback = base::Closure; |
| 56 using FailureCallback = | 59 using FailureCallback = |
| 57 base::Callback<void(const std::string& error_name, | 60 base::Callback<void(const std::string& error_name, |
| 58 const std::string& error_message)>; | 61 const std::string& error_message)>; |
| 59 | 62 |
| 60 VpnService(content::BrowserContext* browser_context, | 63 VpnService(content::BrowserContext* browser_context, |
| 61 const std::string& userid_hash, | 64 const std::string& userid_hash, |
| 65 extensions::AppWindowRegistry* app_window_registry, | |
|
bartfab (slow)
2015/03/10 13:28:40
Nit: No longer needed.
| |
| 62 extensions::ExtensionRegistry* extension_registry, | 66 extensions::ExtensionRegistry* extension_registry, |
| 63 extensions::EventRouter* event_router, | 67 extensions::EventRouter* event_router, |
| 64 ShillThirdPartyVpnDriverClient* shill_client, | 68 ShillThirdPartyVpnDriverClient* shill_client, |
| 65 NetworkConfigurationHandler* network_configuration_handler, | 69 NetworkConfigurationHandler* network_configuration_handler, |
| 66 NetworkProfileHandler* network_profile_handler, | 70 NetworkProfileHandler* network_profile_handler, |
| 67 NetworkStateHandler* network_state_handler); | 71 NetworkStateHandler* network_state_handler); |
| 68 ~VpnService() override; | 72 ~VpnService() override; |
| 69 | 73 |
| 70 // NetworkConfigurationObserver: | 74 // NetworkConfigurationObserver: |
| 71 void OnConfigurationCreated(const std::string& service_path, | 75 void OnConfigurationCreated(const std::string& service_path, |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 83 const std::string& profile_path, | 87 const std::string& profile_path, |
| 84 Source source) override; | 88 Source source) override; |
| 85 | 89 |
| 86 // NetworkStateHandlerObserver: | 90 // NetworkStateHandlerObserver: |
| 87 void NetworkListChanged() override; | 91 void NetworkListChanged() override; |
| 88 | 92 |
| 89 // ExtensionRegistryObserver: | 93 // ExtensionRegistryObserver: |
| 90 void OnExtensionUninstalled(content::BrowserContext* browser_context, | 94 void OnExtensionUninstalled(content::BrowserContext* browser_context, |
| 91 const extensions::Extension* extension, | 95 const extensions::Extension* extension, |
| 92 extensions::UninstallReason reason) override; | 96 extensions::UninstallReason reason) override; |
| 93 | 97 |
|
bartfab (slow)
2015/03/10 13:28:41
Nit: Remove blank linke to make it clear that this
| |
| 98 void OnExtensionUnloaded( | |
| 99 content::BrowserContext* browser_context, | |
| 100 const extensions::Extension* extension, | |
| 101 extensions::UnloadedExtensionInfo::Reason reason) override; | |
| 102 | |
| 103 // AppWindowRegistry::Observer: | |
| 104 void OnAppWindowRemoved(extensions::AppWindow* app_window) override; | |
|
bartfab (slow)
2015/03/10 13:28:40
Nit: As discussed offline, we do not need this.
| |
| 105 | |
| 94 // Creates a new VPN configuration with |configuration_name| as the name and | 106 // Creates a new VPN configuration with |configuration_name| as the name and |
| 95 // attaches it to the extension with id |extension_id|. | 107 // attaches it to the extension with id |extension_id|. |
| 96 // Calls |success| or |failure| based on the outcome. | 108 // Calls |success| or |failure| based on the outcome. |
| 97 void CreateConfiguration(const std::string& extension_id, | 109 void CreateConfiguration(const std::string& extension_id, |
| 98 const std::string& extension_name, | 110 const std::string& extension_name, |
| 99 const std::string& configuration_name, | 111 const std::string& configuration_name, |
| 100 const SuccessCallback& success, | 112 const SuccessCallback& success, |
| 101 const FailureCallback& failure); | 113 const FailureCallback& failure); |
| 102 | 114 |
| 103 // Destroys the VPN configuration with the name |configuration_name| after | 115 // Destroys the VPN configuration with the name |configuration_name| after |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 void SendSignalToExtension(const std::string& extension_id, | 198 void SendSignalToExtension(const std::string& extension_id, |
| 187 const std::string& event_name, | 199 const std::string& event_name, |
| 188 scoped_ptr<base::ListValue> event_args); | 200 scoped_ptr<base::ListValue> event_args); |
| 189 | 201 |
| 190 // Set the active configuration. | 202 // Set the active configuration. |
| 191 void SetActiveConfiguration(VpnConfiguration* configuration); | 203 void SetActiveConfiguration(VpnConfiguration* configuration); |
| 192 | 204 |
| 193 content::BrowserContext* browser_context_; | 205 content::BrowserContext* browser_context_; |
| 194 std::string userid_hash_; | 206 std::string userid_hash_; |
| 195 | 207 |
| 208 extensions::AppWindowRegistry* app_window_registry_; | |
|
bartfab (slow)
2015/03/10 13:28:40
Nit: No longer needed.
| |
| 196 extensions::ExtensionRegistry* extension_registry_; | 209 extensions::ExtensionRegistry* extension_registry_; |
| 197 extensions::EventRouter* event_router_; | 210 extensions::EventRouter* event_router_; |
| 198 ShillThirdPartyVpnDriverClient* shill_client_; | 211 ShillThirdPartyVpnDriverClient* shill_client_; |
| 199 NetworkConfigurationHandler* network_configuration_handler_; | 212 NetworkConfigurationHandler* network_configuration_handler_; |
| 200 NetworkProfileHandler* network_profile_handler_; | 213 NetworkProfileHandler* network_profile_handler_; |
| 201 NetworkStateHandler* network_state_handler_; | 214 NetworkStateHandler* network_state_handler_; |
| 202 | 215 |
| 203 VpnConfiguration* active_configuration_; | 216 VpnConfiguration* active_configuration_; |
| 204 | 217 |
| 205 // Key map owns the VpnConfigurations. | 218 // Key map owns the VpnConfigurations. |
| 206 StringToConfigurationMap key_to_configuration_map_; | 219 StringToConfigurationMap key_to_configuration_map_; |
| 207 | 220 |
| 208 // Service path does not own the VpnConfigurations. | 221 // Service path does not own the VpnConfigurations. |
| 209 StringToConfigurationMap service_path_to_configuration_map_; | 222 StringToConfigurationMap service_path_to_configuration_map_; |
| 210 | 223 |
| 211 base::WeakPtrFactory<VpnService> weak_factory_; | 224 base::WeakPtrFactory<VpnService> weak_factory_; |
| 212 | 225 |
| 213 DISALLOW_COPY_AND_ASSIGN(VpnService); | 226 DISALLOW_COPY_AND_ASSIGN(VpnService); |
| 214 }; | 227 }; |
| 215 | 228 |
| 216 } // namespace chromeos | 229 } // namespace chromeos |
| 217 | 230 |
| 218 #endif // EXTENSIONS_BROWSER_API_VPN_PROVIDER_VPN_SERVICE_H_ | 231 #endif // EXTENSIONS_BROWSER_API_VPN_PROVIDER_VPN_SERVICE_H_ |
| OLD | NEW |