summaryrefslogtreecommitdiffstats
path: root/net/proxy/proxy_config_service_common_unittest.cc
blob: 06f1c6a342b917d73630fd32ae365865a24a0c0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/proxy/proxy_config_service_common_unittest.h"

#include <string>
#include <vector>

#include "net/proxy/proxy_config.h"

namespace net {

ProxyConfig::ProxyRules MakeProxyRules(
    ProxyConfig::ProxyRules::Type type,
    const char* single_proxy,
    const char* proxy_for_http,
    const char* proxy_for_https,
    const char* proxy_for_ftp) {
  ProxyConfig::ProxyRules rules;
  rules.type = type;
  rules.single_proxy = ProxyServer::FromURI(single_proxy);
  rules.proxy_for_http = ProxyServer::FromURI(proxy_for_http);
  rules.proxy_for_https = ProxyServer::FromURI(proxy_for_https);
  rules.proxy_for_ftp = ProxyServer::FromURI(proxy_for_ftp);
  return rules;
}

ProxyConfig::ProxyRules MakeSingleProxyRules(const char* single_proxy) {
  return MakeProxyRules(ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY,
                        single_proxy, "", "", "");
}

ProxyConfig::ProxyRules MakeProxyPerSchemeRules(
    const char* proxy_http,
    const char* proxy_https,
    const char* proxy_ftp) {
  return MakeProxyRules(ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME,
                        "", proxy_http, proxy_https, proxy_ftp);
}

std::string FlattenProxyBypass(const BypassList& proxy_bypass) {
  std::string flattened_proxy_bypass;
  for (BypassList::const_iterator it = proxy_bypass.begin();
       it != proxy_bypass.end(); ++it) {
    flattened_proxy_bypass += *it + "\n";
  }
  return flattened_proxy_bypass;
}

}  // namespace net