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

Unified Diff: chrome/browser/chromeos/proxy_config_service_impl.h

Issue 8102019: redesign and reimplement proxy config service and tracker, revise proxy ui on cros (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months 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: chrome/browser/chromeos/proxy_config_service_impl.h
===================================================================
--- chrome/browser/chromeos/proxy_config_service_impl.h (revision 103881)
+++ chrome/browser/chromeos/proxy_config_service_impl.h (working copy)
@@ -16,10 +16,13 @@
#include "base/values.h"
#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/chromeos/login/signed_settings.h"
+#include "chrome/browser/net/pref_proxy_config_service.h"
#include "net/proxy/proxy_config.h"
#include "net/proxy/proxy_config_service.h"
#include "net/proxy/proxy_server.h"
+class Profile;
+
namespace chromeos {
// Implementation of proxy config service for chromeos that:
@@ -37,7 +40,8 @@
: public base::RefCountedThreadSafe<ProxyConfigServiceImpl>,
public SignedSettings::Delegate<std::string>,
public NetworkLibrary::NetworkManagerObserver,
- public NetworkLibrary::NetworkObserver {
+ public NetworkLibrary::NetworkObserver,
+ public ProxyConfigDecider {
public:
// ProxyConfigServiceImpl is created on the UI thread in
// chrome/browser/net/proxy_service_factory.cc::CreateProxyConfigService
@@ -80,28 +84,14 @@
MODE_PROXY_PER_SCHEME,
};
- // Specifies where proxy configuration was picked up from.
- enum Source {
- SOURCE_NONE, // No default configuration.
- SOURCE_POLICY, // Configuration is from policy.
- SOURCE_OWNER, // Configuration is from owner.
- };
-
- struct Setting {
- Setting() : source(SOURCE_NONE) {}
- bool CanBeWrittenByUser(bool user_is_owner);
-
- Source source;
- };
-
// Proxy setting for mode = direct or auto-detect or using pac script.
- struct AutomaticProxy : public Setting {
- GURL pac_url; // Set if proxy is using pac script.
+ struct AutomaticProxy {
+ GURL pac_url; // Set if proxy is using pac script.
};
// Proxy setting for mode = single-proxy or proxy-per-scheme.
- struct ManualProxy : public Setting {
- net::ProxyServer server;
+ struct ManualProxy {
+ net::ProxyServer server;
};
ProxyConfig();
@@ -110,10 +100,8 @@
// Converts |this| to net::ProxyConfig.
void ToNetProxyConfig(net::ProxyConfig* net_config);
- // Returns true if proxy config can be written by user.
- // If mode is MODE_PROXY_PER_SCHEME, |scheme| is one of "http", "https",
- // "ftp" or "socks"; otherwise, it should be empty or will be ignored.
- bool CanBeWrittenByUser(bool user_is_owner, const std::string& scheme);
+ // Converts net::ProxyConfig to |this|.
+ bool FromNetProxyConfig(const net::ProxyConfig& net_config);
// Map |scheme| (one of "http", "https", "ftp" or "socks") to the correct
// ManualProxy. Returns NULL if scheme is invalid.
@@ -137,11 +125,12 @@
// Returns true if the given config is equivalent to this config.
bool Equals(const ProxyConfig& other) const;
- // Creates a textual dump of the configuration.
- std::string ToString() const;
-
Mode mode;
+ PrefProxyConfigTracker::ConfigSource source;
+
+ bool user_modifiable;
Mattias Nissler (ping if slow) 2011/10/07 13:32:10 It would be good to have a comment explaining in w
kuan 2011/10/18 16:25:35 Done.
+
// Set if mode is MODE_DIRECT or MODE_AUTO_DETECT or MODE_PAC_SCRIPT.
AutomaticProxy automatic_proxy;
// Set if mode is MODE_SINGLE_PROXY.
@@ -179,37 +168,32 @@
explicit ProxyConfigServiceImpl(const ProxyConfig& init_config);
virtual ~ProxyConfigServiceImpl();
- // Methods called on IO thread from wrapper class chromeos::ProxyConfigService
- // as ProxyConfigService methods.
- void AddObserver(net::ProxyConfigService::Observer* observer);
- void RemoveObserver(net::ProxyConfigService::Observer* observer);
- // Called from GetLatestProxyConfig.
- net::ProxyConfigService::ConfigAvailability IOGetProxyConfig(
- net::ProxyConfig* config);
+ // Called from UI thread to set user preference use_shared_proxies.
+ void UISetUseSharedProxies(bool use_shared);
- // Called from UI thread to retrieve proxy configuration in |config|.
- void UIGetProxyConfig(ProxyConfig* config);
+ // Called from UI thread to set user |profile| whose prefs proxy config will
+ // be to be displayed or edited. Subsequent UISet* methods will use this
+ // profile, until UI calls it again with a different profile.
+ void UISetCurrentUserProfile(Profile* profile);
- // Called from UI thread to set service path of network to be displayed or
- // edited. Subsequent UISet* methods will use this network, until UI calls
+ // Called from UI thread to set service path of |network| to be displayed or
+ // edited. Subsequent UISet* methods will use this
+ // network, until UI calls
// it again with a different network.
Mattias Nissler (ping if slow) 2011/10/07 13:32:10 comment formatting.
kuan 2011/10/18 16:25:35 Done.
- bool UISetCurrentNetwork(const std::string& current_network);
+ void UISetCurrentNetwork(const std::string& current_network);
- // Called from UI thread to make the currently active network the one to be
- // displayed or edited. Subsequent UISet* methods will use this network. until
+ // Called from UI thread to make the currently active |etwork the one to be
Mattias Nissler (ping if slow) 2011/10/07 13:32:10 revert
kuan 2011/10/18 16:25:35 Done.
+ // displayed or edited. Subsequent UISet* methods will use this network until
// UI calls it again when the active network has changed.
- bool UIMakeActiveNetworkCurrent();
+ void UIMakeActiveNetworkCurrent();
// Called from UI thread to get name of the current active network.
const std::string& current_network_name() const {
return current_ui_network_name_;
}
- // Called from UI thread to set/get user preference use_shared_proxies.
- void UISetUseSharedProxies(bool use_shared);
- bool use_shared_proxies() const {
- return use_shared_proxies_;
- }
+ // Called from UI thread to retrieve proxy configuration in |config|.
+ void UIGetProxyConfig(ProxyConfig* config);
// Called from UI thread to update proxy configuration for different modes.
// Returns true if config is set properly and persisted to flimflam for the
@@ -240,6 +224,19 @@
// NetworkLibrary::NetworkObserver implementation.
virtual void OnNetworkChanged(NetworkLibrary* cros, const Network* network);
+ // Methods called on io thread from wrapper chromeos::ProxyConfigService as
Mattias Nissler (ping if slow) 2011/10/07 13:32:10 s/io/IO/
kuan 2011/10/18 16:25:35 function is removed.
+ // net::ProxyConfigService methods.
+ void AddObserver(net::ProxyConfigService::Observer* observer);
+ void RemoveObserver(net::ProxyConfigService::Observer* observer);
+ // Called from GetLatestProxyConfig.
Mattias Nissler (ping if slow) 2011/10/07 13:32:10 maybe adjust to match the name then?
kuan 2011/10/18 16:25:35 function is removed.
+ net::ProxyConfigService::ConfigAvailability IOGetProxyConfig(
+ net::ProxyConfig* config);
+
+ // Methods called on ui thread from wrapper chromeos::ProxyConfigService to
Mattias Nissler (ping if slow) 2011/10/07 13:32:10 s/ui/UI/
kuan 2011/10/18 16:25:35 function is removed.
+ // serve extra functionalities beyond net::ProxyCofigService methods.
+ // Implementation of PrefProxyConfigTracker::Observer.
+ void OnPrefProxyConfigChanged(PrefProxyConfigTracker* tracker);
+
#if defined(UNIT_TEST)
void SetTesting() {
testing_ = true;
@@ -272,13 +269,32 @@
const std::string& value,
bool only_set_if_empty);
- // Determines and activates proxy config of |network| based on if network is
- // shared/private or user is using shared proxies, etc.
- void DetermineConfigFromNetwork(const Network* network);
+ // Determines effective proxy config based on prefs from config tracker,
+ // |network| and if user is using shared proxies.
+ // If |activate| is true, effective config is stored in |active_config| and
+ // activated on IO thread, and hence, picked up by observers.
+ // if |activate| is false, effective config is stored in |current_ui_config|
+ // but not activated on io thread, and hence, not picked up by observers.
+ void DetermineEffectiveConfig(const Network* network, bool activate);
- // Set |current_ui_network_name_| with name of |network|.
- void SetCurrentNetworkName(const Network* network);
+ // Determine UI-related variables (|current_network_name_| and
+ // |current_ui_config_|) based on |network|, called from UISetCurrentNetwork
+ // and UIMakeActiveNetworkActive.
+ void OnUISetCurrentNetwork(const Network* network);
+ // Returns true if proxy is to be ignored for network, which happens if
+ // network is shared and use-shared-proxies is turned off.
+ bool IgnoreProxy(const Network* network) {
+ return network->profile_type() == PROFILE_SHARED && !use_shared_proxies_;
+ }
+
+ // Reset UI cache variables that keep track of ui changes.
Mattias Nissler (ping if slow) 2011/10/07 13:32:10 s/ui/UI/
kuan 2011/10/18 16:25:35 Done.
+ void ResetUICache();
+
+ // Returns prefs proxy config tracker of |current_ui_profile_| if available,
+ // or default profile.
+ PrefProxyConfigTracker* GetProxyConfigTracker();
+
// Checks that method is called on BrowserThread::IO thread.
void CheckCurrentlyOnIOThread();
@@ -296,41 +312,45 @@
// method until the class's ref_count is at least one).
bool can_post_task_;
- // Availability status of the configuration, initialized on UI thread, but
- // afterwards only accessed from IO thread.
- net::ProxyConfigService::ConfigAvailability config_availability_;
-
// Service path of currently active network (determined via flimflam
// notifications) whose proxy config is taking effect.
std::string active_network_;
- // Proxy configuration of |active_network_|, only accessed from UI thread.
+
+ // Active proxy configuration, which could be from prefs or network, only
+ // accessed from UI thread.
ProxyConfig active_config_;
// Proxy config retreived from device, in format generated from
// SerializeForNetwork, that can be directly set into flimflam.
std::string device_config_;
- // Cached proxy configuration, to be converted to net::ProxyConfig and
- // returned by IOGetProxyConfig.
- // Initially populated from UI thread, but afterwards only accessed from IO
- // thread.
- ProxyConfig cached_config_;
+ // Proxy configuration that is cache of |active_config_| and only accessible
+ // from IO thread (except for construction in UI thread), to be converted to
+ // net::ProxyConfig and returned by IOGetProxyConfig.
+ ProxyConfig io_config_;
+ // Availability status of |io_config_| accessible only from IO thread (except
+ // for construction in UI thread), returned by IOGetProxyConfig.
+ net::ProxyConfigService::ConfigAvailability io_config_availability_;
+
+ // True if user preference UseSharedProxies is true.
+ bool use_shared_proxies_;
+
+ // Current user profile, set in UISetCurrentUserProfile.
+ Profile* current_ui_profile_; // Weak ptr.
+
// Service path of network whose proxy configuration is being displayed or
// edited via UI, separate from |active_network_| which may be same or
// different.
std::string current_ui_network_;
- // Name of network with current_ui_network_, set in UIMakeActiveNetworkCurrent
- // and UISetCurrentNetwork.
+ // Name of network with current_ui_network_, set in UISetCurrentNetwork and
+ // UIMakeActiveNetworkCurrent.
std::string current_ui_network_name_;
// Proxy configuration of |current_ui_network|.
ProxyConfig current_ui_config_;
- // True if user preference UseSharedProxies is true.
- bool use_shared_proxies_;
-
// List of observers for changes in proxy config.
ObserverList<net::ProxyConfigService::Observer> observers_;

Powered by Google App Engine
This is Rietveld 408576698