| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/ui_proxy_config.h" | 5 #include "chrome/browser/chromeos/ui_proxy_config.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "components/proxy_config/proxy_config_dictionary.h" | 9 #include "components/proxy_config/proxy_config_dictionary.h" |
| 10 #include "net/proxy/proxy_config.h" | 10 #include "net/proxy/proxy_config.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 } | 113 } |
| 114 case MODE_SINGLE_PROXY: { | 114 case MODE_SINGLE_PROXY: { |
| 115 std::string spec; | 115 std::string spec; |
| 116 if (single_proxy.server.is_valid()) | 116 if (single_proxy.server.is_valid()) |
| 117 spec = single_proxy.server.ToURI(); | 117 spec = single_proxy.server.ToURI(); |
| 118 return ProxyConfigDictionary::CreateFixedServers( | 118 return ProxyConfigDictionary::CreateFixedServers( |
| 119 spec, bypass_rules.ToString()); | 119 spec, bypass_rules.ToString()); |
| 120 } | 120 } |
| 121 case MODE_PROXY_PER_SCHEME: { | 121 case MODE_PROXY_PER_SCHEME: { |
| 122 std::string spec; | 122 std::string spec; |
| 123 EncodeAndAppendProxyServer("http", http_proxy.server, &spec); | 123 ProxyConfigDictionary::EncodeAndAppendProxyServer( |
| 124 EncodeAndAppendProxyServer("https", https_proxy.server, &spec); | 124 "http", http_proxy.server, &spec); |
| 125 EncodeAndAppendProxyServer("ftp", ftp_proxy.server, &spec); | 125 ProxyConfigDictionary::EncodeAndAppendProxyServer( |
| 126 EncodeAndAppendProxyServer("socks", socks_proxy.server, &spec); | 126 "https", https_proxy.server, &spec); |
| 127 ProxyConfigDictionary::EncodeAndAppendProxyServer("ftp", ftp_proxy.server, |
| 128 &spec); |
| 129 ProxyConfigDictionary::EncodeAndAppendProxyServer( |
| 130 "socks", socks_proxy.server, &spec); |
| 127 return ProxyConfigDictionary::CreateFixedServers( | 131 return ProxyConfigDictionary::CreateFixedServers( |
| 128 spec, bypass_rules.ToString()); | 132 spec, bypass_rules.ToString()); |
| 129 } | 133 } |
| 130 default: | 134 default: |
| 131 break; | 135 break; |
| 132 } | 136 } |
| 133 NOTREACHED() << "Unrecognized proxy config mode for preference"; | 137 NOTREACHED() << "Unrecognized proxy config mode for preference"; |
| 134 return NULL; | 138 return NULL; |
| 135 } | 139 } |
| 136 | 140 |
| 137 UIProxyConfig::ManualProxy* UIProxyConfig::MapSchemeToProxy( | 141 UIProxyConfig::ManualProxy* UIProxyConfig::MapSchemeToProxy( |
| 138 const std::string& scheme) { | 142 const std::string& scheme) { |
| 139 if (scheme == "http") | 143 if (scheme == "http") |
| 140 return &http_proxy; | 144 return &http_proxy; |
| 141 if (scheme == "https") | 145 if (scheme == "https") |
| 142 return &https_proxy; | 146 return &https_proxy; |
| 143 if (scheme == "ftp") | 147 if (scheme == "ftp") |
| 144 return &ftp_proxy; | 148 return &ftp_proxy; |
| 145 if (scheme == "socks") | 149 if (scheme == "socks") |
| 146 return &socks_proxy; | 150 return &socks_proxy; |
| 147 NOTREACHED() << "Invalid scheme: " << scheme; | 151 NOTREACHED() << "Invalid scheme: " << scheme; |
| 148 return NULL; | 152 return NULL; |
| 149 } | 153 } |
| 150 | 154 |
| 151 // static | |
| 152 void UIProxyConfig::EncodeAndAppendProxyServer(const std::string& url_scheme, | |
| 153 const net::ProxyServer& server, | |
| 154 std::string* spec) { | |
| 155 if (!server.is_valid()) | |
| 156 return; | |
| 157 | |
| 158 if (!spec->empty()) | |
| 159 *spec += ';'; | |
| 160 | |
| 161 if (!url_scheme.empty()) { | |
| 162 *spec += url_scheme; | |
| 163 *spec += "="; | |
| 164 } | |
| 165 *spec += server.ToURI(); | |
| 166 } | |
| 167 | |
| 168 } // namespace chromeos | 155 } // namespace chromeos |
| OLD | NEW |