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

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

Issue 6871019: Enable (optional) blocking of webrequests in case a PAC script cannot be fetched or is invalid. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 9 years, 8 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_tokenizer.h" 8 #include "base/string_tokenizer.h"
9 #include "base/string_util.h" 9 #include "base/string_util.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"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 DCHECK_EQ(TYPE_PROXY_PER_SCHEME, type); 151 DCHECK_EQ(TYPE_PROXY_PER_SCHEME, type);
152 if (scheme == "http") 152 if (scheme == "http")
153 return &proxy_for_http; 153 return &proxy_for_http;
154 if (scheme == "https") 154 if (scheme == "https")
155 return &proxy_for_https; 155 return &proxy_for_https;
156 if (scheme == "ftp") 156 if (scheme == "ftp")
157 return &proxy_for_ftp; 157 return &proxy_for_ftp;
158 return NULL; // No mapping for this scheme. 158 return NULL; // No mapping for this scheme.
159 } 159 }
160 160
161 ProxyConfig::ProxyConfig() : auto_detect_(false), id_(INVALID_ID) { 161 ProxyConfig::ProxyConfig()
162 : auto_detect_(false), pac_mandatory_(false),
163 block_everything_(false), id_(INVALID_ID) {
162 } 164 }
163 165
164 ProxyConfig::ProxyConfig(const ProxyConfig& config) 166 ProxyConfig::ProxyConfig(const ProxyConfig& config)
165 : auto_detect_(config.auto_detect_), 167 : auto_detect_(config.auto_detect_),
166 pac_url_(config.pac_url_), 168 pac_url_(config.pac_url_),
169 pac_mandatory_(config.pac_mandatory_),
167 proxy_rules_(config.proxy_rules_), 170 proxy_rules_(config.proxy_rules_),
171 block_everything_(config.block_everything_),
168 id_(config.id_) { 172 id_(config.id_) {
169 } 173 }
170 174
171 ProxyConfig::~ProxyConfig() { 175 ProxyConfig::~ProxyConfig() {
172 } 176 }
173 177
174 ProxyConfig& ProxyConfig::operator=(const ProxyConfig& config) { 178 ProxyConfig& ProxyConfig::operator=(const ProxyConfig& config) {
175 auto_detect_ = config.auto_detect_; 179 auto_detect_ = config.auto_detect_;
176 pac_url_ = config.pac_url_; 180 pac_url_ = config.pac_url_;
181 pac_mandatory_ = config.pac_mandatory_;
177 proxy_rules_ = config.proxy_rules_; 182 proxy_rules_ = config.proxy_rules_;
183 block_everything_ = config.block_everything_;
178 id_ = config.id_; 184 id_ = config.id_;
179 return *this; 185 return *this;
180 } 186 }
181 187
182 bool ProxyConfig::Equals(const ProxyConfig& other) const { 188 bool ProxyConfig::Equals(const ProxyConfig& other) const {
183 // The two configs can have different IDs. We are just interested in if they 189 // The two configs can have different IDs. We are just interested in if they
184 // have the same settings. 190 // have the same settings.
185 return auto_detect_ == other.auto_detect_ && 191 return auto_detect_ == other.auto_detect_ &&
186 pac_url_ == other.pac_url_ && 192 pac_url_ == other.pac_url_ &&
187 proxy_rules_.Equals(other.proxy_rules()); 193 pac_mandatory_ == other.pac_mandatory_ &&
194 proxy_rules_.Equals(other.proxy_rules()) &&
195 block_everything_ == other.block_everything_;
188 } 196 }
189 197
190 bool ProxyConfig::HasAutomaticSettings() const { 198 bool ProxyConfig::HasAutomaticSettings() const {
191 return auto_detect_ || has_pac_url(); 199 return auto_detect_ || has_pac_url();
192 } 200 }
193 201
194 void ProxyConfig::ClearAutomaticSettings() { 202 void ProxyConfig::ClearAutomaticSettings() {
195 auto_detect_ = false; 203 auto_detect_ = false;
196 pac_url_ = GURL(); 204 pac_url_ = GURL();
197 } 205 }
198 206
199 Value* ProxyConfig::ToValue() const { 207 Value* ProxyConfig::ToValue() const {
200 DictionaryValue* dict = new DictionaryValue(); 208 DictionaryValue* dict = new DictionaryValue();
201 209
202 // Output the automatic settings. 210 // Output the automatic settings.
203 if (auto_detect_) 211 if (auto_detect_)
204 dict->SetBoolean("auto_detect", auto_detect_); 212 dict->SetBoolean("auto_detect", auto_detect_);
205 if (has_pac_url()) 213 if (has_pac_url())
206 dict->SetString("pac_url", pac_url_.possibly_invalid_spec()); 214 dict->SetString("pac_url", pac_url_.possibly_invalid_spec());
eroman 2011/04/26 21:47:17 The new properties should be mirrored here as well
battre 2011/04/27 17:02:58 Done.
207 215
208 // Output the manual settings. 216 // Output the manual settings.
209 if (proxy_rules_.type != ProxyRules::TYPE_NO_RULES) { 217 if (proxy_rules_.type != ProxyRules::TYPE_NO_RULES) {
210 switch (proxy_rules_.type) { 218 switch (proxy_rules_.type) {
211 case ProxyRules::TYPE_SINGLE_PROXY: 219 case ProxyRules::TYPE_SINGLE_PROXY:
212 AddProxyToValue("single_proxy", proxy_rules_.single_proxy, dict); 220 AddProxyToValue("single_proxy", proxy_rules_.single_proxy, dict);
213 break; 221 break;
214 case ProxyRules::TYPE_PROXY_PER_SCHEME: { 222 case ProxyRules::TYPE_PROXY_PER_SCHEME: {
215 DictionaryValue* dict2 = new DictionaryValue(); 223 DictionaryValue* dict2 = new DictionaryValue();
216 AddProxyToValue("http", proxy_rules_.proxy_for_http, dict2); 224 AddProxyToValue("http", proxy_rules_.proxy_for_http, dict2);
(...skipping 22 matching lines...) Expand all
239 } 247 }
240 248
241 dict->Set("bypass_list", list); 249 dict->Set("bypass_list", list);
242 } 250 }
243 } 251 }
244 252
245 return dict; 253 return dict;
246 } 254 }
247 255
248 } // namespace net 256 } // namespace net
249
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698