Commit 549f5891 authored by Daniel Rubery's avatar Daniel Rubery Committed by Commit Bot

Remove target_url from FindRetargetingNavigationEvent

We can't rely on the target_url to be valid when looking for a
retargeting event, since the new tab may be navigated away from its
original destination before anything commits. This CL should be safe
since it seems impossible to make the current URL empty, except for
the initial empty URL when opening a new window.

Bug: 876768
Change-Id: I72860d3e5404a86511e3f247b94fdf6a6a12c2b4
Reviewed-on: https://chromium-review.googlesource.com/1187278Reviewed-by: default avatarJialiu Lin <jialiul@chromium.org>
Commit-Queue: Daniel Rubery <drubery@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585604}
parent d7fd86e0
......@@ -150,8 +150,7 @@ NavigationEvent* NavigationEventList::FindNavigationEvent(
if (nav_event->source_url.is_empty() &&
nav_event->source_main_frame_url.is_empty()) {
NavigationEvent* retargeting_nav_event = FindRetargetingNavigationEvent(
nav_event->last_updated, nav_event->original_request_url,
nav_event->target_tab_id);
nav_event->last_updated, nav_event->target_tab_id);
if (!retargeting_nav_event)
return nav_event;
// If there is a server redirection immediately after retargeting, we
......@@ -172,11 +171,7 @@ NavigationEvent* NavigationEventList::FindNavigationEvent(
NavigationEvent* NavigationEventList::FindRetargetingNavigationEvent(
const base::Time& last_event_timestamp,
const GURL& target_url,
SessionID target_tab_id) {
if (target_url.is_empty())
return nullptr;
// Since navigation events are recorded in chronological order, we traverse
// the vector in reverse order to get the latest match.
for (auto rit = navigation_events_.rbegin(); rit != navigation_events_.rend();
......@@ -189,8 +184,7 @@ NavigationEvent* NavigationEventList::FindRetargetingNavigationEvent(
// In addition to url and tab_id checking, we need to compare the
// source_tab_id and target_tab_id to make sure it is a retargeting event.
if (nav_event->original_request_url == target_url &&
nav_event->target_tab_id == target_tab_id &&
if (nav_event->target_tab_id == target_tab_id &&
nav_event->source_tab_id != nav_event->target_tab_id) {
return nav_event;
}
......
......@@ -85,11 +85,10 @@ struct NavigationEventList {
const GURL& target_main_frame_url,
SessionID target_tab_id);
// Finds the most recent retargeting NavigationEvent that satisfies
// |target_url|, and |target_tab_id|.
// Finds the most recent retargeting NavigationEvent that satisfies the
// |target_tab_id|.
NavigationEvent* FindRetargetingNavigationEvent(
const base::Time& last_event_timestamp,
const GURL& target_url,
SessionID target_tab_id);
void RecordNavigationEvent(std::unique_ptr<NavigationEvent> nav_event);
......
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