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

Unified Diff: components/history/core/browser/history_backend.cc

Issue 2757003002: Untyped intranet URL check should examine the start and end of a redirect chain. (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: components/history/core/browser/history_backend.cc
diff --git a/components/history/core/browser/history_backend.cc b/components/history/core/browser/history_backend.cc
index 62187120cff3ae3d97a93a60b1fdcd8759dff2e5..5b1d53ddccd2dc97863ad91160efdc96e6213b87 100644
--- a/components/history/core/browser/history_backend.cc
+++ b/components/history/core/browser/history_backend.cc
@@ -372,6 +372,19 @@ void HistoryBackend::UpdateVisitDuration(VisitID visit_id, const Time end_ts) {
}
}
+bool HistoryBackend::IsUntypedIntranetHost(const GURL& url) {
+ if (!url.SchemeIs(url::kHttpScheme) && !url.SchemeIs(url::kHttpsScheme) &&
+ !url.SchemeIs(url::kFtpScheme))
+ return false;
+
+ const std::string host = url.host();
+ const size_t registry_length =
+ net::registry_controlled_domains::GetCanonicalHostRegistryLength(
+ host, net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES,
+ net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES);
+ return (registry_length == 0) && !db_->IsTypedHost(host);
+}
+
TopHostsList HistoryBackend::TopHosts(size_t num_hosts) const {
if (!db_)
return TopHostsList();
@@ -450,21 +463,13 @@ void HistoryBackend::AddPage(const HistoryAddPageArgs& request) {
!ui::PageTransitionCoreTypeIs(request_transition,
ui::PAGE_TRANSITION_TYPED) &&
!is_keyword_generated) {
- const GURL& origin_url(has_redirects ? request.redirects[0] : request.url);
- if (origin_url.SchemeIs(url::kHttpScheme) ||
- origin_url.SchemeIs(url::kHttpsScheme) ||
- origin_url.SchemeIs(url::kFtpScheme)) {
- std::string host(origin_url.host());
- size_t registry_length =
- net::registry_controlled_domains::GetCanonicalHostRegistryLength(
- host,
- net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES,
- net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES);
- if (registry_length == 0 && !db_->IsTypedHost(host)) {
- request_transition = ui::PageTransitionFromInt(
- ui::PAGE_TRANSITION_TYPED |
- ui::PageTransitionGetQualifier(request_transition));
- }
+ // Check both the start and end of a redirect chain, since the user will
+ // consider both to have been "navigated to".
+ if (IsUntypedIntranetHost(request.url) ||
+ (has_redirects && IsUntypedIntranetHost(request.redirects[0]))) {
+ request_transition = ui::PageTransitionFromInt(
+ ui::PAGE_TRANSITION_TYPED |
+ ui::PageTransitionGetQualifier(request_transition));
}
}
« no previous file with comments | « components/history/core/browser/history_backend.h ('k') | components/history/core/browser/history_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698