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/intranet_redirect_detector.h" | 5 #include "chrome/browser/intranet_redirect_detector.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/prefs/pref_registry_simple.h" | 9 #include "base/prefs/pref_registry_simple.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 114 } |
115 redirect_origin_ = GURL(); | 115 redirect_origin_ = GURL(); |
116 } else { | 116 } else { |
117 DCHECK(source->GetURL().is_valid()); | 117 DCHECK(source->GetURL().is_valid()); |
118 GURL origin(source->GetURL().GetOrigin()); | 118 GURL origin(source->GetURL().GetOrigin()); |
119 if (resulting_origins_.empty()) { | 119 if (resulting_origins_.empty()) { |
120 resulting_origins_.push_back(origin); | 120 resulting_origins_.push_back(origin); |
121 return; | 121 return; |
122 } | 122 } |
123 if (net::RegistryControlledDomainService::SameDomainOrHost( | 123 if (net::RegistryControlledDomainService::SameDomainOrHost( |
124 resulting_origins_.front(), origin)) { | 124 resulting_origins_.front(), |
| 125 origin, |
| 126 net::RCDS::EXCLUDE_PRIVATE_REGISTRIES)) { |
125 redirect_origin_ = origin; | 127 redirect_origin_ = origin; |
126 if (!fetchers_.empty()) { | 128 if (!fetchers_.empty()) { |
127 // Cancel remaining fetch, we don't need it. | 129 // Cancel remaining fetch, we don't need it. |
128 DCHECK(fetchers_.size() == 1); | 130 DCHECK(fetchers_.size() == 1); |
129 delete (*fetchers_.begin()); | 131 delete (*fetchers_.begin()); |
130 fetchers_.clear(); | 132 fetchers_.clear(); |
131 } | 133 } |
132 } | 134 } |
133 if (resulting_origins_.size() == 1) { | 135 if (resulting_origins_.size() == 1) { |
134 resulting_origins_.push_back(origin); | 136 resulting_origins_.push_back(origin); |
135 return; | 137 return; |
136 } | 138 } |
137 DCHECK(resulting_origins_.size() == 2); | 139 DCHECK(resulting_origins_.size() == 2); |
138 redirect_origin_ = net::RegistryControlledDomainService::SameDomainOrHost( | 140 redirect_origin_ = net::RegistryControlledDomainService::SameDomainOrHost( |
139 resulting_origins_.back(), origin) ? origin : GURL(); | 141 resulting_origins_.back(), |
| 142 origin, |
| 143 net::RCDS::EXCLUDE_PRIVATE_REGISTRIES) ? origin : GURL(); |
140 } | 144 } |
141 | 145 |
142 g_browser_process->local_state()->SetString( | 146 g_browser_process->local_state()->SetString( |
143 prefs::kLastKnownIntranetRedirectOrigin, redirect_origin_.is_valid() ? | 147 prefs::kLastKnownIntranetRedirectOrigin, redirect_origin_.is_valid() ? |
144 redirect_origin_.spec() : std::string()); | 148 redirect_origin_.spec() : std::string()); |
145 } | 149 } |
146 | 150 |
147 void IntranetRedirectDetector::OnIPAddressChanged() { | 151 void IntranetRedirectDetector::OnIPAddressChanged() { |
148 // If a request is already scheduled, do not scheduled yet another one. | 152 // If a request is already scheduled, do not scheduled yet another one. |
149 if (in_sleep_) | 153 if (in_sleep_) |
(...skipping 24 matching lines...) Expand all Loading... |
174 // the same thread. So just use the heuristic that any all-lowercase a-z | 178 // the same thread. So just use the heuristic that any all-lowercase a-z |
175 // hostname with the right number of characters is likely from the detector | 179 // hostname with the right number of characters is likely from the detector |
176 // (and thus should be blocked). | 180 // (and thus should be blocked). |
177 return ((host.length() == IntranetRedirectDetector::kNumCharsInHostnames) && | 181 return ((host.length() == IntranetRedirectDetector::kNumCharsInHostnames) && |
178 (host.find_first_not_of("abcdefghijklmnopqrstuvwxyz") == | 182 (host.find_first_not_of("abcdefghijklmnopqrstuvwxyz") == |
179 std::string::npos)) ? | 183 std::string::npos)) ? |
180 net::ERR_NAME_NOT_RESOLVED : | 184 net::ERR_NAME_NOT_RESOLVED : |
181 ResolveUsingPrevious(host, address_family, host_resolver_flags, addrlist, | 185 ResolveUsingPrevious(host, address_family, host_resolver_flags, addrlist, |
182 os_error); | 186 os_error); |
183 } | 187 } |
OLD | NEW |