User-Agent: Move ShouldOverrideUserAgent() to NavigationControllerImpl [chromium/src : main]

0 views
Skip to first unread message

Takashi Nakayama (Gerrit)

unread,
Sep 4, 2025, 4:07:49 AM (3 days ago) Sep 4
to Hiroshige Hayashizaki, Charlie Reis, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, alexmo...@chromium.org, creis...@chromium.org, navigation...@chromium.org
Attention needed from Charlie Reis and Hiroshige Hayashizaki

Takashi Nakayama voted and added 2 comments

Votes added by Takashi Nakayama

Commit-Queue+1

2 comments

Patchset-level comments
File-level comment, Patchset 2:
Takashi Nakayama . unresolved

@cr...@chromium.org Could you please take a look at this CL because the Tokyo-based reviewer is OOO this week? Thanks.

Charlie Reis

Thanks, but we don't allow new content/public APIs until there's a use for them outside content/ in the tree:
https://chromium.googlesource.com/chromium/src/+/HEAD/content/public/README.md

This is partly so that we can review how the new API will be used, to determine if it's the right API to expose. Can you include the use case in this CL, or a dependent CL that we can get approved as well?

Takashi Nakayama

I will create dependent CL(s) next week, then ask for your review again. Thanks!

Takashi Nakayama

Created dependents CL(s). Could you please take a look again?

Charlie Reis

Thanks! All of the changes in https://chromium-review.googlesource.com/c/chromium/src/+/6905125/5 and https://chromium-review.googlesource.com/c/chromium/src/+/6906464/1 are within content/, which means this shouldn't need to be exposed in the content/public API. Can we put it on NavigationControllerImpl instead?

Takashi Nakayama

Thank you for the detailed and careful suggestions! I changed the function to a method of `NavigationControllerImpl` and changed the name (and updated CL description accordingly). Could you please take a look?

File content/public/browser/navigation_controller.h
Line 130, Patchset 3: // last committed entry. `last_committed_entry` can be a nullptr.
Charlie Reis . unresolved

Needing to pass (specifically) the last committed entry here feels error prone, and something that's probably better handled within NavigationController itself. Maybe the use case for the API will make it clearer whether this is the right approach.

Charlie Reis

