Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added adblock info tab. #25490

Merged
merged 14 commits into from
Sep 17, 2024
Merged

Added adblock info tab. #25490

merged 14 commits into from
Sep 17, 2024

Conversation

boocmp
Copy link
Contributor

@boocmp boocmp commented Sep 9, 2024

Resolves brave/brave-browser#6458

image

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

@boocmp boocmp self-assigned this Sep 9, 2024
@github-actions github-actions bot added CI/run-network-audit Run network-audit CI/storybook-url Deploy storybook and provide a unique URL for each build labels Sep 9, 2024
@boocmp boocmp force-pushed the adblock_devtools branch 2 times, most recently from b5c6a38 to 47aebcc Compare September 9, 2024 14:15
@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@boocmp boocmp force-pushed the adblock_devtools branch 2 times, most recently from 766d4de to 7dc5963 Compare September 10, 2024 10:37
@boocmp boocmp marked this pull request as ready for review September 10, 2024 14:07
@boocmp boocmp requested review from fmarier, iefremov and a team as code owners September 10, 2024 14:07
@ShivanKaul
Copy link
Collaborator

@boocmp this is looking great. One question: if a network request would have been blocked by adblock-rust but isn't because of an exception rule, would that show up? Those requests would be very useful to highlight. Maybe those could be in green (since they are allowed)?

Also, we would like to eventually build the ability to detect which adblock rules were inserted into a page, and which were active, including cosmetic rules and scriplets. That definitely is beyond the scope of this PR, but just wanted to put it out there in case we can structure the code to help with that. I would imagine that could live in a new Brave Shields Blocking tab in DevTools. The experience would be simillar to Adblock Plus (though not identical).

@ShivanKaul
Copy link
Collaborator

cc @antonok-edm @ryanbr

Copy link
Member

@fmarier fmarier left a comment

Choose a reason for hiding this comment

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

script/brave_license_helper.py change 👍

@boocmp
Copy link
Contributor Author

boocmp commented Sep 11, 2024

@ShivanKaul I've added green highlighting of exceptions.
I ain't particularly familiar with our implementation of cosmetic filters, I think we can deal with it in a separate task.

@@ -591,6 +591,12 @@ Config.prototype.buildArgs = function () {
args.enable_brave_page_graph_webapi_probes = false
}

// Devtools: Now we patch devtools frontend, so it is usefull to see
Copy link
Contributor

Choose a reason for hiding this comment

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

useful

std::optional<std::string> rewritten_url;
};

CONTENT_EXPORT void SendAdblockInfo(int frame_tree_node_id,
Copy link
Contributor

Choose a reason for hiding this comment

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

pls write a comment for the functions.
They repost to the UI thread, that's also is worth mentioning here

Copy link
Contributor

[puLL-Merge] - brave/brave-core@25490

Description

This PR adds adblock information to the DevTools Network panel, allowing developers to see details about adblock decisions for network requests. The changes include new backend instrumentation to capture adblock info, modifications to the DevTools protocol to support sending this data, and frontend changes to display the information in the UI.

Changes

Changes

  1. browser/brave_shields/ad_block_devtools_browsertest.cc:

    • New file adding browser tests for the adblock DevTools functionality.
  2. browser/net/brave_ad_block_tp_network_delegate_helper.cc:

    • Modified to send adblock information to DevTools when applicable.
  3. browser/net/url_context.cc and url_context.h:

    • Added devtools_request_id field to BraveRequestInfo struct.
  4. build/commands/lib/config.js and util.js:

    • Modified build configuration to support DevTools frontend patching.
  5. chromium_src/content/browser/devtools/protocol/network_handler.cc and network_handler.h:

    • Added support for sending adblock information through the DevTools protocol.
  6. content/browser/devtools/adblock_devtools_instrumentation.cc and content/public/browser/devtools/adblock_devtools_instumentation.h:

    • New files implementing the instrumentation for capturing and sending adblock information.
  7. components/brave_shields/content/browser/domain_block_navigation_throttle.cc and domain_block_navigation_throttle.h:

    • Modified to include adblock information in the navigation throttle.
  8. Various patches to Chromium files:

    • Modified build files and DevTools frontend files to support the new adblock functionality.
  9. third_party/devtools-frontend/src/front_end/panels/network/RequestAdblockView.ts:

    • New file implementing the UI for displaying adblock information in the DevTools Network panel.

Possible Issues

  • The changes touch several critical areas of the browser, including network handling and DevTools. Thorough testing is required to ensure no regressions in existing functionality.
  • The DevTools frontend patching mechanism introduced might require careful maintenance when updating Chromium versions.

Security Hotspots

No significant security hotspots were identified in this change. The adblock information exposure is limited to the DevTools, which is already a privileged interface.

@boocmp boocmp enabled auto-merge (squash) September 17, 2024 04:05
@boocmp boocmp merged commit 0955815 into master Sep 17, 2024
19 checks passed
@boocmp boocmp deleted the adblock_devtools branch September 17, 2024 06:01
@github-actions github-actions bot added this to the 1.72.x - Nightly milestone Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/run-network-audit Run network-audit CI/storybook-url Deploy storybook and provide a unique URL for each build puLL-Merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Log requests blocked by adblocker in developer tools Network pane
7 participants