OLD | NEW |
1 // Copyright (c) 2011 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 "chrome/browser/intranet_redirect_detector.h" | 5 #include "chrome/browser/intranet_redirect_detector.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // origin to that; otherwise we set it to nothing. | 104 // origin to that; otherwise we set it to nothing. |
105 if (!source->GetStatus().is_success() || (source->GetResponseCode() != 200)) { | 105 if (!source->GetStatus().is_success() || (source->GetResponseCode() != 200)) { |
106 if ((resulting_origins_.empty()) || | 106 if ((resulting_origins_.empty()) || |
107 ((resulting_origins_.size() == 1) && | 107 ((resulting_origins_.size() == 1) && |
108 resulting_origins_.front().is_valid())) { | 108 resulting_origins_.front().is_valid())) { |
109 resulting_origins_.push_back(GURL()); | 109 resulting_origins_.push_back(GURL()); |
110 return; | 110 return; |
111 } | 111 } |
112 redirect_origin_ = GURL(); | 112 redirect_origin_ = GURL(); |
113 } else { | 113 } else { |
114 DCHECK(source->GetUrl().is_valid()); | 114 DCHECK(source->GetURL().is_valid()); |
115 GURL origin(source->GetUrl().GetOrigin()); | 115 GURL origin(source->GetURL().GetOrigin()); |
116 if (resulting_origins_.empty()) { | 116 if (resulting_origins_.empty()) { |
117 resulting_origins_.push_back(origin); | 117 resulting_origins_.push_back(origin); |
118 return; | 118 return; |
119 } | 119 } |
120 if (net::RegistryControlledDomainService::SameDomainOrHost( | 120 if (net::RegistryControlledDomainService::SameDomainOrHost( |
121 resulting_origins_.front(), origin)) { | 121 resulting_origins_.front(), origin)) { |
122 redirect_origin_ = origin; | 122 redirect_origin_ = origin; |
123 if (!fetchers_.empty()) { | 123 if (!fetchers_.empty()) { |
124 // Cancel remaining fetch, we don't need it. | 124 // Cancel remaining fetch, we don't need it. |
125 DCHECK(fetchers_.size() == 1); | 125 DCHECK(fetchers_.size() == 1); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 // the same thread. So just use the heuristic that any all-lowercase a-z | 171 // the same thread. So just use the heuristic that any all-lowercase a-z |
172 // hostname with the right number of characters is likely from the detector | 172 // hostname with the right number of characters is likely from the detector |
173 // (and thus should be blocked). | 173 // (and thus should be blocked). |
174 return ((host.length() == IntranetRedirectDetector::kNumCharsInHostnames) && | 174 return ((host.length() == IntranetRedirectDetector::kNumCharsInHostnames) && |
175 (host.find_first_not_of("abcdefghijklmnopqrstuvwxyz") == | 175 (host.find_first_not_of("abcdefghijklmnopqrstuvwxyz") == |
176 std::string::npos)) ? | 176 std::string::npos)) ? |
177 net::ERR_NAME_NOT_RESOLVED : | 177 net::ERR_NAME_NOT_RESOLVED : |
178 ResolveUsingPrevious(host, address_family, host_resolver_flags, addrlist, | 178 ResolveUsingPrevious(host, address_family, host_resolver_flags, addrlist, |
179 os_error); | 179 os_error); |
180 } | 180 } |
OLD | NEW |