Index: chrome/browser/net/pref_proxy_config_service.h |
=================================================================== |
--- chrome/browser/net/pref_proxy_config_service.h (revision 103881) |
+++ chrome/browser/net/pref_proxy_config_service.h (working copy) |
@@ -43,21 +43,47 @@ |
CONFIG_UNSET, |
}; |
+ // Source of proxy configuration, returned togther when proxy config is |
+ // retrieved. |
+ enum ConfigSource { |
Mattias Nissler (ping if slow)
2011/10/07 13:32:10
ConfigState and ConfigSource are basically doing t
kuan
2011/10/18 16:25:35
Done.
|
+ // Configuration souce is not set. |
+ CONFIG_SOURCE_UNSET, |
+ // Configuration is from policy. |
+ CONFIG_SOURCE_POLICY, |
+ // Configuration is from extension. |
+ CONFIG_SOURCE_EXTENSION, |
+ // Configuration is from recommended i..e fallback. |
+ CONFIG_SOURCE_FALLBACK, |
+ // Configuration is from sytem. (PrefProxyConfigTracker doesn't use this, |
+ // but we define it so that system proxy config services can use it). |
+ CONFIG_SOURCE_SYSTEM, |
+ }; |
+ |
explicit PrefProxyConfigTracker(PrefService* pref_service); |
// Observer manipulation is only valid on the IO thread. |
void AddObserver(Observer* observer); |
void RemoveObserver(Observer* observer); |
- // Get the proxy configuration currently defined by preferences. Status is |
- // indicated in the return value. Writes the configuration to |config| unless |
- // the return value is CONFIG_UNSET, in which case |config| is not touched. |
- ConfigState GetProxyConfig(net::ProxyConfig* config); |
+ // Get the proxy configuration currently defined by preferences on the IO |
+ // UI threads respectively. Status is indicated in the return value. |
+ // Writes the configuration to |config| and its source to |config_source| |
+ // unless the return value is CONFIG_UNSET, in which case |config| and |
+ // |config_source| are not touched. |
+ ConfigState IOGetProxyConfig(net::ProxyConfig* config, |
+ ConfigSource* config_source); |
+ ConfigState UIGetProxyConfig(net::ProxyConfig* config, |
+ ConfigSource* config_source); |
// Notifies the tracker that the pref service passed upon construction is |
// about to go away. This must be called from the UI thread. |
void DetachFromPrefService(); |
+ // Converts a ProxyConfigDictionary to net::ProxyConfig representation. |
+ // Returns true if the data from in the dictionary is valid, false otherwise. |
+ static bool PrefConfigToNetConfig(const ProxyConfigDictionary& proxy_dict, |
+ net::ProxyConfig* config); |
+ |
private: |
friend class base::RefCountedThreadSafe<PrefProxyConfigTracker>; |
virtual ~PrefProxyConfigTracker(); |
@@ -71,27 +97,37 @@ |
// the internal state after handling a pref change on the UI thread. |
// |config_state| indicates the new state we're switching to, and |config| is |
// the new preference-based proxy configuration if |config_state| is different |
- // from CONFIG_UNSET. |
- void InstallProxyConfig(const net::ProxyConfig& config, ConfigState state); |
+ // from CONFIG_UNSET, |source| is the new source of |config|. |
+ void InstallProxyConfig(const net::ProxyConfig& config, ConfigState state, |
+ ConfigSource source); |
// Creates a proxy configuration from proxy-related preferences. Configuration |
- // is stored in |config| and the return value indicates whether the |
- // configuration is valid. |
- ConfigState ReadPrefConfig(net::ProxyConfig* config); |
+ // is stored in |config| and its source in |config_source|, return value |
+ // indicates whether the configuration is valid. |
+ ConfigState ReadPrefConfig(net::ProxyConfig* config, |
+ ConfigSource* config_source); |
- // Converts a ProxyConfigDictionary to net::ProxyConfig representation. |
- // Returns true if the data from in the dictionary is valid, false otherwise. |
- static bool PrefConfigToNetConfig(const ProxyConfigDictionary& proxy_dict, |
- net::ProxyConfig* config); |
+ // Configuration as defined by prefs. Only to be accessed from UI thread. |
+ net::ProxyConfig ui_pref_config_; |
- // Configuration as defined by prefs. Only to be accessed from the IO thread |
- // (except for construction). |
- net::ProxyConfig pref_config_; |
+ // Tracks configuration state. |ui_pref_config_| is valid only if |
+ // |ui_config_state_| is not CONFIG_UNSET. |
+ ConfigState ui_config_state_; |
- // Tracks configuration state. |pref_config_| is valid only if |config_state_| |
- // is not CONFIG_UNSET. |
- ConfigState config_state_; |
+ // Tracks source of |ui_pref_config_|. |
+ ConfigSource ui_config_source_; |
+ // Configuration as defined by prefs. Only to be accessed from |
+ // IO thread, except for construction on UI thread. |
+ net::ProxyConfig io_pref_config_; |
+ |
+ // Tracks configuration state. |io_pref_config_| is valid only if |
+ // |io_config_state_| is not CONFIG_UNSET. |
+ ConfigState io_config_state_; |
+ |
+ // Tracks source of |io_pref_config_|. |
+ ConfigSource io_config_source_; |
+ |
// List of observers, accessed exclusively from the IO thread. |
ObserverList<Observer, true> observers_; |
@@ -102,13 +138,33 @@ |
DISALLOW_COPY_AND_ASSIGN(PrefProxyConfigTracker); |
}; |
+class ProxyConfigDecider { |
+ public: |
+ ProxyConfigDecider() {} |
+ virtual ~ProxyConfigDecider() {} |
+ |
+ net::ProxyConfigService::ConfigAvailability GetEffectiveProxyConfig( |
+ PrefProxyConfigTracker::ConfigState pref_state, |
+ const net::ProxyConfig& pref_config, |
+ PrefProxyConfigTracker::ConfigSource pref_source, |
+ net::ProxyConfigService::ConfigAvailability system_availability, |
+ const net::ProxyConfig& system_config, |
+ bool ignore_fallback_config, |
+ net::ProxyConfig* config, |
+ PrefProxyConfigTracker::ConfigSource* config_source); |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(ProxyConfigDecider); |
+}; |
+ |
// A net::ProxyConfigService implementation that applies preference proxy |
// settings as overrides to the proxy configuration determined by a baseline |
// delegate ProxyConfigService. |
class PrefProxyConfigService |
: public net::ProxyConfigService, |
public net::ProxyConfigService::Observer, |
- public PrefProxyConfigTracker::Observer { |
+ public PrefProxyConfigTracker::Observer, |
+ public ProxyConfigDecider { |
public: |
// Takes ownership of the passed |base_service|. |
PrefProxyConfigService(PrefProxyConfigTracker* tracker, |