Commit 5963da8a authored by Stephane Zermatten's avatar Stephane Zermatten Committed by Commit Bot

[Autofill Assistant] Fix the navigation detection logic.

Before this patch, the navigation detection logic for what happens
during a prompt (a script is running with a touchable element area) was
incorrect:
 - it was too trigger happy, disallowing navigation for other frames,
   such when fetching data in the background
 - it did not detect usage of the back button

With this patch, during a prompt, only non-renderer initiated navigation
is disabled. That includes hitting the back button or refreshing the
page through the UI, but not clicking on a link or Javascript-triggered
navigation.

From the user's point of view, with this patch, scripts won't randomly
fail during prompt anymore.

Change-Id: I0d825eeae596503e80d27e5ab032eee7e966ea4c
Bug: 911108
Reviewed-on: https://chromium-review.googlesource.com/c/1358496Reviewed-by: default avatarMathias Carlen <mcarlen@chromium.org>
Commit-Queue: Stephane Zermatten <szermatt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#613101}
parent eac49afe
......@@ -526,20 +526,24 @@ void Controller::DidStartNavigation(
// page is considered an end condition.
if (navigation_handle->IsInMainFrame() &&
web_contents()->GetLastCommittedURL().is_valid() &&
!script_tracker_->running() && !navigation_handle->WasServerRedirect() &&
!navigation_handle->IsSameDocument() &&
!navigation_handle->IsRendererInitiated()) {
GiveUp();
return;
}
!navigation_handle->WasServerRedirect() &&
!navigation_handle->IsSameDocument()) {
if (!script_tracker_->running() &&
!navigation_handle->IsRendererInitiated()) {
GiveUp();
return;
}
// Special case: during a prompt, forbid render-initiated navigation. This is
// necessary as there won't be any script lookup to tell us whether the
// destination page is acceptable.
if (script_tracker_->running() && touchable_element_area_.HasElements() &&
navigation_handle->IsRendererInitiated()) {
GiveUp();
return;
// Special case: during a prompt, only forbid non-render-initiated
// navigation for the main frame, such as going back to the previous page or
// refreshing the page using the UI. This allows clicking on links and
// Javascript-initiated navigation; it's up to the action to define a
// touchable element area that prevents these from happening.
if (script_tracker_->running() && touchable_element_area_.HasElements() &&
!navigation_handle->IsRendererInitiated()) {
GiveUp();
return;
}
}
}
......
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