diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-22 18:25:48 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-22 18:25:48 +0000 |
commit | 9e72c20a4fd1eece107e950c95e8153dcf71447b (patch) | |
tree | baaf038280047bfff4b72bc9d4b50e36478ed36c /net/base/mock_host_resolver.cc | |
parent | 8ad9da07e33a811e709462b88405cb53baea336d (diff) | |
download | chromium_src-9e72c20a4fd1eece107e950c95e8153dcf71447b.zip chromium_src-9e72c20a4fd1eece107e950c95e8153dcf71447b.tar.gz chromium_src-9e72c20a4fd1eece107e950c95e8153dcf71447b.tar.bz2 |
Disable IPv6 results for the PAC bindings:
myIpAddress()
dnsResolve()
isResolvable()
This makes us behave more like IE and less like Firefox for scripts where IPv6 addresses are not expected.
BUG=24641
TEST=ProxyResolverJSBindingsTest.DontUseIPv6
Review URL: http://codereview.chromium.org/303022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29788 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/mock_host_resolver.cc')
-rw-r--r-- | net/base/mock_host_resolver.cc | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/net/base/mock_host_resolver.cc b/net/base/mock_host_resolver.cc index c6d31e9..4a723a6 100644 --- a/net/base/mock_host_resolver.cc +++ b/net/base/mock_host_resolver.cc @@ -110,15 +110,18 @@ struct RuleBasedHostResolverProc::Rule { ResolverType resolver_type; std::string host_pattern; + AddressFamily address_family; std::string replacement; int latency_ms; // In milliseconds. Rule(ResolverType resolver_type, const std::string& host_pattern, + AddressFamily address_family, const std::string& replacement, int latency_ms) : resolver_type(resolver_type), host_pattern(host_pattern), + address_family(address_family), replacement(replacement), latency_ms(latency_ms) {} }; @@ -132,14 +135,24 @@ RuleBasedHostResolverProc::~RuleBasedHostResolverProc() { void RuleBasedHostResolverProc::AddRule(const std::string& host_pattern, const std::string& replacement) { + AddRuleForFamily(host_pattern, ADDRESS_FAMILY_UNSPECIFIED, replacement); +} + +void RuleBasedHostResolverProc::AddRuleForFamily( + const std::string& host_pattern, + AddressFamily address_family, + const std::string& replacement) { DCHECK(!replacement.empty()); - Rule rule(Rule::kResolverTypeSystem, host_pattern, replacement, 0); + Rule rule(Rule::kResolverTypeSystem, host_pattern, + address_family, replacement, 0); rules_.push_back(rule); } + void RuleBasedHostResolverProc::AddIPv6Rule(const std::string& host_pattern, const std::string& ipv6_literal) { - Rule rule(Rule::kResolverTypeIPV6Literal, host_pattern, ipv6_literal, 0); + Rule rule(Rule::kResolverTypeIPV6Literal, host_pattern, + ADDRESS_FAMILY_UNSPECIFIED, ipv6_literal, 0); rules_.push_back(rule); } @@ -148,19 +161,22 @@ void RuleBasedHostResolverProc::AddRuleWithLatency( const std::string& replacement, int latency_ms) { DCHECK(!replacement.empty()); - Rule rule(Rule::kResolverTypeSystem, host_pattern, replacement, latency_ms); + Rule rule(Rule::kResolverTypeSystem, host_pattern, + ADDRESS_FAMILY_UNSPECIFIED, replacement, latency_ms); rules_.push_back(rule); } void RuleBasedHostResolverProc::AllowDirectLookup( const std::string& host_pattern) { - Rule rule(Rule::kResolverTypeSystem, host_pattern, "", 0); + Rule rule(Rule::kResolverTypeSystem, host_pattern, + ADDRESS_FAMILY_UNSPECIFIED, "", 0); rules_.push_back(rule); } void RuleBasedHostResolverProc::AddSimulatedFailure( const std::string& host_pattern) { - Rule rule(Rule::kResolverTypeFail, host_pattern, "", 0); + Rule rule(Rule::kResolverTypeFail, host_pattern, + ADDRESS_FAMILY_UNSPECIFIED, "", 0); rules_.push_back(rule); } @@ -169,7 +185,11 @@ int RuleBasedHostResolverProc::Resolve(const std::string& host, AddressList* addrlist) { RuleList::iterator r; for (r = rules_.begin(); r != rules_.end(); ++r) { - if (MatchPattern(host, r->host_pattern)) { + bool matches_address_family = + r->address_family == ADDRESS_FAMILY_UNSPECIFIED || + r->address_family == address_family; + + if (matches_address_family && MatchPattern(host, r->host_pattern)) { if (r->latency_ms != 0) PlatformThread::Sleep(r->latency_ms); |