Chromium Code Reviews| Index: chrome/browser/chromeos/proxy_config_service_impl.h |
| diff --git a/chrome/browser/chromeos/proxy_config_service_impl.h b/chrome/browser/chromeos/proxy_config_service_impl.h |
| index 730e003bd968005b9da7a81f12f217f4f9cc42e4..e32fbd90d6225c3f5aca3140a26d7cdda08e523d 100644 |
| --- a/chrome/browser/chromeos/proxy_config_service_impl.h |
| +++ b/chrome/browser/chromeos/proxy_config_service_impl.h |
| @@ -10,18 +10,23 @@ |
| #include "base/basictypes.h" |
| #include "base/prefs/pref_member.h" |
| -#include "base/values.h" |
| -#include "chrome/browser/chromeos/cros/network_library.h" |
| #include "chrome/browser/net/pref_proxy_config_tracker_impl.h" |
| +#include "chromeos/network/network_state_handler_observer.h" |
| class PrefRegistrySimple; |
| +namespace base { |
| +class DictionaryValue; |
| +} |
| + |
| namespace user_prefs { |
| class PrefRegistrySyncable; |
| } |
| namespace chromeos { |
| +class NetworkState; |
| + |
| // Implementation of proxy config service for chromeos that: |
| // - extends PrefProxyConfigTrackerImpl (and so lives and runs entirely on UI |
| // thread) to handle proxy from prefs (via PrefProxyConfigTrackerImpl) and |
| @@ -37,8 +42,7 @@ namespace chromeos { |
| // any remembered network (either currently active or non-active) of current |
| // user profile |
| class ProxyConfigServiceImpl : public PrefProxyConfigTrackerImpl, |
| - public NetworkLibrary::NetworkManagerObserver, |
| - public NetworkLibrary::NetworkObserver { |
| + public NetworkStateHandlerObserver { |
| public: |
| // ProxyConfigServiceImpl is created in ProxyServiceFactory:: |
| // CreatePrefProxyConfigTrackerImpl via Profile::GetProxyConfigTracker() for |
| @@ -94,7 +98,7 @@ class ProxyConfigServiceImpl : public PrefProxyConfigTrackerImpl, |
| // Converts |this| to Dictionary of ProxyConfigDictionary format (which |
| // is the same format used by prefs). |
| - DictionaryValue* ToPrefProxyConfig(); |
| + base::DictionaryValue* ToPrefProxyConfig(); |
| // Map |scheme| (one of "http", "https", "ftp" or "socks") to the correct |
| // ManualProxy. Returns NULL if scheme is invalid. |
| @@ -142,22 +146,20 @@ class ProxyConfigServiceImpl : public PrefProxyConfigTrackerImpl, |
| net::ProxyBypassRules bypass_rules; |
| }; |
| - // Constructor. |
| explicit ProxyConfigServiceImpl(PrefService* pref_service); |
| virtual ~ProxyConfigServiceImpl(); |
| - // Called by UI to set service path of |network| to be displayed or edited. |
| - // Subsequent UISet* methods will use this network, until UI calls it again |
| - // with a different network. |
| + // Called by UI to set the network with service path |current_network| to be |
| + // displayed or edited. Subsequent UISet*/UIGet* methods will use this |
| + // network, until this method is called again. |
| void UISetCurrentNetwork(const std::string& current_network); |
| - // Called from UI to make the currently active network the one to be displayed |
| - // or edited. Subsequent UISet* methods will use this network until UI calls |
| - // it again when the active network has changed. |
| - void UIMakeActiveNetworkCurrent(); |
| + // Called from UI to make the current default network the one to be displayed |
|
Mattias Nissler (ping if slow)
2013/05/08 12:46:36
Why the change in wording to default? The previous
pneubeck (no reviews)
2013/05/08 18:32:14
The wording was changed in many places. I think th
Mattias Nissler (ping if slow)
2013/05/10 12:17:31
If this is consistent with the networking code, I'
|
| + // or edited. See UISetCurrentNetwork. |
| + void UIMakeDefaultNetworkCurrent(); |
| // Called from UI to get name of the current network set via |
| - // UISetCurrentNetwork or UIMakeActiveNetworkCurrent. |
| + // UISetCurrentNetwork or UIMakeDefaultNetworkCurrent. |
| void UIGetCurrentNetworkName(std::string* network_name); |
| // Called from UI to retrieve proxy configuration in |current_ui_config_|. |
| @@ -165,7 +167,7 @@ class ProxyConfigServiceImpl : public PrefProxyConfigTrackerImpl, |
| // Called from UI to update proxy configuration for different modes. |
| // Returns true if config is set properly and persisted to shill for the |
| - // current network (set via UISetCurrentNetwork/UIMakeActiveNetworkCurrent). |
| + // current network (set via UISetCurrentNetwork/UIMakeDefaultNetworkCurrent). |
| // If this network is also currently active, config service proceeds to start |
| // activating it on network stack. |
| // Returns false if config is not set properly, probably because information |
| @@ -191,16 +193,13 @@ class ProxyConfigServiceImpl : public PrefProxyConfigTrackerImpl, |
| virtual void OnProxyConfigChanged(ProxyPrefs::ConfigState config_state, |
| const net::ProxyConfig& config) OVERRIDE; |
| - // NetworkLibrary::NetworkManagerObserver implementation. |
| - virtual void OnNetworkManagerChanged(NetworkLibrary* cros) OVERRIDE; |
| - |
| - // NetworkLibrary::NetworkObserver implementation. |
| - virtual void OnNetworkChanged(NetworkLibrary* cros, |
| - const Network* network) OVERRIDE; |
| + // NetworkStateHandlerObserver implementation. |
| + virtual void DefaultNetworkChanged(const NetworkState* network) OVERRIDE; |
| - // Parse |network| proxy config and store result in |proxy_config|. |
| - // Returns true if proxy config was successfully parsed. |
| - static bool ParseProxyConfig(const Network* network, |
| + // Convert and store the proxy config of |network| to |proxy_config|. Returns |
| + // true if any proxy config is stored in |network| and proxy config was |
| + // successfully converted. |
| + static bool ParseProxyConfig(const NetworkState& network, |
| net::ProxyConfig* proxy_config); |
| // Register UseShardProxies preference. |
| @@ -209,11 +208,11 @@ class ProxyConfigServiceImpl : public PrefProxyConfigTrackerImpl, |
| #if defined(UNIT_TEST) |
| void SetTesting(ProxyConfig* test_config) { |
| - UIMakeActiveNetworkCurrent(); |
| + UIMakeDefaultNetworkCurrent(); |
| if (test_config) { |
| std::string value; |
| test_config->SerializeForNetwork(&value); |
| - SetProxyConfigForNetwork(active_network_, value, false); |
| + SetProxyConfigForNetwork(current_ui_network_, value, false); |
| } |
| } |
| #endif // defined(UNIT_TEST) |
| @@ -225,13 +224,6 @@ class ProxyConfigServiceImpl : public PrefProxyConfigTrackerImpl, |
| // Called from the various UISetProxyConfigTo*. |
| void OnUISetProxyConfig(); |
| - // Called from OnNetworkManagerChanged and OnNetworkChanged for currently |
| - // active network, to handle previously active network, new active network, |
| - // and if necessary, migrates device settings to shill and/or activates |
| - // proxy setting of new network. |
| - void OnActiveNetworkChanged(NetworkLibrary* cros, |
| - const Network* active_network); |
| - |
| // Sets proxy config for |network_path| into shill and activates setting |
| // if the network is currently active. If |only_set_if_empty| is true, |
| // proxy will be set and saved only if network has no proxy. |
| @@ -245,7 +237,11 @@ class ProxyConfigServiceImpl : public PrefProxyConfigTrackerImpl, |
| // Returns true if proxy is to be ignored for network, which happens if |
| // network is shared and use-shared-proxies is turned off. |
| - bool IgnoreProxy(const Network* network); |
| + bool IgnoreProxy(const NetworkState& network); |
| + |
| + // Determines, applies and stores the effective proxy config based on the |
| + // current default network. |
| + void UpdateProxyConfigOfDefaultNetwork(); |
| // Determines effective proxy config based on prefs from config tracker, |
| // |network| and if user is using shared proxies. |
| @@ -253,23 +249,16 @@ class ProxyConfigServiceImpl : public PrefProxyConfigTrackerImpl, |
| // activated on network stack, and hence, picked up by observers. |
| // if |activate| is false, effective config is stored in |current_ui_config_| |
| // but not activated on network stack, and hence, not picked up by observers. |
| - void DetermineEffectiveConfig(const Network* network, bool activate); |
| - |
| - // Determines |current_ui_config_| based on |network|, called from |
| - // UISetCurrentNetwork and UIMakeActiveNetworkActive. |
| - void OnUISetCurrentNetwork(const Network* network); |
| + void DetermineEffectiveConfig(const NetworkState* network, bool activate); |
| // Reset UI cache variables that keep track of UI activities. |
| void ResetUICache(); |
| void FetchProxyPolicy(); |
| - // Data members. |
| - |
| - // Service path of currently active network (determined via shill |
| - // notifications); if effective proxy config is from system, proxy of this |
| - // network will be the one taking effect. |
| - std::string active_network_; |
| + // Service path of last known default network; if effective proxy config is |
| + // from system, proxy of this network will be the one taking effect. |
| + std::string default_network_; |
| // State of |active_config_|. |active_config_| is only valid if |
| // |active_config_state_| is not ProxyPrefs::CONFIG_UNSET. |
| @@ -283,7 +272,7 @@ class ProxyConfigServiceImpl : public PrefProxyConfigTrackerImpl, |
| std::string device_config_; |
| // Service path of network whose proxy configuration is being displayed or |
| - // edited via UI, separate from |active_network_| which may be same or |
| + // edited via UI, separate from |default_network_| which may be same or |
| // different. |
| std::string current_ui_network_; |