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

Side by Side Diff: chrome/browser/intranet_redirect_detector.cc

Issue 1593015: HostResolver supports optional CNAME lookups. (Closed)
Patch Set: Addressing wtc's nits. Created 10 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/rand_util.h" 7 #include "base/rand_util.h"
8 #include "base/stl_util-inl.h" 8 #include "base/stl_util-inl.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 DCHECK_EQ(NotificationType::DEFAULT_REQUEST_CONTEXT_AVAILABLE, type.value); 149 DCHECK_EQ(NotificationType::DEFAULT_REQUEST_CONTEXT_AVAILABLE, type.value);
150 request_context_available_ = true; 150 request_context_available_ = true;
151 StartFetchesIfPossible(); 151 StartFetchesIfPossible();
152 } 152 }
153 153
154 IntranetRedirectHostResolverProc::IntranetRedirectHostResolverProc( 154 IntranetRedirectHostResolverProc::IntranetRedirectHostResolverProc(
155 net::HostResolverProc* previous) 155 net::HostResolverProc* previous)
156 : net::HostResolverProc(previous) { 156 : net::HostResolverProc(previous) {
157 } 157 }
158 158
159 int IntranetRedirectHostResolverProc::Resolve(const std::string& host, 159 int IntranetRedirectHostResolverProc::Resolve(
160 net::AddressFamily address_family, 160 const std::string& host,
161 net::AddressList* addrlist) { 161 net::AddressFamily address_family,
162 net::HostResolverFlags host_resolver_flags,
163 net::AddressList* addrlist) {
162 // We'd love to just ask the IntranetRedirectDetector, but we may not be on 164 // We'd love to just ask the IntranetRedirectDetector, but we may not be on
163 // the same thread. So just use the heuristic that any all-lowercase a-z 165 // the same thread. So just use the heuristic that any all-lowercase a-z
164 // hostname with the right number of characters is likely from the detector 166 // hostname with the right number of characters is likely from the detector
165 // (and thus should be blocked). 167 // (and thus should be blocked).
166 return ((host.length() == IntranetRedirectDetector::kNumCharsInHostnames) && 168 return ((host.length() == IntranetRedirectDetector::kNumCharsInHostnames) &&
167 (host.find_first_not_of("abcdefghijklmnopqrstuvwxyz") == 169 (host.find_first_not_of("abcdefghijklmnopqrstuvwxyz") ==
168 std::string::npos)) ? 170 std::string::npos)) ?
169 net::ERR_NAME_NOT_RESOLVED : 171 net::ERR_NAME_NOT_RESOLVED :
170 ResolveUsingPrevious(host, address_family, addrlist); 172 ResolveUsingPrevious(host, address_family, host_resolver_flags, addrlist);
171 } 173 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698