Skip to content

[Experiment] Remove Bounce Tracking Mitigations from Cobalt#11536

Open
linxinan-yt wants to merge 5 commits into
youtube:mainfrom
linxinan-yt:btm
Open

[Experiment] Remove Bounce Tracking Mitigations from Cobalt#11536
linxinan-yt wants to merge 5 commits into
youtube:mainfrom
linxinan-yt:btm

Conversation

@linxinan-yt

Copy link
Copy Markdown
Member

Bug: 505811196

@linxinan-yt
linxinan-yt requested a review from a team as a code owner July 24, 2026 04:34
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Gemini Suggested Commit Message


cobalt: Remove Bounce Tracking Mitigations

Disable the Privacy Sandbox APIs to remove support for Bounce Tracking
Mitigations, Federated Identity, Fenced Frames, and Trust Tokens.
Removing these components reduces the browser binary size and minimizes
runtime complexity for Cobalt use cases where these privacy features are
not required.

Bug: 505811196

💡 Pro Tips for a Better Commit Message:

  1. Influence the Result: Want to change the output? You can write custom prompts or instructions directly in the Pull Request description. The model uses that text to generate the message.
  2. Re-run the Generator: Post a comment with: /generate-commit-message

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces conditional compilation guards to gate various Privacy Sandbox APIs (such as Fenced Frames, WebID, BTM, and Trust Tokens) behind the ENABLE_PRIVACY_SANDBOX_APIS build flag across the codebase. The feedback highlights two critical issues in render_frame_host_impl.cc: first, a maintainability anti-pattern where preprocessor directives span across function boundaries, which breaks code formatting and IDE tooling; second, a compilation error when the APIs are disabled due to RevokeNetworkForNonceCallback referencing the incomplete type FencedFrameProperties. It is recommended to isolate each function with its own preprocessor guards and completely compile out RevokeNetworkForNonceCallback when the build flag is disabled.

}

void RenderFrameHostImpl::DisableUntrustedNetworkInFencedFrame(
DisableUntrustedNetworkInFencedFrameCallback callback) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Maintainability Anti-Pattern: Preprocessor Directives Spanning Across Function Boundaries

Spanning preprocessor directives (#if / #else / #endif) across function boundaries (starting inside DisableUntrustedNetworkInFencedFrame and ending inside RevokeNetworkForNonceCallback) is a highly discouraged practice.

This "brace-matching" trick:

  1. Breaks Tooling: Automatic code formatters like clang-format will fail or produce highly distorted formatting due to mismatched braces inside preprocessor blocks.
  2. Breaks IDEs: IDE outline views, code navigation, refactoring tools, and brace-matching features will be completely broken.
  3. Reduces Readability: It is extremely confusing for future maintainers to follow the control flow and structure of the code.

Recommended Solution:
Each function should be self-contained with its own preprocessor guards.

  • Wrap DisableUntrustedNetworkInFencedFrame with its own #if / #else / #endif block, running the callback in the #else block.
  • Wrap RevokeNetworkForNonceCallback entirely in #if BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS) (both its declaration in render_frame_host_impl.h and its definition in render_frame_host_impl.cc). Since DisableUntrustedNetworkInFencedFrame won't call it when the APIs are disabled, it can be completely compiled out.

Comment on lines +10721 to +10723
#else
std::move(callback).Run();
#endif // BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Compilation Error: Incomplete Type FencedFrameProperties

When ENABLE_PRIVACY_SANDBOX_APIS is false, FencedFrameProperties is not defined because the fenced_frame/* directory is excluded from the build.

Because FencedFrameProperties is undefined, the signature of RevokeNetworkForNonceCallback in render_frame_host_impl.h (which uses std::optional<FencedFrameProperties>) will fail to compile, as std::optional requires a complete type.

Recommended Solution:
Completely wrap both the declaration of RevokeNetworkForNonceCallback in render_frame_host_impl.h and its definition in render_frame_host_impl.cc with #if BUILDFLAG(ENABLE_PRIVACY_SANDBOX_APIS). Since the calling function DisableUntrustedNetworkInFencedFrame is already guarded, RevokeNetworkForNonceCallback is completely unused when the APIs are disabled and can be safely compiled out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant