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

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

Issue 15140003: Add support for split Public Suffix List distinctions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased again Created 7 years, 7 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
« no previous file with comments | « chrome/browser/history/history_backend.cc ('k') | chrome/browser/net/url_fixer_upper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 return; 113 return;
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::registry_controlled_domains::SameDomainOrHost(
124 resulting_origins_.front(), origin)) { 124 resulting_origins_.front(),
125 origin,
126 net::registry_controlled_domains::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 const bool same_domain_or_host =
139 resulting_origins_.back(), origin) ? origin : GURL(); 141 net::registry_controlled_domains::SameDomainOrHost(
142 resulting_origins_.back(),
143 origin,
144 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES);
145 redirect_origin_ = same_domain_or_host ? origin : GURL();
140 } 146 }
141 147
142 g_browser_process->local_state()->SetString( 148 g_browser_process->local_state()->SetString(
143 prefs::kLastKnownIntranetRedirectOrigin, redirect_origin_.is_valid() ? 149 prefs::kLastKnownIntranetRedirectOrigin, redirect_origin_.is_valid() ?
144 redirect_origin_.spec() : std::string()); 150 redirect_origin_.spec() : std::string());
145 } 151 }
146 152
147 void IntranetRedirectDetector::OnIPAddressChanged() { 153 void IntranetRedirectDetector::OnIPAddressChanged() {
148 // If a request is already scheduled, do not scheduled yet another one. 154 // If a request is already scheduled, do not scheduled yet another one.
149 if (in_sleep_) 155 if (in_sleep_)
(...skipping 24 matching lines...) Expand all
174 // the same thread. So just use the heuristic that any all-lowercase a-z 180 // 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 181 // hostname with the right number of characters is likely from the detector
176 // (and thus should be blocked). 182 // (and thus should be blocked).
177 return ((host.length() == IntranetRedirectDetector::kNumCharsInHostnames) && 183 return ((host.length() == IntranetRedirectDetector::kNumCharsInHostnames) &&
178 (host.find_first_not_of("abcdefghijklmnopqrstuvwxyz") == 184 (host.find_first_not_of("abcdefghijklmnopqrstuvwxyz") ==
179 std::string::npos)) ? 185 std::string::npos)) ?
180 net::ERR_NAME_NOT_RESOLVED : 186 net::ERR_NAME_NOT_RESOLVED :
181 ResolveUsingPrevious(host, address_family, host_resolver_flags, addrlist, 187 ResolveUsingPrevious(host, address_family, host_resolver_flags, addrlist,
182 os_error); 188 os_error);
183 } 189 }
OLDNEW
« no previous file with comments | « chrome/browser/history/history_backend.cc ('k') | chrome/browser/net/url_fixer_upper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698