Commit 70082341 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

history: makes FROM_API_3 carry through to redirect chain end

When history adds a page with redirects the transition qualifier
is not applied to redirects. This resulted in FROM_API_3 being
dropped, and pages that should be hidden being shown.

This patch adds FROM_API_3 to CHAIN_END if FROM_API_3 was present
in the requested transition. It's only necessary to add for CHAIN_END,
as CHAIN_END must be present in order for the visit to be considered
visible.

BUG=1145208
TEST=HistoryBackendTest.AddPageWithRedirectsAndFromApi3IsNotVisible

Change-Id: I4ac41e5385fe58b249532f1251612b6c1112005b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2521833
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824582}
parent 86ef81d7
...@@ -677,6 +677,13 @@ void HistoryBackend::AddPage(const HistoryAddPageArgs& request) { ...@@ -677,6 +677,13 @@ void HistoryBackend::AddPage(const HistoryAddPageArgs& request) {
// If this is the last transition, add a CHAIN_END marker // If this is the last transition, add a CHAIN_END marker
if (redirect_index == (redirects.size() - 1)) { if (redirect_index == (redirects.size() - 1)) {
t = ui::PageTransitionFromInt(t | ui::PAGE_TRANSITION_CHAIN_END); t = ui::PageTransitionFromInt(t | ui::PAGE_TRANSITION_CHAIN_END);
// In order for a visit to be visible, it must have CHAIN_END. If the
// requested transition contained PAGE_TRANSITION_FROM_API_3, then
// add it to the CHAIN_END visit so that the visit is not visible.
if ((ui::PageTransitionGetQualifier(request_transition) &
ui::PAGE_TRANSITION_FROM_API_3) != 0) {
t = ui::PageTransitionFromInt(t | ui::PAGE_TRANSITION_FROM_API_3);
}
// Since request.publicly_routable is a property of the visit to // Since request.publicly_routable is a property of the visit to
// request.url, it only applies to the final redirect. // request.url, it only applies to the final redirect.
......
...@@ -2999,6 +2999,22 @@ TEST_F(HistoryBackendTest, QueryMostVisitedURLs) { ...@@ -2999,6 +2999,22 @@ TEST_F(HistoryBackendTest, QueryMostVisitedURLs) {
MostVisitedURL(GURL("http://example5.com"), kSomeTitle))); MostVisitedURL(GURL("http://example5.com"), kSomeTitle)));
} }
TEST_F(HistoryBackendTest, AddPageWithRedirectsAndFromApi3IsNotVisible) {
ASSERT_TRUE(backend_.get());
HistoryAddPageArgs args;
args.url = GURL("http://result.com");
args.time = base::Time::Now();
args.transition = ui::PageTransitionFromInt(ui::PAGE_TRANSITION_LINK |
ui::PAGE_TRANSITION_FROM_API_3);
args.redirects.push_back(GURL("http://result.com/redirect"));
args.redirects.push_back(args.url);
backend_->AddPage(args);
QueryResults results =
backend_->QueryHistory(base::string16(), QueryOptions());
EXPECT_TRUE(results.empty());
}
TEST(FormatUrlForRedirectComparisonTest, TestUrlFormatting) { TEST(FormatUrlForRedirectComparisonTest, TestUrlFormatting) {
// Tests that the formatter removes HTTPS scheme, port, username/password, // Tests that the formatter removes HTTPS scheme, port, username/password,
// and trivial "www." subdomain. Domain and path are left unchanged. // and trivial "www." subdomain. Domain and path are left unchanged.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment