Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROMEOS_NETWORK_PROXY_UI_PROXY_CONFIG_SERVICE_H_ | 5 #ifndef CHROMEOS_NETWORK_PROXY_UI_PROXY_CONFIG_SERVICE_H_ |
| 6 #define CHROMEOS_NETWORK_PROXY_UI_PROXY_CONFIG_SERVICE_H_ | 6 #define CHROMEOS_NETWORK_PROXY_UI_PROXY_CONFIG_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "chromeos/chromeos_export.h" | 11 #include "chromeos/chromeos_export.h" |
| 12 #include "chromeos/network/proxy/ui_proxy_config.h" | 12 #include "chromeos/network/proxy/ui_proxy_config.h" |
| 13 #include "components/prefs/pref_change_registrar.h" | |
| 13 | 14 |
| 14 class PrefService; | 15 class PrefService; |
| 15 | 16 |
| 16 namespace chromeos { | 17 namespace chromeos { |
| 17 | 18 |
| 18 class NetworkState; | 19 class NetworkState; |
| 19 | 20 |
| 20 // This class is only accessed from the UI via Profile::GetProxyConfigTracker to | 21 // 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.
| |
| 21 // allow the user to read and modify the proxy configuration via | 22 // configuration. Primarily this class caches the "current" requested config |
| 22 // GetProxyConfig and SetProxyConfig. | 23 // and populates UIProxyConfig for convenient UI consumption. |
| 23 // | 24 // NOTE: This class must be rebuilt when the logged in profile changes. |
| 24 // Before reading/setting a proxy config, a network has to be selected using | 25 |
| 25 // either SetCurrentNetwork (any remembered network) or | |
| 26 // MakeActiveNetworkCurrent. | |
| 27 class CHROMEOS_EXPORT UIProxyConfigService { | 26 class CHROMEOS_EXPORT UIProxyConfigService { |
| 28 public: | 27 public: |
| 29 UIProxyConfigService(); | 28 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.
| |
| 29 PrefService* local_state_prefs); | |
| 30 ~UIProxyConfigService(); | 30 ~UIProxyConfigService(); |
| 31 | 31 |
| 32 // After this call, proxy settings are read from |profile_prefs| and | 32 // Called when ::proxy_config::prefs change or to force an update. |
| 33 // |local_state_prefs|. In case of usage for the sign-in screen, | 33 void UpdateFromPrefs(const std::string& guid); |
| 34 // |profile_prefs| must be NULL because sign-in screen should depend only on | |
| 35 // shared settings. | |
| 36 void SetPrefs(PrefService* profile_prefs, PrefService* local_state_prefs); | |
| 37 | 34 |
| 38 // Called by UI to set the network with GUID |current_guid| to be | 35 // Called from UI to retrieve the active proxy configuration, using |
| 39 // displayed or edited. Subsequent Set*/Get* methods will use this | 36 // |network_guid| for the network state if no global proxy configuration |
| 40 // network, until this method is called again. | 37 // superceeds it. |
| 41 void SetCurrentNetworkGuid(const std::string& current_guid); | 38 void GetProxyConfig(const std::string& network_guid, UIProxyConfig* config); |
| 42 | |
| 43 void UpdateFromPrefs(); | |
| 44 | |
| 45 // Called from UI to retrieve the stored proxy configuration, which is either | |
| 46 // the last proxy config of the current network or the one last set by | |
| 47 // SetProxyConfig. | |
| 48 void GetProxyConfig(UIProxyConfig* config) const; | |
| 49 | 39 |
| 50 // Called from UI to update proxy configuration for different modes. Stores | 40 // Called from UI to update proxy configuration for different modes. Stores |
| 51 // and persists |config| to shill for the current network. | 41 // and persists |config| to shill for the network matching |network_guid|. |
| 52 void SetProxyConfig(const UIProxyConfig& config); | 42 void SetProxyConfig(const std::string& network_guid, |
| 43 const UIProxyConfig& config); | |
| 53 | 44 |
| 54 private: | 45 private: |
| 55 // Determines effective proxy config based on prefs from config tracker, | 46 // Determines effective proxy config based on prefs from config tracker, |
| 56 // |network| and if user is using shared proxies. The effective config is | 47 // |network| and if user is using shared proxies. The effective config is |
| 57 // stored in |current_ui_config_| but not activated on network stack, and | 48 // stored in |current_ui_config_| but not activated on network stack, and |
| 58 // hence, not picked up by observers. | 49 // hence, not picked up by observers. |
| 59 void DetermineEffectiveConfig(const NetworkState& network); | 50 void DetermineEffectiveConfig(const NetworkState& network); |
| 60 | 51 |
| 61 // GUID of network whose proxy configuration is being displayed or | 52 void OnPreferenceChanged(const std::string& pref_name); |
| 62 // edited via UI. | 53 |
| 54 // GUID of network used for current_ui_config_. | |
| 63 std::string current_ui_network_guid_; | 55 std::string current_ui_network_guid_; |
| 64 | 56 |
| 65 // Proxy configuration of |current_ui_network_|. | 57 // Proxy configuration of |current_ui_network_|. |
| 66 UIProxyConfig current_ui_config_; | 58 UIProxyConfig current_ui_config_; |
| 67 | 59 |
| 68 // Not owned. | 60 PrefService* logged_in_profile_prefs_; // unowned |
| 69 PrefService* profile_prefs_; | 61 PrefChangeRegistrar logged_in_profile_registrar_; |
| 70 | 62 |
| 71 // Not owned. | 63 PrefService* local_state_prefs_; // unowned |
| 72 PrefService* local_state_prefs_; | 64 PrefChangeRegistrar local_state_registrar_; |
| 73 | 65 |
| 74 DISALLOW_COPY_AND_ASSIGN(UIProxyConfigService); | 66 DISALLOW_COPY_AND_ASSIGN(UIProxyConfigService); |
| 75 }; | 67 }; |
| 76 | 68 |
| 77 } // namespace chromeos | 69 } // namespace chromeos |
| 78 | 70 |
| 79 #endif // CHROMEOS_NETWORK_PROXY_UI_PROXY_CONFIG_SERVICE_H_ | 71 #endif // CHROMEOS_NETWORK_PROXY_UI_PROXY_CONFIG_SERVICE_H_ |
| OLD | NEW |