OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/proxy_cros_settings_parser.h" | 5 #include "chrome/browser/chromeos/proxy_cros_settings_parser.h" |
6 | 6 |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/chromeos/ui_proxy_config.h" | 9 #include "chrome/browser/chromeos/ui_proxy_config.h" |
10 #include "chrome/browser/chromeos/ui_proxy_config_service.h" | 10 #include "chrome/browser/chromeos/ui_proxy_config_service.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 if (proxy.server.is_valid()) | 105 if (proxy.server.is_valid()) |
106 host = proxy.server.host_port_pair().host(); | 106 host = proxy.server.host_port_pair().host(); |
107 return CreateProxyServer(host, port, scheme); | 107 return CreateProxyServer(host, port, scheme); |
108 } | 108 } |
109 | 109 |
110 } // namespace | 110 } // namespace |
111 | 111 |
112 namespace proxy_cros_settings_parser { | 112 namespace proxy_cros_settings_parser { |
113 | 113 |
114 bool IsProxyPref(const std::string& path) { | 114 bool IsProxyPref(const std::string& path) { |
115 return StartsWithASCII(path, kProxyPrefsPrefix, true); | 115 return base::StartsWithASCII(path, kProxyPrefsPrefix, true); |
116 } | 116 } |
117 | 117 |
118 void SetProxyPrefValue(const std::string& path, | 118 void SetProxyPrefValue(const std::string& path, |
119 const base::Value* in_value, | 119 const base::Value* in_value, |
120 UIProxyConfigService* config_service) { | 120 UIProxyConfigService* config_service) { |
121 if (!in_value) { | 121 if (!in_value) { |
122 NOTREACHED(); | 122 NOTREACHED(); |
123 return; | 123 return; |
124 } | 124 } |
125 | 125 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 if (in_value->GetAsInteger(&val)) { | 240 if (in_value->GetAsInteger(&val)) { |
241 config.SetProxyForScheme( | 241 config.SetProxyForScheme( |
242 "ftp", CreateProxyServerFromPort( | 242 "ftp", CreateProxyServerFromPort( |
243 val, config.ftp_proxy, net::ProxyServer::SCHEME_HTTP)); | 243 val, config.ftp_proxy, net::ProxyServer::SCHEME_HTTP)); |
244 } | 244 } |
245 } else if (path == kProxySocks) { | 245 } else if (path == kProxySocks) { |
246 std::string val; | 246 std::string val; |
247 if (in_value->GetAsString(&val)) { | 247 if (in_value->GetAsString(&val)) { |
248 config.SetProxyForScheme( | 248 config.SetProxyForScheme( |
249 "socks", CreateProxyServerFromHost( | 249 "socks", CreateProxyServerFromHost( |
250 val, | 250 val, config.socks_proxy, |
251 config.socks_proxy, | 251 base::StartsWithASCII(val, "socks5://", false) |
252 StartsWithASCII(val, "socks5://", false) ? | 252 ? net::ProxyServer::SCHEME_SOCKS5 |
253 net::ProxyServer::SCHEME_SOCKS5 : | 253 : net::ProxyServer::SCHEME_SOCKS4)); |
254 net::ProxyServer::SCHEME_SOCKS4)); | |
255 } | 254 } |
256 } else if (path == kProxySocksPort) { | 255 } else if (path == kProxySocksPort) { |
257 int val; | 256 int val; |
258 if (in_value->GetAsInteger(&val)) { | 257 if (in_value->GetAsInteger(&val)) { |
259 std::string host = config.socks_proxy.server.host_port_pair().host(); | 258 std::string host = config.socks_proxy.server.host_port_pair().host(); |
260 config.SetProxyForScheme( | 259 config.SetProxyForScheme( |
261 "socks", CreateProxyServerFromPort( | 260 "socks", CreateProxyServerFromPort( |
262 val, | 261 val, config.socks_proxy, |
263 config.socks_proxy, | 262 base::StartsWithASCII(host, "socks5://", false) |
264 StartsWithASCII(host, "socks5://", false) ? | 263 ? net::ProxyServer::SCHEME_SOCKS5 |
265 net::ProxyServer::SCHEME_SOCKS5 : | 264 : net::ProxyServer::SCHEME_SOCKS4)); |
266 net::ProxyServer::SCHEME_SOCKS4)); | |
267 } | 265 } |
268 } else if (path == kProxyIgnoreList) { | 266 } else if (path == kProxyIgnoreList) { |
269 net::ProxyBypassRules bypass_rules; | 267 net::ProxyBypassRules bypass_rules; |
270 if (in_value->GetType() == base::Value::TYPE_LIST) { | 268 if (in_value->GetType() == base::Value::TYPE_LIST) { |
271 const base::ListValue* list_value = | 269 const base::ListValue* list_value = |
272 static_cast<const base::ListValue*>(in_value); | 270 static_cast<const base::ListValue*>(in_value); |
273 for (size_t x = 0; x < list_value->GetSize(); x++) { | 271 for (size_t x = 0; x < list_value->GetSize(); x++) { |
274 std::string val; | 272 std::string val; |
275 if (list_value->GetString(x, &val)) | 273 if (list_value->GetString(x, &val)) |
276 bypass_rules.AddRuleFromString(val); | 274 bypass_rules.AddRuleFromString(val); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 } else { | 371 } else { |
374 dict->SetBoolean("disabled", false); | 372 dict->SetBoolean("disabled", false); |
375 } | 373 } |
376 *out_value = dict; | 374 *out_value = dict; |
377 return true; | 375 return true; |
378 } | 376 } |
379 | 377 |
380 } // namespace proxy_cros_settings_parser | 378 } // namespace proxy_cros_settings_parser |
381 | 379 |
382 } // namespace chromeos | 380 } // namespace chromeos |
OLD | NEW |