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

Force aggressive cosmetic filtering on youtube #18813

Merged
merged 3 commits into from
Jul 8, 2023

Conversation

antonok-edm
Copy link
Collaborator

Resolves brave/brave-browser#30896

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • 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 lint, 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:

Visit youtube.com and verify that there's no difference in parts of the page visible when toggling between Block trackers & ads and Aggressively block trackers & ads in the Advanced controls section of the Shields panel.

Toggling to Allow all trackers & ads or turning Shields off completely should still show preroll and page ads.

@antonok-edm antonok-edm requested review from pes10k and ryanbr June 8, 2023 04:20
@antonok-edm antonok-edm self-assigned this Jun 8, 2023
@github-actions github-actions bot added the CI/run-network-audit Run network-audit label Jun 8, 2023
@@ -186,7 +186,7 @@ EngineFlags ShouldBlockRequestOnTaskRunner(

bool force_aggressive = SameDomainOrHost(
ctx->initiator_url,
url::Origin::CreateFromNormalizedTuple("https", "youtube.com", 80),
url::Origin::CreateFromNormalizedTuple("https", "youtube.com", 443),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Doesn't seem to matter, but I changed the port to 443 here for consistency.

Copy link
Contributor

Choose a reason for hiding this comment

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

can you also please add a comment that links a ticket(s) in both cases

@pes10k
Copy link
Contributor

pes10k commented Jun 8, 2023

looks great to me, though please make sure to sync with @cuba when hes back from PTO to make sure iOS matches

Copy link
Contributor

@pes10k pes10k left a comment

Choose a reason for hiding this comment

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

LGTM

@antonok-edm antonok-edm requested a review from cuba June 8, 2023 16:51
content_settings->IsFirstPartyCosmeticFilteringEnabled(url_) ||
net::registry_controlled_domains::SameDomainOrHost(
url_,
url::Origin::CreateFromNormalizedTuple("https", "youtube.com", 443),
Copy link
Contributor

Choose a reason for hiding this comment

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

i would rather move this check to a separate statement, to avoid mixing exceptional/hardcoded cases with normal code. I.e. making corner cases very clear and visible never hurts

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1
Also ask iOS team to make a ticket to sync these changes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

BTW we already use per-frame GetBlinkPreferences().force_cosmetic_filtering.
IMHO if we change force_cosmetic_filtering to cosmetic_filtering_mode we will get a single point to in the browser process to setup cosmetic filter mode for a single frame.

The exceptions like youtube & g_vetted_search_engines could be moved there.
And cosmetic_filtering_mode will be the one source to check for CosmeticFiltersJsHandler.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree this check is not great, but I think these changes could probably move to a follow-up if done immediately following this since it's apparently a high priority fix, but my bigger concern here is that there is no test to verify this.

Copy link
Contributor

@cuba cuba Jul 6, 2023

Choose a reason for hiding this comment

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

The relevant iOS changes to correspond with these changes are here: It's introducing network level standard mode and the youtube.com exception to both network blocking and CF.

@iefremov
Copy link
Contributor

cc @atuchin-m

Copy link
Contributor

@iefremov iefremov left a comment

Choose a reason for hiding this comment

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

pls make the requested changes in a followup

@antonok-edm antonok-edm force-pushed the force-aggressive-cosmetic-filtering-youtube branch from 2a3e0a5 to 3e4d430 Compare July 7, 2023 22:38
@antonok-edm antonok-edm force-pushed the force-aggressive-cosmetic-filtering-youtube branch from 3e4d430 to a9d5f08 Compare July 8, 2023 04:49
@antonok-edm antonok-edm merged commit 8afae7c into master Jul 8, 2023
6 checks passed
@antonok-edm antonok-edm deleted the force-aggressive-cosmetic-filtering-youtube branch July 8, 2023 07:15
@github-actions github-actions bot added this to the 1.58.x - Nightly milestone Jul 8, 2023
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Force aggressive cosmetic filtering on YouTube
7 participants