Commit 4056e7f8 authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

Support proxy-server and proxy-bypass-list flags in WebView with NS

Network service did not have support for these flags in webview. This
matches the functionality from aw_url_request_context_getter.cc.

This was causing some webview telemetry tests to fail, see bug for more
details.

Bug: 987623
Change-Id: I0ae492cd8040e6d6ced7ca505a8f48ed82a0f1f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1721451Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681922}
parent c6b18ebc
......@@ -15,6 +15,9 @@
namespace android_webview {
namespace {
const char kProxyServerSwitch[] = "proxy-server";
const char kProxyBypassListSwitch[] = "proxy-bypass-list";
base::LazyInstance<AwProxyConfigMonitor>::Leaky g_instance;
} // namespace
......@@ -36,16 +39,31 @@ AwProxyConfigMonitor* AwProxyConfigMonitor::GetInstance() {
void AwProxyConfigMonitor::AddProxyToNetworkContextParams(
network::mojom::NetworkContextParamsPtr& network_context_params) {
network::mojom::ProxyConfigClientPtr proxy_config_client;
network_context_params->proxy_config_client_request =
mojo::MakeRequest(&proxy_config_client);
proxy_config_client_set_.AddPtr(std::move(proxy_config_client));
net::ProxyConfigWithAnnotation proxy_config;
net::ProxyConfigService::ConfigAvailability availability =
proxy_config_service_android_->GetLatestProxyConfig(&proxy_config);
if (availability == net::ProxyConfigService::CONFIG_VALID) {
network_context_params->initial_proxy_config = proxy_config;
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(kProxyServerSwitch)) {
std::string proxy = command_line.GetSwitchValueASCII(kProxyServerSwitch);
net::ProxyConfig proxy_config;
proxy_config.proxy_rules().ParseFromString(proxy);
if (command_line.HasSwitch(kProxyBypassListSwitch)) {
std::string bypass_list =
command_line.GetSwitchValueASCII(kProxyBypassListSwitch);
proxy_config.proxy_rules().bypass_rules.ParseFromString(bypass_list);
}
network_context_params->initial_proxy_config =
net::ProxyConfigWithAnnotation(proxy_config, NO_TRAFFIC_ANNOTATION_YET);
} else {
network::mojom::ProxyConfigClientPtr proxy_config_client;
network_context_params->proxy_config_client_request =
mojo::MakeRequest(&proxy_config_client);
proxy_config_client_set_.AddPtr(std::move(proxy_config_client));
net::ProxyConfigWithAnnotation proxy_config;
net::ProxyConfigService::ConfigAvailability availability =
proxy_config_service_android_->GetLatestProxyConfig(&proxy_config);
if (availability == net::ProxyConfigService::CONFIG_VALID)
network_context_params->initial_proxy_config = proxy_config;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment