Chromium Code Reviews| Index: chromeos/network/proxy/ui_proxy_config_service.h |
| diff --git a/chromeos/network/proxy/ui_proxy_config_service.h b/chromeos/network/proxy/ui_proxy_config_service.h |
| index 85c921e092c87d69d96add143810f4f71e6fce54..9e39b676810d1d4bbe6dadf84d94c03465677ab1 100644 |
| --- a/chromeos/network/proxy/ui_proxy_config_service.h |
| +++ b/chromeos/network/proxy/ui_proxy_config_service.h |
| @@ -10,6 +10,7 @@ |
| #include "base/macros.h" |
| #include "chromeos/chromeos_export.h" |
| #include "chromeos/network/proxy/ui_proxy_config.h" |
| +#include "components/prefs/pref_change_registrar.h" |
| class PrefService; |
| @@ -17,39 +18,29 @@ namespace chromeos { |
| class NetworkState; |
| -// This class is only accessed from the UI via Profile::GetProxyConfigTracker to |
| -// allow the user to read and modify the proxy configuration via |
| -// GetProxyConfig and SetProxyConfig. |
| -// |
| -// Before reading/setting a proxy config, a network has to be selected using |
| -// either SetCurrentNetwork (any remembered network) or |
| -// MakeActiveNetworkCurrent. |
| +// This class provdes an interface to the UI for getting and setting a proxy |
|
James Cook
2016/11/01 23:02:04
nit: provides
stevenjb
2016/11/01 23:55:11
Done.
|
| +// configuration. Primarily this class caches the "current" requested config |
| +// and populates UIProxyConfig for convenient UI consumption. |
| +// NOTE: This class must be rebuilt when the logged in profile changes. |
| + |
| class CHROMEOS_EXPORT UIProxyConfigService { |
| public: |
| - UIProxyConfigService(); |
| + UIProxyConfigService(PrefService* logged_in_profile_prefs, |
|
James Cook
2016/11/01 23:02:04
nit: document what it means if one (or both) are n
stevenjb
2016/11/01 23:55:11
Done.
|
| + PrefService* local_state_prefs); |
| ~UIProxyConfigService(); |
| - // After this call, proxy settings are read from |profile_prefs| and |
| - // |local_state_prefs|. In case of usage for the sign-in screen, |
| - // |profile_prefs| must be NULL because sign-in screen should depend only on |
| - // shared settings. |
| - void SetPrefs(PrefService* profile_prefs, PrefService* local_state_prefs); |
| - |
| - // Called by UI to set the network with GUID |current_guid| to be |
| - // displayed or edited. Subsequent Set*/Get* methods will use this |
| - // network, until this method is called again. |
| - void SetCurrentNetworkGuid(const std::string& current_guid); |
| + // Called when ::proxy_config::prefs change or to force an update. |
| + void UpdateFromPrefs(const std::string& guid); |
| - void UpdateFromPrefs(); |
| - |
| - // Called from UI to retrieve the stored proxy configuration, which is either |
| - // the last proxy config of the current network or the one last set by |
| - // SetProxyConfig. |
| - void GetProxyConfig(UIProxyConfig* config) const; |
| + // Called from UI to retrieve the active proxy configuration, using |
| + // |network_guid| for the network state if no global proxy configuration |
| + // superceeds it. |
| + void GetProxyConfig(const std::string& network_guid, UIProxyConfig* config); |
| // Called from UI to update proxy configuration for different modes. Stores |
| - // and persists |config| to shill for the current network. |
| - void SetProxyConfig(const UIProxyConfig& config); |
| + // and persists |config| to shill for the network matching |network_guid|. |
| + void SetProxyConfig(const std::string& network_guid, |
| + const UIProxyConfig& config); |
| private: |
| // Determines effective proxy config based on prefs from config tracker, |
| @@ -58,18 +49,19 @@ class CHROMEOS_EXPORT UIProxyConfigService { |
| // hence, not picked up by observers. |
| void DetermineEffectiveConfig(const NetworkState& network); |
| - // GUID of network whose proxy configuration is being displayed or |
| - // edited via UI. |
| + void OnPreferenceChanged(const std::string& pref_name); |
| + |
| + // GUID of network used for current_ui_config_. |
| std::string current_ui_network_guid_; |
| // Proxy configuration of |current_ui_network_|. |
| UIProxyConfig current_ui_config_; |
| - // Not owned. |
| - PrefService* profile_prefs_; |
| + PrefService* logged_in_profile_prefs_; // unowned |
| + PrefChangeRegistrar logged_in_profile_registrar_; |
| - // Not owned. |
| - PrefService* local_state_prefs_; |
| + PrefService* local_state_prefs_; // unowned |
| + PrefChangeRegistrar local_state_registrar_; |
| DISALLOW_COPY_AND_ASSIGN(UIProxyConfigService); |
| }; |