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_ |
|
michaelpg
2016/11/02 05:34:51
what's the deal with the title? what is being adde
stevenjb
2016/11/02 18:03:41
I don't understand this question.
michaelpg
2016/11/02 23:39:09
sorry, I commented in a better place about changin
| |
| 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 provides an interface to the UI for getting and setting a proxy |
| 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 // either SetCurrentNetwork (any remembered network) or | |
| 26 // MakeActiveNetworkCurrent. | |
| 27 class CHROMEOS_EXPORT UIProxyConfigService { | 25 class CHROMEOS_EXPORT UIProxyConfigService { |
| 28 public: | 26 public: |
| 29 UIProxyConfigService(); | 27 // |local_state_prefs| must not be null. |logged_in_profile_prefs| can be |
| 28 // null if there is no logged in user, in which case only the local state | |
| 29 // (device) prefs will be used. See note above. | |
| 30 UIProxyConfigService(PrefService* local_state_prefs, | |
| 31 PrefService* logged_in_profile_prefs); | |
| 30 ~UIProxyConfigService(); | 32 ~UIProxyConfigService(); |
| 31 | 33 |
| 32 // After this call, proxy settings are read from |profile_prefs| and | 34 // Called when ::proxy_config::prefs change or to force an update. |
| 33 // |local_state_prefs|. In case of usage for the sign-in screen, | 35 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 | 36 |
| 38 // Called by UI to set the network with GUID |current_guid| to be | 37 // Called from UI to retrieve the active proxy configuration, using |
| 39 // displayed or edited. Subsequent Set*/Get* methods will use this | 38 // |network_guid| for the network state if no global proxy configuration |
| 40 // network, until this method is called again. | 39 // supersedes it. |
| 41 void SetCurrentNetworkGuid(const std::string& current_guid); | 40 void GetProxyConfig(const std::string& network_guid, UIProxyConfig* config); |
|
michaelpg
2016/11/02 05:34:51
The comment makes sense, but between the naming, a
stevenjb
2016/11/02 18:03:42
I absolutely agree that this class is a bit of a m
| |
| 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 | 41 |
| 50 // Called from UI to update proxy configuration for different modes. Stores | 42 // Called from UI to update proxy configuration for different modes. Stores |
| 51 // and persists |config| to shill for the current network. | 43 // and persists |config| to shill for the network matching |network_guid|. |
| 52 void SetProxyConfig(const UIProxyConfig& config); | 44 void SetProxyConfig(const std::string& network_guid, |
| 45 const UIProxyConfig& config); | |
| 53 | 46 |
| 54 private: | 47 private: |
| 55 // Determines effective proxy config based on prefs from config tracker, | 48 // Determines effective proxy config based on prefs from config tracker, |
| 56 // |network| and if user is using shared proxies. The effective config is | 49 // |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 | 50 // stored in |current_ui_config_| but not activated on network stack, and |
| 58 // hence, not picked up by observers. | 51 // hence, not picked up by observers. |
| 59 void DetermineEffectiveConfig(const NetworkState& network); | 52 void DetermineEffectiveConfig(const NetworkState& network); |
| 60 | 53 |
| 61 // GUID of network whose proxy configuration is being displayed or | 54 void OnPreferenceChanged(const std::string& pref_name); |
| 62 // edited via UI. | 55 |
| 56 // GUID of network used for current_ui_config_. | |
| 63 std::string current_ui_network_guid_; | 57 std::string current_ui_network_guid_; |
| 64 | 58 |
| 65 // Proxy configuration of |current_ui_network_|. | 59 // Proxy configuration of |current_ui_network_|. |
|
michaelpg
2016/11/02 05:34:51
|current_ui_network_guid_| (or just normal words)
stevenjb
2016/11/02 18:03:41
Done.
| |
| 66 UIProxyConfig current_ui_config_; | 60 UIProxyConfig current_ui_config_; |
| 67 | 61 |
| 68 // Not owned. | 62 PrefService* logged_in_profile_prefs_; // unowned |
|
michaelpg
2016/11/02 05:34:51
s/profile/user while you're here?
stevenjb
2016/11/02 18:03:41
Well, they are associated with Profile, not User,
| |
| 69 PrefService* profile_prefs_; | 63 PrefChangeRegistrar logged_in_profile_registrar_; |
| 70 | 64 |
| 71 // Not owned. | 65 PrefService* local_state_prefs_; // unowned |
| 72 PrefService* local_state_prefs_; | 66 PrefChangeRegistrar local_state_registrar_; |
| 73 | 67 |
| 74 DISALLOW_COPY_AND_ASSIGN(UIProxyConfigService); | 68 DISALLOW_COPY_AND_ASSIGN(UIProxyConfigService); |
| 75 }; | 69 }; |
| 76 | 70 |
| 77 } // namespace chromeos | 71 } // namespace chromeos |
| 78 | 72 |
| 79 #endif // CHROMEOS_NETWORK_PROXY_UI_PROXY_CONFIG_SERVICE_H_ | 73 #endif // CHROMEOS_NETWORK_PROXY_UI_PROXY_CONFIG_SERVICE_H_ |
| OLD | NEW |