virtual CefRefPtr<CefProxyHandler> GetProxyHandler() {
return NULL;
}
class CefProxyHandler : public virtual CefBaseRefCounted {
public:
///
// Called to retrieve proxy information for the specified |url|.
///
/*--cef()--*/
virtual void GetProxyForUrl(const CefString& url,
CefProxyInfo& proxy_info) {}
};
#include "net/proxy_resolution/proxy_config_service_win.h"
#include "net/proxy_resolution/proxy_resolver_factory.h"
#include "net/proxy_resolution/proxy_resolver.h"
...
namespace {
class ProxyConfigServiceNull : public net::ProxyConfigService {
public:
ProxyConfigServiceNull() {}
virtual void AddObserver(Observer* observer) override {}
virtual void RemoveObserver(Observer* observer) override {}
virtual ProxyConfigService::ConfigAvailability
GetLatestProxyConfig(net::ProxyConfigWithAnnotation* config) override
{ return ProxyConfigService::CONFIG_VALID; }
virtual void OnLazyPoll() override {}
};
// An implementation of |HttpUserAgentSettings| that provides a static
class CefProxyResolver
: public net::ProxyResolver {
public:
explicit CefProxyResolver(CefRefPtr<CefProxyHandler> handler)
: handler_(handler) {}
virtual ~CefProxyResolver() {}
// HTTP Accept-Language header value and uses |content::GetUserAgent|
virtual int GetProxyForURL(const GURL& url,
net::ProxyInfo* results,
const net::CompletionCallback& callback,
std::unique_ptr<Request>* request,
const net::NetLogWithSource& net_log) override {
CefProxyInfo proxy_info;
handler_->GetProxyForUrl(url.spec(), proxy_info);
if (proxy_info.IsDirect())
results->UseDirect();
else if (proxy_info.IsNamedProxy())
results->UseNamedProxy(proxy_info.ProxyList());
else if (proxy_info.IsPacString())
results->UsePacString(proxy_info.ProxyList());
// to provide the HTTP User-Agent header value.
return net::OK;
}
protected:
CefRefPtr<CefProxyHandler> handler_;
};
class CefProxyResolverFactory
: public net::ProxyResolverFactory {
public:
explicit CefProxyResolverFactory(CefRefPtr<CefProxyHandler> handler)
: net::ProxyResolverFactory(false)
, handler_(handler) {
}
virtual ~CefProxyResolverFactory() {
}
// Creates a new ProxyResolver. The caller is responsible for freeing this
// object.
virtual int CreateProxyResolver(
const scoped_refptr<net::PacFileData>& pac_script,
std::unique_ptr<net::ProxyResolver>* resolver,
const net::CompletionCallback& callback,
std::unique_ptr<Request>* request) override {
resolver->reset(new CefProxyResolver(handler_));
return net::OK;
}
private:
CefRefPtr<CefProxyHandler> handler_;
DISALLOW_COPY_AND_ASSIGN(CefProxyResolverFactory);
};
}; // namespace
net::URLRequestContext* CefURLRequestContextGetterImpl::GetURLRequestContext() {
CEF_REQUIRE_IOT();
if (!io_state_->url_request_context_.get()) {
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
...
io_state_->storage_->set_ct_policy_enforcer(std::move(ct_policy_enforcer));
// and here:
bool fCustomProxyHandler = false;
if(app.get()) {
CefRefPtr<CefProxyHandler> handler = app->GetProxyHandler();
if(handler.get()) {
// Force auto-detect so the client resolver will be called.
net::ProxyConfigServiceWin::set_force_auto_detect(true);
// The client will provide proxy resolution.
std::unique_ptr<net::ProxyResolutionService> custom_proxy_service(
new net::ProxyResolutionService(
net::ProxyResolutionService::CreateSystemProxyConfigService(
io_state_->io_task_runner_),
base::WrapUnique(
new CefProxyResolverFactory(handler)),
nullptr));
io_state_->storage_->set_proxy_resolution_service(
std::move(custom_proxy_service));
fCustomProxyHandler = true;
}
}
if(!fCustomProxyHandler) {
// custom proxy resolution not provided
std::unique_ptr<net::ProxyResolutionService> system_proxy_service =
CreateProxyResolutionService(
io_state_->net_log_,
io_state_->url_request_context_.get(),
io_state_->url_request_context_->network_delegate(),
std::move(io_state_->proxy_resolver_factory_),
std::move(io_state_->proxy_config_service_), *command_line,
quick_check_enabled_.GetValue(),
pac_https_url_stripping_enabled_.GetValue());
io_state_->storage_->set_proxy_resolution_service(
std::move(system_proxy_service));
}
...
}
--proxy-bypass-list
Specifies a list of hosts for whom we bypass proxy settings and use direct connections. Ignored unless --proxy-server is also specified. This is a comma-separated list of bypass rules. See: "net/proxy/proxy_bypass_rules.h" for the format of these rules. ↪
Users browsing this forum: No registered users and 32 guests