Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: net/proxy/proxy_config.cc

Issue 12209080: Cleanup: Remove deprecated base::Value methods from net. Use base::Value too. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/dns/dns_config_service.cc ('k') | net/proxy/proxy_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/strings/string_tokenizer.h" 9 #include "base/strings/string_tokenizer.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "net/proxy/proxy_info.h" 11 #include "net/proxy/proxy_info.h"
12 12
13 namespace net { 13 namespace net {
14 14
15 namespace { 15 namespace {
16 16
17 // If |proxy| is valid, sets it in |dict| under the key |name|. 17 // If |proxy| is valid, sets it in |dict| under the key |name|.
18 void AddProxyToValue(const char* name, 18 void AddProxyToValue(const char* name,
19 const ProxyServer& proxy, 19 const ProxyServer& proxy,
20 DictionaryValue* dict) { 20 base::DictionaryValue* dict) {
21 if (proxy.is_valid()) 21 if (proxy.is_valid())
22 dict->SetString(name, proxy.ToURI()); 22 dict->SetString(name, proxy.ToURI());
23 } 23 }
24 24
25 } // namespace 25 } // namespace
26 26
27 ProxyConfig::ProxyRules::ProxyRules() 27 ProxyConfig::ProxyRules::ProxyRules()
28 : reverse_bypass(false), 28 : reverse_bypass(false),
29 type(TYPE_NO_RULES) { 29 type(TYPE_NO_RULES) {
30 } 30 }
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 196
197 bool ProxyConfig::HasAutomaticSettings() const { 197 bool ProxyConfig::HasAutomaticSettings() const {
198 return auto_detect_ || has_pac_url(); 198 return auto_detect_ || has_pac_url();
199 } 199 }
200 200
201 void ProxyConfig::ClearAutomaticSettings() { 201 void ProxyConfig::ClearAutomaticSettings() {
202 auto_detect_ = false; 202 auto_detect_ = false;
203 pac_url_ = GURL(); 203 pac_url_ = GURL();
204 } 204 }
205 205
206 Value* ProxyConfig::ToValue() const { 206 base::Value* ProxyConfig::ToValue() const {
207 DictionaryValue* dict = new DictionaryValue(); 207 base::DictionaryValue* dict = new base::DictionaryValue();
208 208
209 // Output the automatic settings. 209 // Output the automatic settings.
210 if (auto_detect_) 210 if (auto_detect_)
211 dict->SetBoolean("auto_detect", auto_detect_); 211 dict->SetBoolean("auto_detect", auto_detect_);
212 if (has_pac_url()) { 212 if (has_pac_url()) {
213 dict->SetString("pac_url", pac_url_.possibly_invalid_spec()); 213 dict->SetString("pac_url", pac_url_.possibly_invalid_spec());
214 if (pac_mandatory_) 214 if (pac_mandatory_)
215 dict->SetBoolean("pac_mandatory", pac_mandatory_); 215 dict->SetBoolean("pac_mandatory", pac_mandatory_);
216 } 216 }
217 217
218 // Output the manual settings. 218 // Output the manual settings.
219 if (proxy_rules_.type != ProxyRules::TYPE_NO_RULES) { 219 if (proxy_rules_.type != ProxyRules::TYPE_NO_RULES) {
220 switch (proxy_rules_.type) { 220 switch (proxy_rules_.type) {
221 case ProxyRules::TYPE_SINGLE_PROXY: 221 case ProxyRules::TYPE_SINGLE_PROXY:
222 AddProxyToValue("single_proxy", proxy_rules_.single_proxy, dict); 222 AddProxyToValue("single_proxy", proxy_rules_.single_proxy, dict);
223 break; 223 break;
224 case ProxyRules::TYPE_PROXY_PER_SCHEME: { 224 case ProxyRules::TYPE_PROXY_PER_SCHEME: {
225 DictionaryValue* dict2 = new DictionaryValue(); 225 base::DictionaryValue* dict2 = new base::DictionaryValue();
226 AddProxyToValue("http", proxy_rules_.proxy_for_http, dict2); 226 AddProxyToValue("http", proxy_rules_.proxy_for_http, dict2);
227 AddProxyToValue("https", proxy_rules_.proxy_for_https, dict2); 227 AddProxyToValue("https", proxy_rules_.proxy_for_https, dict2);
228 AddProxyToValue("ftp", proxy_rules_.proxy_for_ftp, dict2); 228 AddProxyToValue("ftp", proxy_rules_.proxy_for_ftp, dict2);
229 AddProxyToValue("fallback", proxy_rules_.fallback_proxy, dict2); 229 AddProxyToValue("fallback", proxy_rules_.fallback_proxy, dict2);
230 dict->Set("proxy_per_scheme", dict2); 230 dict->Set("proxy_per_scheme", dict2);
231 break; 231 break;
232 } 232 }
233 default: 233 default:
234 NOTREACHED(); 234 NOTREACHED();
235 } 235 }
236 236
237 // Output the bypass rules. 237 // Output the bypass rules.
238 const ProxyBypassRules& bypass = proxy_rules_.bypass_rules; 238 const ProxyBypassRules& bypass = proxy_rules_.bypass_rules;
239 if (!bypass.rules().empty()) { 239 if (!bypass.rules().empty()) {
240 if (proxy_rules_.reverse_bypass) 240 if (proxy_rules_.reverse_bypass)
241 dict->SetBoolean("reverse_bypass", true); 241 dict->SetBoolean("reverse_bypass", true);
242 242
243 ListValue* list = new ListValue(); 243 base::ListValue* list = new base::ListValue();
244 244
245 for (ProxyBypassRules::RuleList::const_iterator it = 245 for (ProxyBypassRules::RuleList::const_iterator it =
246 bypass.rules().begin(); 246 bypass.rules().begin();
247 it != bypass.rules().end(); ++it) { 247 it != bypass.rules().end(); ++it) {
248 list->Append(Value::CreateStringValue((*it)->ToString())); 248 list->Append(new base::StringValue((*it)->ToString()));
249 } 249 }
250 250
251 dict->Set("bypass_list", list); 251 dict->Set("bypass_list", list);
252 } 252 }
253 } 253 }
254 254
255 // Output the source. 255 // Output the source.
256 dict->SetString("source", ProxyConfigSourceToString(source_)); 256 dict->SetString("source", ProxyConfigSourceToString(source_));
257 257
258 return dict; 258 return dict;
259 } 259 }
260 260
261 } // namespace net 261 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/dns_config_service.cc ('k') | net/proxy/proxy_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698