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 "net/proxy/proxy_config.h" | 5 #include "net/proxy/proxy_config.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_tokenizer.h" |
8 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
9 #include "base/strings/string_tokenizer.h" | |
10 #include "base/values.h" | 12 #include "base/values.h" |
11 #include "net/proxy/proxy_info.h" | 13 #include "net/proxy/proxy_info.h" |
12 | 14 |
13 namespace net { | 15 namespace net { |
14 | 16 |
15 namespace { | 17 namespace { |
16 | 18 |
17 // If |proxies| is non-empty, sets it in |dict| under the key |name|. | 19 // If |proxies| is non-empty, sets it in |dict| under the key |name|. |
18 void AddProxyListToValue(const char* name, | 20 void AddProxyListToValue(const char* name, |
19 const ProxyList& proxies, | 21 const ProxyList& proxies, |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 dict.get()); | 253 dict.get()); |
252 break; | 254 break; |
253 case ProxyRules::TYPE_PROXY_PER_SCHEME: { | 255 case ProxyRules::TYPE_PROXY_PER_SCHEME: { |
254 scoped_ptr<base::DictionaryValue> dict2(new base::DictionaryValue()); | 256 scoped_ptr<base::DictionaryValue> dict2(new base::DictionaryValue()); |
255 AddProxyListToValue("http", proxy_rules_.proxies_for_http, dict2.get()); | 257 AddProxyListToValue("http", proxy_rules_.proxies_for_http, dict2.get()); |
256 AddProxyListToValue("https", proxy_rules_.proxies_for_https, | 258 AddProxyListToValue("https", proxy_rules_.proxies_for_https, |
257 dict2.get()); | 259 dict2.get()); |
258 AddProxyListToValue("ftp", proxy_rules_.proxies_for_ftp, dict2.get()); | 260 AddProxyListToValue("ftp", proxy_rules_.proxies_for_ftp, dict2.get()); |
259 AddProxyListToValue("fallback", proxy_rules_.fallback_proxies, | 261 AddProxyListToValue("fallback", proxy_rules_.fallback_proxies, |
260 dict2.get()); | 262 dict2.get()); |
261 dict->Set("proxy_per_scheme", dict2.Pass()); | 263 dict->Set("proxy_per_scheme", std::move(dict2)); |
262 break; | 264 break; |
263 } | 265 } |
264 default: | 266 default: |
265 NOTREACHED(); | 267 NOTREACHED(); |
266 } | 268 } |
267 | 269 |
268 // Output the bypass rules. | 270 // Output the bypass rules. |
269 const ProxyBypassRules& bypass = proxy_rules_.bypass_rules; | 271 const ProxyBypassRules& bypass = proxy_rules_.bypass_rules; |
270 if (!bypass.rules().empty()) { | 272 if (!bypass.rules().empty()) { |
271 if (proxy_rules_.reverse_bypass) | 273 if (proxy_rules_.reverse_bypass) |
272 dict->SetBoolean("reverse_bypass", true); | 274 dict->SetBoolean("reverse_bypass", true); |
273 | 275 |
274 base::ListValue* list = new base::ListValue(); | 276 base::ListValue* list = new base::ListValue(); |
275 | 277 |
276 for (ProxyBypassRules::RuleList::const_iterator it = | 278 for (ProxyBypassRules::RuleList::const_iterator it = |
277 bypass.rules().begin(); | 279 bypass.rules().begin(); |
278 it != bypass.rules().end(); ++it) { | 280 it != bypass.rules().end(); ++it) { |
279 list->Append(new base::StringValue((*it)->ToString())); | 281 list->Append(new base::StringValue((*it)->ToString())); |
280 } | 282 } |
281 | 283 |
282 dict->Set("bypass_list", list); | 284 dict->Set("bypass_list", list); |
283 } | 285 } |
284 } | 286 } |
285 | 287 |
286 // Output the source. | 288 // Output the source. |
287 dict->SetString("source", ProxyConfigSourceToString(source_)); | 289 dict->SetString("source", ProxyConfigSourceToString(source_)); |
288 | 290 |
289 return dict.Pass(); | 291 return dict; |
290 } | 292 } |
291 | 293 |
292 } // namespace net | 294 } // namespace net |
OLD | NEW |