| 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)
|
| @@ -20,6 +20,8 @@
|
| #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:
|
| @@ -81,26 +83,40 @@
|
| };
|
|
|
| // Specifies where proxy configuration was picked up from.
|
| + static const int kSourceDisabled = 0x1000;
|
| + enum SourceType {
|
| + SOURCE_TYPE_NONE = 1, // No configuration.
|
| + SOURCE_TYPE_POLICY = 2, // Configuration is from policy.
|
| + SOURCE_TYPE_EXTENSION = 3, // Configuration is from extension.
|
| + SOURCE_TYPE_RECOMMENDED = 4, // Configuration is recommended.
|
| + SOURCE_TYPE_NETWORK = 5, // Configuration is from network.
|
| + };
|
| enum Source {
|
| - SOURCE_NONE, // No default configuration.
|
| - SOURCE_POLICY, // Configuration is from policy.
|
| - SOURCE_OWNER, // Configuration is from owner.
|
| + // No configuration and writeable.
|
| + SOURCE_NONE = SOURCE_TYPE_NONE,
|
| + // No configuration and disabled.
|
| + SOURCE_NONE_DISABLED = SOURCE_TYPE_NONE | kSourceDisabled,
|
| + // Configuration is from policy and readonly.
|
| + SOURCE_POLICY = SOURCE_TYPE_POLICY | kSourceDisabled,
|
| + // Configuration is from extension and readonly.
|
| + SOURCE_EXTENSION = SOURCE_TYPE_EXTENSION | kSourceDisabled,
|
| + // Configuration is recommended and writeable.
|
| + SOURCE_RECOMMENDED = SOURCE_TYPE_RECOMMENDED,
|
| + // Configuration is recommended but disabled.
|
| + SOURCE_RECOMMENDED_DISABLED = SOURCE_TYPE_RECOMMENDED | kSourceDisabled,
|
| + // Configuration is from network and writeable.
|
| + SOURCE_NETWORK = SOURCE_TYPE_NETWORK,
|
| + // Configuration is from network but disabled.
|
| + SOURCE_NETWORK_DISABLED = SOURCE_TYPE_NETWORK | kSourceDisabled,
|
| };
|
|
|
| - 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 {
|
| + 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 {
|
| + struct ManualProxy {
|
| net::ProxyServer server;
|
| };
|
|
|
| @@ -110,11 +126,14 @@
|
| // 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);
|
|
|
| + // Returns true if proxy config can be modified by user.
|
| + bool IsUserModifiable() const {
|
| + return !(static_cast<int>(source) & kSourceDisabled);
|
| + }
|
| +
|
| // Map |scheme| (one of "http", "https", "ftp" or "socks") to the correct
|
| // ManualProxy. Returns NULL if scheme is invalid.
|
| ManualProxy* MapSchemeToProxy(const std::string& scheme);
|
| @@ -142,6 +161,8 @@
|
|
|
| Mode mode;
|
|
|
| + Source source;
|
| +
|
| // Set if mode is MODE_DIRECT or MODE_AUTO_DETECT or MODE_PAC_SCRIPT.
|
| AutomaticProxy automatic_proxy;
|
| // Set if mode is MODE_SINGLE_PROXY.
|
| @@ -191,29 +212,29 @@
|
| void UIGetProxyConfig(ProxyConfig* config);
|
|
|
| // 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.
|
| - bool UISetCurrentNetwork(const std::string& current_network);
|
| + // edited with the current user profile. Subsequent UISet* methods will use
|
| + // this network, until UI calls it again with a different network.
|
| + void UISetCurrentNetworkWithProfile(const std::string& current_network,
|
| + Profile* profile);
|
|
|
| // 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
|
| - // UI calls it again when the active network has changed.
|
| - bool UIMakeActiveNetworkCurrent();
|
| + // displayed or edited, with current user profile. Subsequent UISet* methods
|
| + // will use this network until UI calls it again when the active network has
|
| + // changed.
|
| + void UIMakeActiveNetworkCurrentWithProfile(Profile* profile);
|
|
|
| // 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.
|
| + // Called from UI thread to set user preference use_shared_proxies.
|
| void UISetUseSharedProxies(bool use_shared);
|
| - bool use_shared_proxies() const {
|
| - return use_shared_proxies_;
|
| - }
|
|
|
| // Called from UI thread to update proxy configuration for different modes.
|
| // Returns true if config is set properly and persisted to flimflam for the
|
| - // current network (set via UISetCurrentNetwork/UIMakeActiveNetworkCurrent).
|
| + // current network (set via UISetCurrentNetworkWithProfile or
|
| + // UIMakeActiveNetworkCurrentWithPRofile).
|
| // If this network is also currently active, config service proceeds to start
|
| // activating it on network stack.
|
| // Returns false if config is not set properly, probably because information
|
| @@ -244,7 +265,7 @@
|
| void SetTesting() {
|
| testing_ = true;
|
| active_network_ = "test";
|
| - UIMakeActiveNetworkCurrent();
|
| + UIMakeActiveNetworkCurrentWithProfile(NULL);
|
| }
|
| #endif // defined(UNIT_TEST)
|
|
|
| @@ -276,9 +297,21 @@
|
| // shared/private or user is using shared proxies, etc.
|
| void DetermineConfigFromNetwork(const Network* network);
|
|
|
| + // Determines proxy config for ui based on |profile| and |network|.
|
| + void DetermineUIConfig(Profile* profile, const Network* network);
|
| +
|
| // Set |current_ui_network_name_| with name of |network|.
|
| void SetCurrentNetworkName(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.
|
| + void ResetUICache();
|
| +
|
| // Checks that method is called on BrowserThread::IO thread.
|
| void CheckCurrentlyOnIOThread();
|
|
|
| @@ -316,21 +349,21 @@
|
| // thread.
|
| ProxyConfig cached_config_;
|
|
|
| + // True if user preference UseSharedProxies is true.
|
| + bool use_shared_proxies_;
|
| +
|
| // 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
|
| + // UIMakeActiveNetworkCurrentWithProfile and UISetCurrentNetworkWithProfile.
|
| 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_;
|
|
|
|
|