-
Notifications
You must be signed in to change notification settings - Fork 921
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
add flag for first-party blocking in standard blocking mode #9673
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chromium_src
changes ++
3729731
to
5c46bda
Compare
@@ -10,6 +10,10 @@ | |||
namespace brave_shields { | |||
namespace features { | |||
|
|||
// When disabled, Brave will allow first-party requests in "standard" blocking |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather rephrase it as "When enabled ..." :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the "disabled" state is less obvious behavior to those unfamiliar with adblocking - I added a description for both.
we need tests for this change |
@@ -76,6 +76,7 @@ struct BraveRequestInfo { | |||
// TODO(iefremov): rename to shields_up. | |||
bool allow_brave_shields = true; | |||
bool allow_ads = false; | |||
bool aggressive_blocking = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need a comment for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
@@ -138,6 +138,9 @@ std::shared_ptr<brave::BraveRequestInfo> BraveRequestInfo::MakeCTX( | |||
brave_shields::GetBraveShieldsEnabled(map, ctx->tab_origin); | |||
ctx->allow_ads = brave_shields::GetAdControlType(map, ctx->tab_origin) == | |||
brave_shields::ControlType::ALLOW; | |||
ctx->aggressive_blocking = | |||
brave_shields::GetCosmeticFilteringControlType(map, ctx->tab_origin) == |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this assignment is not really readable - I had to search through the source to understand that "aggressive" flag is stored as cosmetic filtering content setting, which we reuse here... So definitely needs a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added as well
@@ -180,7 +180,7 @@ EngineFlags ShouldBlockRequestOnTaskRunner( | |||
|
|||
SCOPED_UMA_HISTOGRAM_TIMER("Brave.Adblock.ShouldBlockRequest"); | |||
g_brave_browser_process->ad_block_service()->ShouldStartRequest( | |||
url_to_check, ctx->resource_type, source_host, | |||
url_to_check, ctx->resource_type, source_host, ctx->aggressive_blocking, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gather that at some point we can craft a struct with needed parameters, to avoid changing all of the signatures
brave_shields::features::kBraveAdblockDefault1pBlocking) || | ||
!SameDomainOrHost( | ||
url, | ||
url::Origin::CreateFromNormalizedTuple("https", tab_host.c_str(), 80), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for c_str()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what are our expectations if tab_host
is empty? AFAIR this is the SW case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, just curious whether we want to skip the check for all of the subresource types? Or maybe just scripts/whatever else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed c_str()
this is the same logic that's passed to the adblock engine already. It should be possible to refactor it to only happen in a single place later, but at the moment it's not trivial.
I'll leave @pes10k to comment on the resource types we want to apply this to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this change is outdated, so apologies if this is talking into the void, but i dont see any reason to not apply to all requests. The "what does shields block in what configurations" logic is already complicated as it is. I dont think we should make the decision tree more complicated unless there is a compelling reason
@@ -66,27 +66,36 @@ void AdBlockService::ShouldStartRequest( | |||
const GURL& url, | |||
blink::mojom::ResourceType resource_type, | |||
const std::string& tab_host, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we could pass Origin here...
@@ -66,27 +66,36 @@ void AdBlockService::ShouldStartRequest( | |||
const GURL& url, | |||
blink::mojom::ResourceType resource_type, | |||
const std::string& tab_host, | |||
bool aggressive_blocking, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bridiver we have to refactor this hierarchy so that the facade method doesn't share its signature with general adblock / regional ablock / etc.
Here we add a parameter to the facade method, and that parameter is useless for all other methods
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree a lot of refactoring is needed in general. Several PRs are in the works
generally looks good, but we need some tests, since this code is a critical part of the browser |
FWIW, i added a QA test too: https://dev-pages.brave.software/filtering/network-requests.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unblocking the merge since this looks urgent. Minors and tests can be a f/u
5c46bda
to
d66d36a
Compare
Resolves brave/brave-browser#17366
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
,npm run lint
,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan:
Disable the new
#brave-adblock-default-1p-blocking
flag, then visit https://dev-pages.bravesoftware.com/filtering/network-requests.html and follow the directions, ensuring that the images are shown as described.