Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1754)

Unified Diff: chromeos/network/proxy/ui_proxy_config_service.h

Issue 2446893008: NetworkHandler: Add ui_proxy_config_service (Closed)
Patch Set: Feedback + elim bogus shill errors Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..6414988ade7ec5abf4d3b0e8ba3761ba74e3cd9e 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,31 @@ 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 provides an interface to the UI for getting and setting a proxy
+// 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();
+ // |local_state_prefs| must not be null. |logged_in_profile_prefs| can be
+ // null if there is no logged in user, in which case only the local state
+ // (device) prefs will be used. See note above.
+ UIProxyConfigService(PrefService* local_state_prefs,
+ PrefService* logged_in_profile_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 when ::proxy_config::prefs change or to force an update.
+ void UpdateFromPrefs(const std::string& guid);
- // 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);
-
- 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
+ // supersedes it.
+ 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
// 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 +51,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_|.
michaelpg 2016/11/02 05:34:51 |current_ui_network_guid_| (or just normal words)
stevenjb 2016/11/02 18:03:41 Done.
UIProxyConfig current_ui_config_;
- // Not owned.
- PrefService* profile_prefs_;
+ 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,
+ 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);
};

Powered by Google App Engine
This is Rietveld 408576698