Skip to content

Commit

Permalink
[MPArch] Use IsOutermostMainFrame instead of checking the Parent
Browse files Browse the repository at this point in the history
render_frame()->GetWebFrame()->Parent() is used to detect if the
primary main frame was navigated or a subframe. In MPArch, because
of nested frame trees, instead of checking Parent() we should
check IsOutermostMainFrame.

Bug: 1294378
Change-Id: I303569cec12c2bf6e00a6f8680c8379f142a0379
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3710067
Reviewed-by: Christoph Schwering <schwering@google.com>
Reviewed-by: Adithya Srinivasan <adithyas@chromium.org>
Reviewed-by: Vasilii Sukhanov <vasilii@chromium.org>
Commit-Queue: Liviu Tinta <liviutinta@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1016913}
  • Loading branch information
liviutinta authored and Chromium LUCI CQ committed Jun 22, 2022
1 parent 296cfd4 commit 1e2a8ea
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions components/autofill/content/renderer/form_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ void FormTracker::DidStartNavigation(
absl::optional<blink::WebNavigationType> navigation_type) {
DCHECK_CALLED_ON_VALID_SEQUENCE(form_tracker_sequence_checker_);
blink::WebLocalFrame* navigated_frame = render_frame()->GetWebFrame();
// Ony handle main frame.
if (navigated_frame->Parent())
// Ony handle primary main frame.
if (!navigated_frame->IsOutermostMainFrame())
return;

// Bug fix for crbug.com/368690. isProcessingUserGesture() is false when
Expand Down
10 changes: 6 additions & 4 deletions components/autofill/content/renderer/password_autofill_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,9 @@ void PasswordAutofillAgent::OnFrameDetached() {
// If a sub frame has been destroyed while the user was entering information
// into a password form, try to save the data. See https://crbug.com/450806
// for examples of sites that perform login using this technique.
if (render_frame()->GetWebFrame()->Parent() && browser_has_form_to_process_) {
// We are treating primary main frame and the root of embedded frames the same
// on purpose.
if (browser_has_form_to_process_ && render_frame()->GetWebFrame()->Parent()) {
DCHECK(FrameCanAccessPasswordManager());
GetPasswordManagerDriver().DynamicFormSubmission(
SubmissionIndicatorEvent::FRAME_DETACHED);
Expand Down Expand Up @@ -1408,12 +1410,12 @@ void PasswordAutofillAgent::ReadyToCommitNavigation(
}

WebLocalFrame* navigated_frame = render_frame()->GetWebFrame();
if (navigated_frame->Parent()) {
LogMessage(logger.get(), Logger::STRING_FRAME_NOT_MAIN_FRAME);
} else {
if (navigated_frame->IsOutermostMainFrame()) {
// This is a new navigation, so require a new user gesture before filling in
// passwords.
gatekeeper_.Reset();
} else {
LogMessage(logger.get(), Logger::STRING_FRAME_NOT_MAIN_FRAME);
}

CleanupOnDocumentShutdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ void PasswordGenerationAgent::BindPendingReceiver(

void PasswordGenerationAgent::DidCommitProvisionalLoad(
ui::PageTransition transition) {
// Update stats for main frame navigation.
if (!render_frame()->GetWebFrame()->Parent()) {
// Update stats for primary main frame navigation.
if (render_frame()->GetWebFrame()->IsOutermostMainFrame()) {
if (current_generation_item_) {
if (current_generation_item_->password_edited_) {
password_generation::LogPasswordGenerationEvent(
Expand Down

0 comments on commit 1e2a8ea

Please sign in to comment.