The use case in `PrefetchContainer::ShouldApplyUserAgentOverride` [here](https://chromium-review.googlesource.com/c/chromium/src/+/6905125/5/content/browser/preloading/prefetch/prefetch_container.cc#1526) seems to have access to the NavigationController and calls GetLastCommittedEntry() on it to pass into this function.

As noted, that seems error prone, where someone could pass in the wrong entry (including allowing time to pass so that an earlier acquired last committed entry is no longer the current one).

Can we make this an instance method on NavigationControllerImpl instead, so that it can look up GetLastCommittedEntry() internally and callers don't have to worry about it?

Takashi Nakayama

Let me merge this to the other thread crrev.com/c/6894097/comments/36a08211_9088dbca

Open in Gerrit

Related details

Attention is currently required from:
  • Charlie Reis
  • Hiroshige Hayashizaki
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ia3acacb4eabc85846e5f0d044d185444c9ddfa08
Gerrit-Change-Number: 6894097
Gerrit-PatchSet: 10
Gerrit-Owner: Takashi Nakayama <tn...@chromium.org>
Gerrit-Reviewer: Charlie Reis <cr...@chromium.org>
Gerrit-Reviewer: Hiroshige Hayashizaki <hiro...@chromium.org>
Gerrit-Reviewer: Takashi Nakayama <tn...@chromium.org>
Gerrit-Attention: Charlie Reis <cr...@chromium.org>
Gerrit-Attention: Hiroshige Hayashizaki <hiro...@chromium.org>
Gerrit-Comment-Date: Thu, 04 Sep 2025 08:07:21 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Charlie Reis <cr...@chromium.org>
Comment-In-Reply-To: Takashi Nakayama <tn...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Takashi Nakayama (Gerrit)

unread,
Sep 4, 2025, 4:08:04 AM (3 days ago) Sep 4
to Hiroshige Hayashizaki, Charlie Reis, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, alexmo...@chromium.org, creis...@chromium.org, navigation...@chromium.org
Attention needed from Charlie Reis and Hiroshige Hayashizaki

Takashi Nakayama added 1 comment

File content/public/browser/navigation_controller.h
Line 130, Patchset 3: // last committed entry. `last_committed_entry` can be a nullptr.
Charlie Reis . resolved

Needing to pass (specifically) the last committed entry here feels error prone, and something that's probably better handled within NavigationController itself. Maybe the use case for the API will make it clearer whether this is the right approach.

Charlie Reis

The use case in `PrefetchContainer::ShouldApplyUserAgentOverride` [here](https://chromium-review.googlesource.com/c/chromium/src/+/6905125/5/content/browser/preloading/prefetch/prefetch_container.cc#1526) seems to have access to the NavigationController and calls GetLastCommittedEntry() on it to pass into this function.

As noted, that seems error prone, where someone could pass in the wrong entry (including allowing time to pass so that an earlier acquired last committed entry is no longer the current one).

Can we make this an instance method on NavigationControllerImpl instead, so that it can look up GetLastCommittedEntry() internally and callers don't have to worry about it?

Takashi Nakayama

Let me merge this to the other thread crrev.com/c/6894097/comments/36a08211_9088dbca

Takashi Nakayama

Marked as resolved.

Gerrit-Comment-Date: Thu, 04 Sep 2025 08:07:34 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Charlie Reis (Gerrit)

unread,
Sep 4, 2025, 12:24:46 PM (3 days ago) Sep 4
to Takashi Nakayama, Hiroshige Hayashizaki, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, alexmo...@chromium.org, creis...@chromium.org, navigation...@chromium.org
Attention needed from Hiroshige Hayashizaki and Takashi Nakayama

Charlie Reis voted and added 1 comment

Votes added by Charlie Reis

Code-Review+1

1 comment

Patchset-level comments
File-level comment, Patchset 2:
Takashi Nakayama . resolved

@cr...@chromium.org Could you please take a look at this CL because the Tokyo-based reviewer is OOO this week? Thanks.

Charlie Reis

Thanks, but we don't allow new content/public APIs until there's a use for them outside content/ in the tree:
https://chromium.googlesource.com/chromium/src/+/HEAD/content/public/README.md

This is partly so that we can review how the new API will be used, to determine if it's the right API to expose. Can you include the use case in this CL, or a dependent CL that we can get approved as well?

Takashi Nakayama

I will create dependent CL(s) next week, then ask for your review again. Thanks!

Takashi Nakayama

Created dependents CL(s). Could you please take a look again?

Charlie Reis

Thanks! All of the changes in https://chromium-review.googlesource.com/c/chromium/src/+/6905125/5 and https://chromium-review.googlesource.com/c/chromium/src/+/6906464/1 are within content/, which means this shouldn't need to be exposed in the content/public API. Can we put it on NavigationControllerImpl instead?

Takashi Nakayama

Thank you for the detailed and careful suggestions! I changed the function to a method of `NavigationControllerImpl` and changed the name (and updated CL description accordingly). Could you please take a look?

Charlie Reis

Thanks! LGTM.

Open in Gerrit

Related details

Attention is currently required from:
  • Hiroshige Hayashizaki
  • Takashi Nakayama
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ia3acacb4eabc85846e5f0d044d185444c9ddfa08
Gerrit-Change-Number: 6894097
Gerrit-PatchSet: 10
Gerrit-Owner: Takashi Nakayama <tn...@chromium.org>
Gerrit-Reviewer: Charlie Reis <cr...@chromium.org>
Gerrit-Reviewer: Hiroshige Hayashizaki <hiro...@chromium.org>
Gerrit-Reviewer: Takashi Nakayama <tn...@chromium.org>
Gerrit-Attention: Takashi Nakayama <tn...@chromium.org>
Gerrit-Attention: Hiroshige Hayashizaki <hiro...@chromium.org>
Gerrit-Comment-Date: Thu, 04 Sep 2025 16:24:36 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Takashi Nakayama (Gerrit)

unread,
Sep 4, 2025, 9:04:25 PM (2 days ago) Sep 4
to Charlie Reis, Hiroshige Hayashizaki, Chromium LUCI CQ, AyeAye, chromium...@chromium.org, alexmo...@chromium.org, creis...@chromium.org, navigation...@chromium.org
Attention needed from Hiroshige Hayashizaki

Takashi Nakayama voted Commit-Queue+2

Commit-Queue+2
Open in Gerrit

Related details

Attention is currently required from:
  • Hiroshige Hayashizaki
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ia3acacb4eabc85846e5f0d044d185444c9ddfa08
Gerrit-Change-Number: 6894097
Gerrit-PatchSet: 10
Gerrit-Owner: Takashi Nakayama <tn...@chromium.org>
Gerrit-Reviewer: Charlie Reis <cr...@chromium.org>
Gerrit-Reviewer: Hiroshige Hayashizaki <hiro...@chromium.org>
Gerrit-Reviewer: Takashi Nakayama <tn...@chromium.org>
Gerrit-Attention: Hiroshige Hayashizaki <hiro...@chromium.org>
Gerrit-Comment-Date: Fri, 05 Sep 2025 01:03:56 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Chromium LUCI CQ (Gerrit)

unread,
Sep 4, 2025, 9:06:50 PM (2 days ago) Sep 4
to Takashi Nakayama, Charlie Reis, Hiroshige Hayashizaki, AyeAye, chromium...@chromium.org, alexmo...@chromium.org, creis...@chromium.org, navigation...@chromium.org

Chromium LUCI CQ submitted the change

Change information

Commit message:
User-Agent: Move ShouldOverrideUserAgent() to NavigationControllerImpl

The function `ShouldOverrideUserAgent()` is responsible for converting
`NavigationController::UserAgentOverrideOption` to final bool decision.
This CL changes this function into a method of NavigationControllerImpl
so that other code that handles UA overrides (e.g. //content prefetch)
can use this feature in future. This CL also renames the function name
to `ShouldOverrideUserAgentInNextNavigation()` for clarity.

Bug: 441612842
Change-Id: Ia3acacb4eabc85846e5f0d044d185444c9ddfa08
Reviewed-by: Charlie Reis <cr...@chromium.org>
Commit-Queue: Takashi Nakayama <tn...@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1511251}
Files:
  • M content/browser/renderer_host/navigation_controller_impl.cc
  • M content/browser/renderer_host/navigation_controller_impl.h
Change size: S
Delta: 2 files changed, 23 insertions(+), 23 deletions(-)
Branch: refs/heads/main
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Charlie Reis
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ia3acacb4eabc85846e5f0d044d185444c9ddfa08
Gerrit-Change-Number: 6894097
Gerrit-PatchSet: 11
Gerrit-Owner: Takashi Nakayama <tn...@chromium.org>
Gerrit-Reviewer: Charlie Reis <cr...@chromium.org>
Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
Gerrit-Reviewer: Hiroshige Hayashizaki <hiro...@chromium.org>
Gerrit-Reviewer: Takashi Nakayama <tn...@chromium.org>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages