Commit 8dfd9e23 authored by Daniel Rubery's avatar Daniel Rubery Committed by Commit Bot

Ignore the original_request_url of retargeting NavigationEvents

Since the original request may have been cancelled, the
original_request_url is not reliable, and should be overwritten with the
search_url in referrer chain attribution.

Bug: 903996
Change-Id: Ie04f9fe60665ebae83054eccdab0719d0840721c
Reviewed-on: https://chromium-review.googlesource.com/c/1330754
Commit-Queue: Daniel Rubery <drubery@chromium.org>
Reviewed-by: default avatarVarun Khaneja <vakh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607056}
parent e94e6a76
......@@ -166,6 +166,10 @@ NavigationEvent* NavigationEventList::FindNavigationEvent(
// Adjust retargeting navigation event's attributes.
retargeting_nav_event->server_redirect_urls.push_back(
std::move(search_url));
} else {
// The retargeting_nav_event original request url is unreliable, since
// that navigation can be canceled.
retargeting_nav_event->original_request_url = std::move(search_url);
}
return retargeting_nav_event;
} else {
......
......@@ -490,4 +490,50 @@ TEST_F(SBNavigationObserverTest, ChainContinuesThroughBrowserInitiated) {
EXPECT_EQ(2, referrer_chain.size());
}
TEST_F(SBNavigationObserverTest,
CanceledRetargetingNavigationHasCorrectEventUrl) {
base::Time now = base::Time::Now();
base::Time one_hour_ago =
base::Time::FromDoubleT(now.ToDoubleT() - 60.0 * 60.0);
SessionID source_tab = SessionID::NewUnique();
SessionID target_tab = SessionID::NewUnique();
// Add two navigations. A initially opens a new tab with url B, but cancels
// that before it completes. It then navigates the new tab to C. We expect
// that asking for the referrer chain for C has C as the event url.
std::unique_ptr<NavigationEvent> first_navigation =
std::make_unique<NavigationEvent>();
first_navigation->source_url = GURL("http://example.com/a");
first_navigation->original_request_url = GURL("http://example.com/b");
first_navigation->last_updated = one_hour_ago;
first_navigation->navigation_initiation =
ReferrerChainEntry::RENDERER_INITIATED_WITH_USER_GESTURE;
first_navigation->source_tab_id = source_tab;
first_navigation->target_tab_id = target_tab;
first_navigation->has_committed = false;
navigation_event_list()->RecordNavigationEvent(std::move(first_navigation));
std::unique_ptr<NavigationEvent> second_navigation =
std::make_unique<NavigationEvent>();
second_navigation->original_request_url = GURL("http://example.com/c");
second_navigation->last_updated = now;
second_navigation->navigation_initiation =
ReferrerChainEntry::BROWSER_INITIATED;
second_navigation->source_tab_id = target_tab;
second_navigation->target_tab_id = target_tab;
navigation_event_list()->RecordNavigationEvent(std::move(second_navigation));
ReferrerChain referrer_chain;
navigation_observer_manager_->IdentifyReferrerChainByEventURL(
GURL("http://example.com/c"), SessionID::InvalidValue(), 10,
&referrer_chain);
ASSERT_EQ(1, referrer_chain.size());
EXPECT_EQ("http://example.com/c", referrer_chain[0].url());
EXPECT_EQ("http://example.com/a", referrer_chain[0].referrer_url());
EXPECT_TRUE(referrer_chain[0].is_retargeting());
}
} // namespace safe_browsing
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