This source file includes following definitions.
- FixupProxyHostScheme
- GetProxyFromEnvVarForScheme
- GetProxyFromEnvVar
- GetConfigFromEnv
- notify_delegate_
- Init
- ShutDown
- SetUpNotifications
- GetNotificationTaskRunner
- GetConfigSource
- GetString
- GetBool
- GetInt
- GetStringList
- BypassListIsReversed
- MatchHostsUsingSuffixMatching
- GetStringByPath
- GetBoolByPath
- GetIntByPath
- GetStringListByPath
- HandleGError
- OnDebouncedNotification
- OnChangeNotification
- OnGConfChangeNotification
- notify_delegate_
- SchemaExists
- Init
- ShutDown
- SetUpNotifications
- GetNotificationTaskRunner
- GetConfigSource
- GetString
- GetBool
- GetInt
- GetStringList
- BypassListIsReversed
- MatchHostsUsingSuffixMatching
- GetStringByPath
- GetBoolByPath
- GetIntByPath
- GetStringListByPath
- OnDebouncedNotification
- OnChangeNotification
- OnGSettingsChangeNotification
- LoadAndCheckVersion
- file_loop_
- Init
- ShutDown
- SetUpNotifications
- GetNotificationTaskRunner
- OnFileCanReadWithoutBlocking
- OnFileCanWriteWithoutBlocking
- GetConfigSource
- GetString
- GetBool
- GetInt
- GetStringList
- BypassListIsReversed
- MatchHostsUsingSuffixMatching
- ResetCachedSettings
- KDEHomeToConfigPath
- AddProxy
- AddHostList
- AddKDESetting
- ResolveIndirect
- ResolveIndirectList
- ResolveModeEffects
- UpdateCachedSettings
- OnDebouncedNotification
- OnChangeNotification
- GetProxyFromSettings
- GetConfigFromSettings
- setting_getter_
- SetUpAndFetchInitialConfig
- SetUpNotifications
- AddObserver
- RemoveObserver
- GetLatestProxyConfig
- OnCheckProxyConfigSettings
- SetNewProxyConfig
- PostDestroyTask
- OnDestroy
- AddObserver
- RemoveObserver
- GetLatestProxyConfig
#include "net/proxy/proxy_config_service_linux.h"
#include <errno.h>
#include <fcntl.h>
#if defined(USE_GCONF)
#include <gconf/gconf-client.h>
#endif
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/inotify.h>
#include <unistd.h>
#include <map>
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/environment.h"
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/files/scoped_file.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/nix/xdg_util.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_tokenizer.h"
#include "base/strings/string_util.h"
#include "base/threading/thread_restrictions.h"
#include "base/timer/timer.h"
#include "net/base/net_errors.h"
#include "net/http/http_util.h"
#include "net/proxy/proxy_config.h"
#include "net/proxy/proxy_server.h"
#include "url/url_canon.h"
#if defined(USE_GIO)
#include "library_loaders/libgio.h"
#endif
namespace net {
namespace {
std::string FixupProxyHostScheme(ProxyServer::Scheme scheme,
std::string host) {
if (scheme == ProxyServer::SCHEME_SOCKS5 &&
StartsWithASCII(host, "socks4://", false)) {
scheme = ProxyServer::SCHEME_SOCKS4;
}
std::string::size_type colon = host.find("://");
if (colon != std::string::npos)
host = host.substr(colon + 3);
std::string::size_type at_sign = host.find("@");
if (at_sign != std::string::npos) {
LOG(WARNING) << "Proxy authentication parameters ignored, see bug 16709";
host = host.substr(at_sign + 1);
}
if (scheme == ProxyServer::SCHEME_SOCKS4)
host = "socks4://" + host;
else if (scheme == ProxyServer::SCHEME_SOCKS5)
host = "socks5://" + host;
if (host.length() && host[host.length() - 1] == '/')
host.resize(host.length() - 1);
return host;
}
}
ProxyConfigServiceLinux::Delegate::~Delegate() {
}
bool ProxyConfigServiceLinux::Delegate::GetProxyFromEnvVarForScheme(
const char* variable, ProxyServer::Scheme scheme,
ProxyServer* result_server) {
std::string env_value;
if (env_var_getter_->GetVar(variable, &env_value)) {
if (!env_value.empty()) {
env_value = FixupProxyHostScheme(scheme, env_value);
ProxyServer proxy_server =
ProxyServer::FromURI(env_value, ProxyServer::SCHEME_HTTP);
if (proxy_server.is_valid() && !proxy_server.is_direct()) {
*result_server = proxy_server;
return true;
} else {
LOG(ERROR) << "Failed to parse environment variable " << variable;
}
}
}
return false;
}
bool ProxyConfigServiceLinux::Delegate::GetProxyFromEnvVar(
const char* variable, ProxyServer* result_server) {
return GetProxyFromEnvVarForScheme(variable, ProxyServer::SCHEME_HTTP,
result_server);
}
bool ProxyConfigServiceLinux::Delegate::GetConfigFromEnv(ProxyConfig* config) {
std::string auto_proxy;
if (env_var_getter_->GetVar("auto_proxy", &auto_proxy)) {
if (auto_proxy.empty()) {
config->set_auto_detect(true);
} else {
config->set_pac_url(GURL(auto_proxy));
}
return true;
}
ProxyServer proxy_server;
if (GetProxyFromEnvVar("all_proxy", &proxy_server)) {
config->proxy_rules().type = ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY;
config->proxy_rules().single_proxies.SetSingleProxyServer(proxy_server);
} else {
bool have_http = GetProxyFromEnvVar("http_proxy", &proxy_server);
if (have_http)
config->proxy_rules().proxies_for_http.SetSingleProxyServer(proxy_server);
bool have_https = GetProxyFromEnvVar("https_proxy", &proxy_server);
if (have_https)
config->proxy_rules().proxies_for_https.
SetSingleProxyServer(proxy_server);
bool have_ftp = GetProxyFromEnvVar("ftp_proxy", &proxy_server);
if (have_ftp)
config->proxy_rules().proxies_for_ftp.SetSingleProxyServer(proxy_server);
if (have_http || have_https || have_ftp) {
config->proxy_rules().type =
ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME;
}
}
if (config->proxy_rules().empty()) {
ProxyServer::Scheme scheme = ProxyServer::SCHEME_SOCKS5;
std::string env_version;
if (env_var_getter_->GetVar("SOCKS_VERSION", &env_version)
&& env_version == "4")
scheme = ProxyServer::SCHEME_SOCKS4;
if (GetProxyFromEnvVarForScheme("SOCKS_SERVER", scheme, &proxy_server)) {
config->proxy_rules().type = ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY;
config->proxy_rules().single_proxies.SetSingleProxyServer(proxy_server);
}
}
std::string no_proxy;
env_var_getter_->GetVar("no_proxy", &no_proxy);
if (config->proxy_rules().empty()) {
return !no_proxy.empty();
}
config->proxy_rules().bypass_rules.ParseFromStringUsingSuffixMatching(
no_proxy);
return true;
}
namespace {
const int kDebounceTimeoutMilliseconds = 250;
#if defined(USE_GCONF)
class SettingGetterImplGConf : public ProxyConfigServiceLinux::SettingGetter {
public:
SettingGetterImplGConf()
: client_(NULL), system_proxy_id_(0), system_http_proxy_id_(0),
notify_delegate_(NULL) {
}
virtual ~SettingGetterImplGConf() {
if (client_) {
if (task_runner_->BelongsToCurrentThread()) {
VLOG(1) << "~SettingGetterImplGConf: releasing gconf client";
ShutDown();
} else {
LOG(FATAL) << "~SettingGetterImplGConf: deleting on wrong thread!";
}
}
DCHECK(!client_);
}
virtual bool Init(base::SingleThreadTaskRunner* glib_thread_task_runner,
base::MessageLoopForIO* file_loop) OVERRIDE {
DCHECK(glib_thread_task_runner->BelongsToCurrentThread());
DCHECK(!client_);
DCHECK(!task_runner_.get());
task_runner_ = glib_thread_task_runner;
client_ = gconf_client_get_default();
if (!client_) {
LOG(ERROR) << "Unable to create a gconf client";
task_runner_ = NULL;
return false;
}
GError* error = NULL;
bool added_system_proxy = false;
gconf_client_add_dir(client_, "/system/proxy",
GCONF_CLIENT_PRELOAD_ONELEVEL, &error);
if (error == NULL) {
added_system_proxy = true;
gconf_client_add_dir(client_, "/system/http_proxy",
GCONF_CLIENT_PRELOAD_ONELEVEL, &error);
}
if (error != NULL) {
LOG(ERROR) << "Error requesting gconf directory: " << error->message;
g_error_free(error);
if (added_system_proxy)
gconf_client_remove_dir(client_, "/system/proxy", NULL);
g_object_unref(client_);
client_ = NULL;
task_runner_ = NULL;
return false;
}
return true;
}
virtual void ShutDown() OVERRIDE {
if (client_) {
DCHECK(task_runner_->BelongsToCurrentThread());
gconf_client_notify_remove(client_, system_http_proxy_id_);
gconf_client_notify_remove(client_, system_proxy_id_);
gconf_client_remove_dir(client_, "/system/http_proxy", NULL);
gconf_client_remove_dir(client_, "/system/proxy", NULL);
g_object_unref(client_);
client_ = NULL;
task_runner_ = NULL;
}
}
virtual bool SetUpNotifications(
ProxyConfigServiceLinux::Delegate* delegate) OVERRIDE {
DCHECK(client_);
DCHECK(task_runner_->BelongsToCurrentThread());
GError* error = NULL;
notify_delegate_ = delegate;
system_proxy_id_ = gconf_client_notify_add(
client_, "/system/proxy",
OnGConfChangeNotification, this,
NULL, &error);
if (error == NULL) {
system_http_proxy_id_ = gconf_client_notify_add(
client_, "/system/http_proxy",
OnGConfChangeNotification, this,
NULL, &error);
}
if (error != NULL) {
LOG(ERROR) << "Error requesting gconf notifications: " << error->message;
g_error_free(error);
ShutDown();
return false;
}
OnChangeNotification();
return true;
}
virtual base::SingleThreadTaskRunner* GetNotificationTaskRunner() OVERRIDE {
return task_runner_.get();
}
virtual ProxyConfigSource GetConfigSource() OVERRIDE {
return PROXY_CONFIG_SOURCE_GCONF;
}
virtual bool GetString(StringSetting key, std::string* result) OVERRIDE {
switch (key) {
case PROXY_MODE:
return GetStringByPath("/system/proxy/mode", result);
case PROXY_AUTOCONF_URL:
return GetStringByPath("/system/proxy/autoconfig_url", result);
case PROXY_HTTP_HOST:
return GetStringByPath("/system/http_proxy/host", result);
case PROXY_HTTPS_HOST:
return GetStringByPath("/system/proxy/secure_host", result);
case PROXY_FTP_HOST:
return GetStringByPath("/system/proxy/ftp_host", result);
case PROXY_SOCKS_HOST:
return GetStringByPath("/system/proxy/socks_host", result);
}
return false;
}
virtual bool GetBool(BoolSetting key, bool* result) OVERRIDE {
switch (key) {
case PROXY_USE_HTTP_PROXY:
return GetBoolByPath("/system/http_proxy/use_http_proxy", result);
case PROXY_USE_SAME_PROXY:
return GetBoolByPath("/system/http_proxy/use_same_proxy", result);
case PROXY_USE_AUTHENTICATION:
return GetBoolByPath("/system/http_proxy/use_authentication", result);
}
return false;
}
virtual bool GetInt(IntSetting key, int* result) OVERRIDE {
switch (key) {
case PROXY_HTTP_PORT:
return GetIntByPath("/system/http_proxy/port", result);
case PROXY_HTTPS_PORT:
return GetIntByPath("/system/proxy/secure_port", result);
case PROXY_FTP_PORT:
return GetIntByPath("/system/proxy/ftp_port", result);
case PROXY_SOCKS_PORT:
return GetIntByPath("/system/proxy/socks_port", result);
}
return false;
}
virtual bool GetStringList(StringListSetting key,
std::vector<std::string>* result) OVERRIDE {
switch (key) {
case PROXY_IGNORE_HOSTS:
return GetStringListByPath("/system/http_proxy/ignore_hosts", result);
}
return false;
}
virtual bool BypassListIsReversed() OVERRIDE {
return false;
}
virtual bool MatchHostsUsingSuffixMatching() OVERRIDE {
return false;
}
private:
bool GetStringByPath(const char* key, std::string* result) {
DCHECK(client_);
DCHECK(task_runner_->BelongsToCurrentThread());
GError* error = NULL;
gchar* value = gconf_client_get_string(client_, key, &error);
if (HandleGError(error, key))
return false;
if (!value)
return false;
*result = value;
g_free(value);
return true;
}
bool GetBoolByPath(const char* key, bool* result) {
DCHECK(client_);
DCHECK(task_runner_->BelongsToCurrentThread());
GError* error = NULL;
GConfValue* gconf_value = gconf_client_get(client_, key, &error);
if (HandleGError(error, key))
return false;
if (!gconf_value) {
return false;
}
if (gconf_value->type != GCONF_VALUE_BOOL) {
gconf_value_free(gconf_value);
return false;
}
gboolean bool_value = gconf_value_get_bool(gconf_value);
*result = static_cast<bool>(bool_value);
gconf_value_free(gconf_value);
return true;
}
bool GetIntByPath(const char* key, int* result) {
DCHECK(client_);
DCHECK(task_runner_->BelongsToCurrentThread());
GError* error = NULL;
int value = gconf_client_get_int(client_, key, &error);
if (HandleGError(error, key))
return false;
*result = value;
return true;
}
bool GetStringListByPath(const char* key, std::vector<std::string>* result) {
DCHECK(client_);
DCHECK(task_runner_->BelongsToCurrentThread());
GError* error = NULL;
GSList* list = gconf_client_get_list(client_, key,
GCONF_VALUE_STRING, &error);
if (HandleGError(error, key))
return false;
if (!list)
return false;
for (GSList *it = list; it; it = it->next) {
result->push_back(static_cast<char*>(it->data));
g_free(it->data);
}
g_slist_free(list);
return true;
}
bool HandleGError(GError* error, const char* key) {
if (error != NULL) {
LOG(ERROR) << "Error getting gconf value for " << key
<< ": " << error->message;
g_error_free(error);
return true;
}
return false;
}
void OnDebouncedNotification() {
DCHECK(task_runner_->BelongsToCurrentThread());
CHECK(notify_delegate_);
notify_delegate_->OnCheckProxyConfigSettings();
}
void OnChangeNotification() {
debounce_timer_.Stop();
debounce_timer_.Start(FROM_HERE,
base::TimeDelta::FromMilliseconds(kDebounceTimeoutMilliseconds),
this, &SettingGetterImplGConf::OnDebouncedNotification);
}
static void OnGConfChangeNotification(GConfClient* client, guint cnxn_id,
GConfEntry* entry, gpointer user_data) {
VLOG(1) << "gconf change notification for key "
<< gconf_entry_get_key(entry);
SettingGetterImplGConf* setting_getter =
reinterpret_cast<SettingGetterImplGConf*>(user_data);
setting_getter->OnChangeNotification();
}
GConfClient* client_;
guint system_proxy_id_;
guint system_http_proxy_id_;
ProxyConfigServiceLinux::Delegate* notify_delegate_;
base::OneShotTimer<SettingGetterImplGConf> debounce_timer_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
DISALLOW_COPY_AND_ASSIGN(SettingGetterImplGConf);
};
#endif
#if defined(USE_GIO)
class SettingGetterImplGSettings
: public ProxyConfigServiceLinux::SettingGetter {
public:
SettingGetterImplGSettings() :
client_(NULL),
http_client_(NULL),
https_client_(NULL),
ftp_client_(NULL),
socks_client_(NULL),
notify_delegate_(NULL) {
}
virtual ~SettingGetterImplGSettings() {
if (client_) {
if (task_runner_->BelongsToCurrentThread()) {
VLOG(1) << "~SettingGetterImplGSettings: releasing gsettings client";
ShutDown();
} else {
LOG(WARNING) << "~SettingGetterImplGSettings: leaking gsettings client";
client_ = NULL;
}
}
DCHECK(!client_);
}
bool SchemaExists(const char* schema_name) {
const gchar* const* schemas = libgio_loader_.g_settings_list_schemas();
while (*schemas) {
if (strcmp(schema_name, static_cast<const char*>(*schemas)) == 0)
return true;
schemas++;
}
return false;
}
bool LoadAndCheckVersion(base::Environment* env);
virtual bool Init(base::SingleThreadTaskRunner* glib_thread_task_runner,
base::MessageLoopForIO* file_loop) OVERRIDE {
DCHECK(glib_thread_task_runner->BelongsToCurrentThread());
DCHECK(!client_);
DCHECK(!task_runner_.get());
if (!SchemaExists("org.gnome.system.proxy") ||
!(client_ = libgio_loader_.g_settings_new("org.gnome.system.proxy"))) {
LOG(ERROR) << "Unable to create a gsettings client";
return false;
}
task_runner_ = glib_thread_task_runner;
http_client_ = libgio_loader_.g_settings_get_child(client_, "http");
https_client_ = libgio_loader_.g_settings_get_child(client_, "https");
ftp_client_ = libgio_loader_.g_settings_get_child(client_, "ftp");
socks_client_ = libgio_loader_.g_settings_get_child(client_, "socks");
DCHECK(http_client_ && https_client_ && ftp_client_ && socks_client_);
return true;
}
virtual void ShutDown() OVERRIDE {
if (client_) {
DCHECK(task_runner_->BelongsToCurrentThread());
g_object_unref(socks_client_);
g_object_unref(ftp_client_);
g_object_unref(https_client_);
g_object_unref(http_client_);
g_object_unref(client_);
client_ = NULL;
task_runner_ = NULL;
}
}
virtual bool SetUpNotifications(
ProxyConfigServiceLinux::Delegate* delegate) OVERRIDE {
DCHECK(client_);
DCHECK(task_runner_->BelongsToCurrentThread());
notify_delegate_ = delegate;
g_signal_connect(G_OBJECT(client_), "changed",
G_CALLBACK(OnGSettingsChangeNotification), this);
g_signal_connect(G_OBJECT(http_client_), "changed",
G_CALLBACK(OnGSettingsChangeNotification), this);
g_signal_connect(G_OBJECT(https_client_), "changed",
G_CALLBACK(OnGSettingsChangeNotification), this);
g_signal_connect(G_OBJECT(ftp_client_), "changed",
G_CALLBACK(OnGSettingsChangeNotification), this);
g_signal_connect(G_OBJECT(socks_client_), "changed",
G_CALLBACK(OnGSettingsChangeNotification), this);
OnChangeNotification();
return true;
}
virtual base::SingleThreadTaskRunner* GetNotificationTaskRunner() OVERRIDE {
return task_runner_.get();
}
virtual ProxyConfigSource GetConfigSource() OVERRIDE {
return PROXY_CONFIG_SOURCE_GSETTINGS;
}
virtual bool GetString(StringSetting key, std::string* result) OVERRIDE {
DCHECK(client_);
switch (key) {
case PROXY_MODE:
return GetStringByPath(client_, "mode", result);
case PROXY_AUTOCONF_URL:
return GetStringByPath(client_, "autoconfig-url", result);
case PROXY_HTTP_HOST:
return GetStringByPath(http_client_, "host", result);
case PROXY_HTTPS_HOST:
return GetStringByPath(https_client_, "host", result);
case PROXY_FTP_HOST:
return GetStringByPath(ftp_client_, "host", result);
case PROXY_SOCKS_HOST:
return GetStringByPath(socks_client_, "host", result);
}
return false;
}
virtual bool GetBool(BoolSetting key, bool* result) OVERRIDE {
DCHECK(client_);
switch (key) {
case PROXY_USE_HTTP_PROXY:
return false;
case PROXY_USE_SAME_PROXY:
return false;
case PROXY_USE_AUTHENTICATION:
return GetBoolByPath(http_client_, "use-authentication", result);
}
return false;
}
virtual bool GetInt(IntSetting key, int* result) OVERRIDE {
DCHECK(client_);
switch (key) {
case PROXY_HTTP_PORT:
return GetIntByPath(http_client_, "port", result);
case PROXY_HTTPS_PORT:
return GetIntByPath(https_client_, "port", result);
case PROXY_FTP_PORT:
return GetIntByPath(ftp_client_, "port", result);
case PROXY_SOCKS_PORT:
return GetIntByPath(socks_client_, "port", result);
}
return false;
}
virtual bool GetStringList(StringListSetting key,
std::vector<std::string>* result) OVERRIDE {
DCHECK(client_);
switch (key) {
case PROXY_IGNORE_HOSTS:
return GetStringListByPath(client_, "ignore-hosts", result);
}
return false;
}
virtual bool BypassListIsReversed() OVERRIDE {
return false;
}
virtual bool MatchHostsUsingSuffixMatching() OVERRIDE {
return false;
}
private:
bool GetStringByPath(GSettings* client, const char* key,
std::string* result) {
DCHECK(task_runner_->BelongsToCurrentThread());
gchar* value = libgio_loader_.g_settings_get_string(client, key);
if (!value)
return false;
*result = value;
g_free(value);
return true;
}
bool GetBoolByPath(GSettings* client, const char* key, bool* result) {
DCHECK(task_runner_->BelongsToCurrentThread());
*result = static_cast<bool>(
libgio_loader_.g_settings_get_boolean(client, key));
return true;
}
bool GetIntByPath(GSettings* client, const char* key, int* result) {
DCHECK(task_runner_->BelongsToCurrentThread());
*result = libgio_loader_.g_settings_get_int(client, key);
return true;
}
bool GetStringListByPath(GSettings* client, const char* key,
std::vector<std::string>* result) {
DCHECK(task_runner_->BelongsToCurrentThread());
gchar** list = libgio_loader_.g_settings_get_strv(client, key);
if (!list)
return false;
for (size_t i = 0; list[i]; ++i) {
result->push_back(static_cast<char*>(list[i]));
g_free(list[i]);
}
g_free(list);
return true;
}
void OnDebouncedNotification() {
DCHECK(task_runner_->BelongsToCurrentThread());
CHECK(notify_delegate_);
notify_delegate_->OnCheckProxyConfigSettings();
}
void OnChangeNotification() {
debounce_timer_.Stop();
debounce_timer_.Start(FROM_HERE,
base::TimeDelta::FromMilliseconds(kDebounceTimeoutMilliseconds),
this, &SettingGetterImplGSettings::OnDebouncedNotification);
}
static void OnGSettingsChangeNotification(GSettings* client, gchar* key,
gpointer user_data) {
VLOG(1) << "gsettings change notification for key " << key;
SettingGetterImplGSettings* setting_getter =
reinterpret_cast<SettingGetterImplGSettings*>(user_data);
setting_getter->OnChangeNotification();
}
GSettings* client_;
GSettings* http_client_;
GSettings* https_client_;
GSettings* ftp_client_;
GSettings* socks_client_;
ProxyConfigServiceLinux::Delegate* notify_delegate_;
base::OneShotTimer<SettingGetterImplGSettings> debounce_timer_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
LibGioLoader libgio_loader_;
DISALLOW_COPY_AND_ASSIGN(SettingGetterImplGSettings);
};
bool SettingGetterImplGSettings::LoadAndCheckVersion(
base::Environment* env) {
DCHECK(!client_);
{
base::ThreadRestrictions::ScopedAllowIO allow_io;
if (!libgio_loader_.Load("libgio-2.0.so.0") &&
!libgio_loader_.Load("libgio-2.0.so")) {
VLOG(1) << "Cannot load gio library. Will fall back to gconf.";
return false;
}
}
GSettings* client;
if (!SchemaExists("org.gnome.system.proxy") ||
!(client = libgio_loader_.g_settings_new("org.gnome.system.proxy"))) {
VLOG(1) << "Cannot create gsettings client. Will fall back to gconf.";
return false;
}
g_object_unref(client);
std::string path;
if (!env->GetVar("PATH", &path)) {
LOG(ERROR) << "No $PATH variable. Assuming no gnome-network-properties.";
} else {
base::ThreadRestrictions::ScopedAllowIO allow_io;
std::vector<std::string> paths;
Tokenize(path, ":", &paths);
for (size_t i = 0; i < paths.size(); ++i) {
base::FilePath file(paths[i]);
if (base::PathExists(file.Append("gnome-network-properties"))) {
VLOG(1) << "Found gnome-network-properties. Will fall back to gconf.";
return false;
}
}
}
VLOG(1) << "All gsettings tests OK. Will get proxy config from gsettings.";
return true;
}
#endif
class SettingGetterImplKDE : public ProxyConfigServiceLinux::SettingGetter,
public base::MessagePumpLibevent::Watcher {
public:
explicit SettingGetterImplKDE(base::Environment* env_var_getter)
: inotify_fd_(-1), notify_delegate_(NULL), indirect_manual_(false),
auto_no_pac_(false), reversed_bypass_list_(false),
env_var_getter_(env_var_getter), file_loop_(NULL) {
base::ThreadRestrictions::ScopedAllowIO allow_io;
std::string home;
if (env_var_getter->GetVar("KDEHOME", &home) && !home.empty()) {
kde_config_dir_ = KDEHomeToConfigPath(base::FilePath(home));
} else {
if (!env_var_getter->GetVar(base::env_vars::kHome, &home))
return;
if (base::nix::GetDesktopEnvironment(env_var_getter) ==
base::nix::DESKTOP_ENVIRONMENT_KDE3) {
base::FilePath kde_path = base::FilePath(home).Append(".kde");
kde_config_dir_ = KDEHomeToConfigPath(kde_path);
} else {
base::FilePath kde3_path = base::FilePath(home).Append(".kde");
base::FilePath kde3_config = KDEHomeToConfigPath(kde3_path);
base::FilePath kde4_path = base::FilePath(home).Append(".kde4");
base::FilePath kde4_config = KDEHomeToConfigPath(kde4_path);
bool use_kde4 = false;
if (base::DirectoryExists(kde4_path)) {
base::File::Info kde3_info;
base::File::Info kde4_info;
if (base::GetFileInfo(kde4_config, &kde4_info)) {
if (base::GetFileInfo(kde3_config, &kde3_info)) {
use_kde4 = kde4_info.last_modified >= kde3_info.last_modified;
} else {
use_kde4 = true;
}
}
}
if (use_kde4) {
kde_config_dir_ = KDEHomeToConfigPath(kde4_path);
} else {
kde_config_dir_ = KDEHomeToConfigPath(kde3_path);
}
}
}
}
virtual ~SettingGetterImplKDE() {
if (inotify_fd_ >= 0)
ShutDown();
DCHECK(inotify_fd_ < 0);
}
virtual bool Init(base::SingleThreadTaskRunner* glib_thread_task_runner,
base::MessageLoopForIO* file_loop) OVERRIDE {
base::ThreadRestrictions::ScopedAllowIO allow_io;
DCHECK(inotify_fd_ < 0);
inotify_fd_ = inotify_init();
if (inotify_fd_ < 0) {
PLOG(ERROR) << "inotify_init failed";
return false;
}
int flags = fcntl(inotify_fd_, F_GETFL);
if (fcntl(inotify_fd_, F_SETFL, flags | O_NONBLOCK) < 0) {
PLOG(ERROR) << "fcntl failed";
close(inotify_fd_);
inotify_fd_ = -1;
return false;
}
file_loop_ = file_loop;
UpdateCachedSettings();
return true;
}
virtual void ShutDown() OVERRIDE {
if (inotify_fd_ >= 0) {
ResetCachedSettings();
inotify_watcher_.StopWatchingFileDescriptor();
close(inotify_fd_);
inotify_fd_ = -1;
}
}
virtual bool SetUpNotifications(
ProxyConfigServiceLinux::Delegate* delegate) OVERRIDE {
DCHECK(inotify_fd_ >= 0);
DCHECK(base::MessageLoop::current() == file_loop_);
if (inotify_add_watch(inotify_fd_, kde_config_dir_.value().c_str(),
IN_MODIFY | IN_MOVED_TO) < 0)
return false;
notify_delegate_ = delegate;
if (!file_loop_->WatchFileDescriptor(inotify_fd_,
true,
base::MessageLoopForIO::WATCH_READ,
&inotify_watcher_,
this))
return false;
OnChangeNotification();
return true;
}
virtual base::SingleThreadTaskRunner* GetNotificationTaskRunner() OVERRIDE {
return file_loop_ ? file_loop_->message_loop_proxy().get() : NULL;
}
virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE {
DCHECK_EQ(fd, inotify_fd_);
DCHECK(base::MessageLoop::current() == file_loop_);
OnChangeNotification();
}
virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE {
NOTREACHED();
}
virtual ProxyConfigSource GetConfigSource() OVERRIDE {
return PROXY_CONFIG_SOURCE_KDE;
}
virtual bool GetString(StringSetting key, std::string* result) OVERRIDE {
string_map_type::iterator it = string_table_.find(key);
if (it == string_table_.end())
return false;
*result = it->second;
return true;
}
virtual bool GetBool(BoolSetting key, bool* result) OVERRIDE {
return false;
}
virtual bool GetInt(IntSetting key, int* result) OVERRIDE {
return false;
}
virtual bool GetStringList(StringListSetting key,
std::vector<std::string>* result) OVERRIDE {
strings_map_type::iterator it = strings_table_.find(key);
if (it == strings_table_.end())
return false;
*result = it->second;
return true;
}
virtual bool BypassListIsReversed() OVERRIDE {
return reversed_bypass_list_;
}
virtual bool MatchHostsUsingSuffixMatching() OVERRIDE {
return true;
}
private:
void ResetCachedSettings() {
string_table_.clear();
strings_table_.clear();
indirect_manual_ = false;
auto_no_pac_ = false;
reversed_bypass_list_ = false;
}
base::FilePath KDEHomeToConfigPath(const base::FilePath& kde_home) {
return kde_home.Append("share").Append("config");
}
void AddProxy(StringSetting host_key, const std::string& value) {
if (value.empty() || value.substr(0, 3) == "//:")
return;
size_t space = value.find(' ');
if (space != std::string::npos) {
std::string fixed = value;
fixed[space] = ':';
string_table_[host_key] = fixed;
} else {
string_table_[host_key] = value;
}
}
void AddHostList(StringListSetting key, const std::string& value) {
std::vector<std::string> tokens;
base::StringTokenizer tk(value, ", ");
while (tk.GetNext()) {
std::string token = tk.token();
if (!token.empty())
tokens.push_back(token);
}
strings_table_[key] = tokens;
}
void AddKDESetting(const std::string& key, const std::string& value) {
if (key == "ProxyType") {
const char* mode = "none";
indirect_manual_ = false;
auto_no_pac_ = false;
int int_value;
base::StringToInt(value, &int_value);
switch (int_value) {
case 0:
break;
case 1:
mode = "manual";
break;
case 2:
mode = "auto";
break;
case 3:
mode = "auto";
auto_no_pac_ = true;
break;
case 4:
mode = "manual";
indirect_manual_ = true;
break;
}
string_table_[PROXY_MODE] = mode;
} else if (key == "Proxy Config Script") {
string_table_[PROXY_AUTOCONF_URL] = value;
} else if (key == "httpProxy") {
AddProxy(PROXY_HTTP_HOST, value);
} else if (key == "httpsProxy") {
AddProxy(PROXY_HTTPS_HOST, value);
} else if (key == "ftpProxy") {
AddProxy(PROXY_FTP_HOST, value);
} else if (key == "socksProxy") {
AddProxy(PROXY_SOCKS_HOST, value);
} else if (key == "ReversedException") {
int int_value;
base::StringToInt(value, &int_value);
reversed_bypass_list_ = (value == "true" || int_value);
} else if (key == "NoProxyFor") {
AddHostList(PROXY_IGNORE_HOSTS, value);
} else if (key == "AuthMode") {
int mode;
base::StringToInt(value, &mode);
if (mode) {
LOG(WARNING) <<
"Proxy authentication parameters ignored, see bug 16709";
}
}
}
void ResolveIndirect(StringSetting key) {
string_map_type::iterator it = string_table_.find(key);
if (it != string_table_.end()) {
std::string value;
if (env_var_getter_->GetVar(it->second.c_str(), &value))
it->second = value;
else
string_table_.erase(it);
}
}
void ResolveIndirectList(StringListSetting key) {
strings_map_type::iterator it = strings_table_.find(key);
if (it != strings_table_.end()) {
std::string value;
if (!it->second.empty() &&
env_var_getter_->GetVar(it->second[0].c_str(), &value))
AddHostList(key, value);
else
strings_table_.erase(it);
}
}
void ResolveModeEffects() {
if (indirect_manual_) {
ResolveIndirect(PROXY_HTTP_HOST);
ResolveIndirect(PROXY_HTTPS_HOST);
ResolveIndirect(PROXY_FTP_HOST);
ResolveIndirectList(PROXY_IGNORE_HOSTS);
}
if (auto_no_pac_) {
string_table_.erase(PROXY_AUTOCONF_URL);
}
}
void UpdateCachedSettings() {
base::FilePath kioslaverc = kde_config_dir_.Append("kioslaverc");
base::ScopedFILE input(base::OpenFile(kioslaverc, "r"));
if (!input.get())
return;
ResetCachedSettings();
bool in_proxy_settings = false;
bool line_too_long = false;
char line[BUFFER_SIZE];
while (fgets(line, sizeof(line), input.get())) {
size_t length = strlen(line);
if (!length)
continue;
if (line[length - 1] != '\n') {
line_too_long = true;
continue;
}
if (line_too_long) {
LOG(WARNING) << "skipped very long line in " << kioslaverc.value();
line_too_long = false;
continue;
}
line[--length] = '\0';
if (length && line[length - 1] == '\r')
line[--length] = '\0';
if (line[0] == '[') {
in_proxy_settings = !strncmp(line, "[Proxy Settings]", 16);
} else if (in_proxy_settings) {
char* split = strchr(line, '=');
if (!split)
continue;
*(split++) = 0;
std::string key = line;
std::string value = split;
base::TrimWhitespaceASCII(key, base::TRIM_ALL, &key);
base::TrimWhitespaceASCII(value, base::TRIM_ALL, &value);
if (key.empty())
continue;
if (key[key.length() - 1] == ']') {
length = key.rfind('[');
if (length == std::string::npos)
continue;
key.resize(length);
base::TrimWhitespaceASCII(key, base::TRIM_TRAILING, &key);
if (key.empty())
continue;
}
AddKDESetting(key, value);
}
}
if (ferror(input.get()))
LOG(ERROR) << "error reading " << kioslaverc.value();
ResolveModeEffects();
}
void OnDebouncedNotification() {
DCHECK(base::MessageLoop::current() == file_loop_);
VLOG(1) << "inotify change notification for kioslaverc";
UpdateCachedSettings();
CHECK(notify_delegate_);
notify_delegate_->OnCheckProxyConfigSettings();
}
void OnChangeNotification() {
DCHECK_GE(inotify_fd_, 0);
DCHECK(base::MessageLoop::current() == file_loop_);
char event_buf[(sizeof(inotify_event) + NAME_MAX + 1) * 4];
bool kioslaverc_touched = false;
ssize_t r;
while ((r = read(inotify_fd_, event_buf, sizeof(event_buf))) > 0) {
char* event_ptr = event_buf;
while (event_ptr < event_buf + r) {
inotify_event* event = reinterpret_cast<inotify_event*>(event_ptr);
CHECK_LE(event_ptr + sizeof(inotify_event), event_buf + r);
CHECK_LE(event->name + event->len, event_buf + r);
if (!strcmp(event->name, "kioslaverc"))
kioslaverc_touched = true;
event_ptr = event->name + event->len;
}
}
if (!r)
errno = EINVAL;
if (errno != EAGAIN) {
PLOG(WARNING) << "error reading inotify file descriptor";
if (errno == EINVAL) {
LOG(ERROR) << "inotify failure; no longer watching kioslaverc!";
inotify_watcher_.StopWatchingFileDescriptor();
close(inotify_fd_);
inotify_fd_ = -1;
}
}
if (kioslaverc_touched) {
debounce_timer_.Stop();
debounce_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(
kDebounceTimeoutMilliseconds), this,
&SettingGetterImplKDE::OnDebouncedNotification);
}
}
typedef std::map<StringSetting, std::string> string_map_type;
typedef std::map<StringListSetting,
std::vector<std::string> > strings_map_type;
int inotify_fd_;
base::MessagePumpLibevent::FileDescriptorWatcher inotify_watcher_;
ProxyConfigServiceLinux::Delegate* notify_delegate_;
base::OneShotTimer<SettingGetterImplKDE> debounce_timer_;
base::FilePath kde_config_dir_;
bool indirect_manual_;
bool auto_no_pac_;
bool reversed_bypass_list_;
base::Environment* env_var_getter_;
string_map_type string_table_;
strings_map_type strings_table_;
base::MessageLoopForIO* file_loop_;
DISALLOW_COPY_AND_ASSIGN(SettingGetterImplKDE);
};
}
bool ProxyConfigServiceLinux::Delegate::GetProxyFromSettings(
SettingGetter::StringSetting host_key,
ProxyServer* result_server) {
std::string host;
if (!setting_getter_->GetString(host_key, &host) || host.empty()) {
return false;
}
int port = 0;
SettingGetter::IntSetting port_key =
SettingGetter::HostSettingToPortSetting(host_key);
setting_getter_->GetInt(port_key, &port);
if (port != 0) {
host += ":" + base::IntToString(port);
}
ProxyServer::Scheme scheme = (host_key == SettingGetter::PROXY_SOCKS_HOST) ?
ProxyServer::SCHEME_SOCKS5 : ProxyServer::SCHEME_HTTP;
host = FixupProxyHostScheme(scheme, host);
ProxyServer proxy_server = ProxyServer::FromURI(host,
ProxyServer::SCHEME_HTTP);
if (proxy_server.is_valid()) {
*result_server = proxy_server;
return true;
}
return false;
}
bool ProxyConfigServiceLinux::Delegate::GetConfigFromSettings(
ProxyConfig* config) {
std::string mode;
if (!setting_getter_->GetString(SettingGetter::PROXY_MODE, &mode)) {
return false;
}
if (mode == "none") {
return true;
}
if (mode == "auto") {
std::string pac_url_str;
if (setting_getter_->GetString(SettingGetter::PROXY_AUTOCONF_URL,
&pac_url_str)) {
if (!pac_url_str.empty()) {
if (pac_url_str[0] == '/')
pac_url_str = "file://" + pac_url_str;
GURL pac_url(pac_url_str);
if (!pac_url.is_valid())
return false;
config->set_pac_url(pac_url);
return true;
}
}
config->set_auto_detect(true);
return true;
}
if (mode != "manual") {
return false;
}
bool use_http_proxy;
if (setting_getter_->GetBool(SettingGetter::PROXY_USE_HTTP_PROXY,
&use_http_proxy)
&& !use_http_proxy) {
return true;
}
bool same_proxy = false;
setting_getter_->GetBool(SettingGetter::PROXY_USE_SAME_PROXY,
&same_proxy);
ProxyServer proxy_for_http;
ProxyServer proxy_for_https;
ProxyServer proxy_for_ftp;
ProxyServer socks_proxy;
size_t num_proxies_specified = 0;
if (GetProxyFromSettings(SettingGetter::PROXY_HTTP_HOST, &proxy_for_http))
num_proxies_specified++;
if (GetProxyFromSettings(SettingGetter::PROXY_HTTPS_HOST, &proxy_for_https))
num_proxies_specified++;
if (GetProxyFromSettings(SettingGetter::PROXY_FTP_HOST, &proxy_for_ftp))
num_proxies_specified++;
if (GetProxyFromSettings(SettingGetter::PROXY_SOCKS_HOST, &socks_proxy))
num_proxies_specified++;
if (same_proxy) {
if (proxy_for_http.is_valid()) {
config->proxy_rules().type = ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY;
config->proxy_rules().single_proxies.SetSingleProxyServer(proxy_for_http);
}
} else if (num_proxies_specified > 0) {
if (socks_proxy.is_valid() && num_proxies_specified == 1) {
config->proxy_rules().type = ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY;
config->proxy_rules().single_proxies.SetSingleProxyServer(socks_proxy);
} else {
config->proxy_rules().type =
ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME;
config->proxy_rules().proxies_for_http.
SetSingleProxyServer(proxy_for_http);
config->proxy_rules().proxies_for_https.
SetSingleProxyServer(proxy_for_https);
config->proxy_rules().proxies_for_ftp.SetSingleProxyServer(proxy_for_ftp);
config->proxy_rules().fallback_proxies.SetSingleProxyServer(socks_proxy);
}
}
if (config->proxy_rules().empty()) {
return false;
}
bool use_auth = false;
setting_getter_->GetBool(SettingGetter::PROXY_USE_AUTHENTICATION,
&use_auth);
if (use_auth) {
LOG(WARNING) << "Proxy authentication parameters ignored, see bug 16709";
}
std::vector<std::string> ignore_hosts_list;
config->proxy_rules().bypass_rules.Clear();
if (setting_getter_->GetStringList(SettingGetter::PROXY_IGNORE_HOSTS,
&ignore_hosts_list)) {
std::vector<std::string>::const_iterator it(ignore_hosts_list.begin());
for (; it != ignore_hosts_list.end(); ++it) {
if (setting_getter_->MatchHostsUsingSuffixMatching()) {
config->proxy_rules().bypass_rules.
AddRuleFromStringUsingSuffixMatching(*it);
} else {
config->proxy_rules().bypass_rules.AddRuleFromString(*it);
}
}
}
config->proxy_rules().reverse_bypass =
setting_getter_->BypassListIsReversed();
return true;
}
ProxyConfigServiceLinux::Delegate::Delegate(base::Environment* env_var_getter)
: env_var_getter_(env_var_getter) {
switch (base::nix::GetDesktopEnvironment(env_var_getter)) {
case base::nix::DESKTOP_ENVIRONMENT_GNOME:
case base::nix::DESKTOP_ENVIRONMENT_UNITY:
#if defined(USE_GIO)
{
scoped_ptr<SettingGetterImplGSettings> gs_getter(
new SettingGetterImplGSettings());
if (gs_getter->LoadAndCheckVersion(env_var_getter))
setting_getter_.reset(gs_getter.release());
}
#endif
#if defined(USE_GCONF)
if (!setting_getter_.get())
setting_getter_.reset(new SettingGetterImplGConf());
#endif
break;
case base::nix::DESKTOP_ENVIRONMENT_KDE3:
case base::nix::DESKTOP_ENVIRONMENT_KDE4:
setting_getter_.reset(new SettingGetterImplKDE(env_var_getter));
break;
case base::nix::DESKTOP_ENVIRONMENT_XFCE:
case base::nix::DESKTOP_ENVIRONMENT_OTHER:
break;
}
}
ProxyConfigServiceLinux::Delegate::Delegate(
base::Environment* env_var_getter, SettingGetter* setting_getter)
: env_var_getter_(env_var_getter), setting_getter_(setting_getter) {
}
void ProxyConfigServiceLinux::Delegate::SetUpAndFetchInitialConfig(
base::SingleThreadTaskRunner* glib_thread_task_runner,
base::SingleThreadTaskRunner* io_thread_task_runner,
base::MessageLoopForIO* file_loop) {
DCHECK(glib_thread_task_runner->BelongsToCurrentThread());
glib_thread_task_runner_ = glib_thread_task_runner;
io_thread_task_runner_ = io_thread_task_runner;
if (!io_thread_task_runner_.get() || !file_loop)
VLOG(1) << "Monitoring of proxy setting changes is disabled";
bool got_config = false;
if (setting_getter_.get() &&
setting_getter_->Init(glib_thread_task_runner, file_loop) &&
GetConfigFromSettings(&cached_config_)) {
cached_config_.set_id(1);
cached_config_.set_source(setting_getter_->GetConfigSource());
VLOG(1) << "Obtained proxy settings from "
<< ProxyConfigSourceToString(cached_config_.source());
got_config = true;
reference_config_ = cached_config_;
reference_config_.set_id(1);
if (io_thread_task_runner && file_loop) {
scoped_refptr<base::SingleThreadTaskRunner> required_loop =
setting_getter_->GetNotificationTaskRunner();
if (!required_loop.get() || required_loop->BelongsToCurrentThread()) {
SetUpNotifications();
} else {
required_loop->PostTask(FROM_HERE, base::Bind(
&ProxyConfigServiceLinux::Delegate::SetUpNotifications, this));
}
}
}
if (!got_config) {
if (GetConfigFromEnv(&cached_config_)) {
cached_config_.set_source(PROXY_CONFIG_SOURCE_ENV);
cached_config_.set_id(1);
VLOG(1) << "Obtained proxy settings from environment variables";
}
}
}
void ProxyConfigServiceLinux::Delegate::SetUpNotifications() {
scoped_refptr<base::SingleThreadTaskRunner> required_loop =
setting_getter_->GetNotificationTaskRunner();
DCHECK(!required_loop.get() || required_loop->BelongsToCurrentThread());
if (!setting_getter_->SetUpNotifications(this))
LOG(ERROR) << "Unable to set up proxy configuration change notifications";
}
void ProxyConfigServiceLinux::Delegate::AddObserver(Observer* observer) {
observers_.AddObserver(observer);
}
void ProxyConfigServiceLinux::Delegate::RemoveObserver(Observer* observer) {
observers_.RemoveObserver(observer);
}
ProxyConfigService::ConfigAvailability
ProxyConfigServiceLinux::Delegate::GetLatestProxyConfig(
ProxyConfig* config) {
DCHECK(!io_thread_task_runner_.get() ||
io_thread_task_runner_->BelongsToCurrentThread());
if (cached_config_.is_valid()) {
*config = cached_config_;
} else {
*config = ProxyConfig::CreateDirect();
config->set_source(PROXY_CONFIG_SOURCE_SYSTEM_FAILED);
}
return CONFIG_VALID;
}
void ProxyConfigServiceLinux::Delegate::OnCheckProxyConfigSettings() {
scoped_refptr<base::SingleThreadTaskRunner> required_loop =
setting_getter_->GetNotificationTaskRunner();
DCHECK(!required_loop.get() || required_loop->BelongsToCurrentThread());
ProxyConfig new_config;
bool valid = GetConfigFromSettings(&new_config);
if (valid)
new_config.set_id(1);
if (new_config.is_valid() != reference_config_.is_valid() ||
!new_config.Equals(reference_config_)) {
io_thread_task_runner_->PostTask(FROM_HERE, base::Bind(
&ProxyConfigServiceLinux::Delegate::SetNewProxyConfig,
this, new_config));
reference_config_ = new_config;
} else {
VLOG(1) << "Detected no-op change to proxy settings. Doing nothing.";
}
}
void ProxyConfigServiceLinux::Delegate::SetNewProxyConfig(
const ProxyConfig& new_config) {
DCHECK(io_thread_task_runner_->BelongsToCurrentThread());
VLOG(1) << "Proxy configuration changed";
cached_config_ = new_config;
FOR_EACH_OBSERVER(
Observer, observers_,
OnProxyConfigChanged(new_config, ProxyConfigService::CONFIG_VALID));
}
void ProxyConfigServiceLinux::Delegate::PostDestroyTask() {
if (!setting_getter_.get())
return;
scoped_refptr<base::SingleThreadTaskRunner> shutdown_loop =
setting_getter_->GetNotificationTaskRunner();
if (!shutdown_loop.get() || shutdown_loop->BelongsToCurrentThread()) {
OnDestroy();
} else {
shutdown_loop->PostTask(FROM_HERE, base::Bind(
&ProxyConfigServiceLinux::Delegate::OnDestroy, this));
}
}
void ProxyConfigServiceLinux::Delegate::OnDestroy() {
scoped_refptr<base::SingleThreadTaskRunner> shutdown_loop =
setting_getter_->GetNotificationTaskRunner();
DCHECK(!shutdown_loop.get() || shutdown_loop->BelongsToCurrentThread());
setting_getter_->ShutDown();
}
ProxyConfigServiceLinux::ProxyConfigServiceLinux()
: delegate_(new Delegate(base::Environment::Create())) {
}
ProxyConfigServiceLinux::~ProxyConfigServiceLinux() {
delegate_->PostDestroyTask();
}
ProxyConfigServiceLinux::ProxyConfigServiceLinux(
base::Environment* env_var_getter)
: delegate_(new Delegate(env_var_getter)) {
}
ProxyConfigServiceLinux::ProxyConfigServiceLinux(
base::Environment* env_var_getter, SettingGetter* setting_getter)
: delegate_(new Delegate(env_var_getter, setting_getter)) {
}
void ProxyConfigServiceLinux::AddObserver(Observer* observer) {
delegate_->AddObserver(observer);
}
void ProxyConfigServiceLinux::RemoveObserver(Observer* observer) {
delegate_->RemoveObserver(observer);
}
ProxyConfigService::ConfigAvailability
ProxyConfigServiceLinux::GetLatestProxyConfig(ProxyConfig* config) {
return delegate_->GetLatestProxyConfig(config);
}
}