-
Notifications
You must be signed in to change notification settings - Fork 940
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
Additional Shields menu item to show all blocked elements(same as reset) #27910
Additional Shields menu item to show all blocked elements(same as reset) #27910
Conversation
A Storybook has been deployed to preview UI for the latest push |
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.
strings
++
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.
a couple of minor changes. the rest LGTM
@@ -0,0 +1,35 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<!-- Copyright (c) 2020 The Brave Authors. All rights reserved. |
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.
nit : year should be 2025
android:layout_height="0dp" | ||
android:layout_weight="1" | ||
android:paddingHorizontal="16dp" | ||
android:paddingTop="16dp" |
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.
nit : we can use paddingVertical here as paddingTop and paddingBottom have the same values.
Signed-off-by: Vadym Struts <[email protected]>
Signed-off-by: Vadym Struts <[email protected]>
Signed-off-by: Vadym Struts <[email protected]>
Signed-off-by: Vadym Struts <[email protected]>
Signed-off-by: Vadym Struts <[email protected]>
e6296be
to
e820257
Compare
e820257
to
027d1ed
Compare
Signed-off-by: Vadym Struts <[email protected]>
027d1ed
to
aa071c1
Compare
GetWebContents().GetController().Reload(content::ReloadType::NORMAL, true); | ||
void CosmeticFiltersTabHelper::ManageCustomFilters() { | ||
#if !BUILDFLAG(IS_ANDROID) | ||
Browser* browser = chrome::FindBrowserWithTab(&GetWebContents()); |
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.
reported by reviewdog 🐶
[semgrep] There are several global functions that facilitate dependency inversion. It will not be possible to call them from modularized features (no dependency cycles), and their usage in non-modularized features is considered a red flag
Don't use Browser*. This is functionally a container of hundreds of other pointers. It is impossible to specify dependencies, since Browser* functionally depends on everything. Instead, pass in the relevant pointers, e.g. Profile*, FooFeatureController, etc
References:
- https://chromium.googlesource.com/chromium/src/+/main/docs/chrome_browser_design_principles.md#structure_modularity
Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/client/browser-dependency-inversion.yaml
Cc @goodov @cdesouza-chromium @bridiver
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.
cc @bridiver I think the wording can be improved to mention valid use cases when we use Browser*
as a "window" object, i.e. we have some functionality bound to the browser window. We shouldn't convert such scenarios to Profile*
as it will lose the connection to the exact window.
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.
But we're not supposed to have functionality tied to Browser anymore. This wording is pulled directly from https://source.chromium.org/chromium/chromium/src/+/main:docs/chrome_browser_design_principles.md;l=1?q=design_principles.&ss=chromium
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 in particular it's bad to have a dependency on Browser here in the tab helper. I'm on my phone right now so I can't see what this helper is doing internally, but at the very least we should pass the webcontents and keep the Browser dependency inside the helper. It's possible we should not be using Browser here at all, but I can't say for sure until I get home and see the details
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 FindBrowserWithTab should have been flagged here. Does it only catch one per line @thypon ?
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 appears to be the only usage of ShowBraveAdblock
so we should change it to use
void ShowSingletonTabOverwritingNTP(
Profile* profile,
const GURL& url,
NavigateParams::PathBehavior path_behavior)
instead of the Browser
version
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 appears to be the only usage of
ShowBraveAdblock
so we should change it to usevoid ShowSingletonTabOverwritingNTP( Profile* profile, const GURL& url, NavigateParams::PathBehavior path_behavior)
instead of the
Browser
version
It doesn't make sense to create a tab using a Profile*
instance when you're acting from a specific tab that is bound to a specific Browser*
instance.
I think technically we should follow this example here:
// Do not do this:
FooTabFeature {
// As per (1) above, we shouldn't be passing or storing Browser* anyways.
// Another common anti-pattern is to dynamically look up Browser* via
// browser_finder methods. These often result in the wrong Browser*
Browser* browser_;
// This will point to the wrong BrowserView if the tab is dragged into a new
// window. Furthermore, BrowserView* itself is a container of hundreds of
// other views. The tab-scoped feature typically wants something much more
// specific.
BrowserView* browser_view_;
// Extensions are profile-scoped, and thus any state/logic should be in a
// ProfileKeyedService. If the user has multiple tabs (possibly across
// multiple windows) simultaneously interacting with FooTabFeature, then it's
// likely that the extension will uninstall while it's still in use.
void InstallExtension();
void UninstallExtension();
};
// Instead do this:
FooTabFeature {
// Guaranteed to remain valid for the lifetime of this class. This can be used
// to dynamically access relevant window state via
// tab_->GetBrowserWindowInterface()->GetFeatures().GetFooWindowFeature()
TabInterface* tab_;
};
So ShowSingletonTabOverwritingNTP
should be a part of GetBrowserWindowInterface
or something like that.
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.
If we don't want to change the function signature atm we can use smth like:
TabInterface::MaybeGetFromContents(contents)->GetBrowserWindowInterface()->GetBrowserForMigrationOnly()
note: don't forget to check pointers on every step.
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.
In context of mentioned approach we could change the function ShowBraveAdblock to look like:
void ShowBraveAdblock(BrowserWindowInterface* browser_window_interface) {
if(!browser_window_interface) {
return;
}
content::OpenURLParams params(GURL(kBraveUIAdblockURL)), content::Referrer(),
WindowOpenDisposition::SINGLETON_TAB,
ui::PAGE_TRANSITION_AUTO_TOPLEVEL, false);
browser_window_interface->OpenURL(params, {});
}
It does the same like the current one, doesn't require Browser dependency, and doesn't use the "GetBrowserForMigrationOnly"
WDYT?
@goodov, @bridiver, @boocmp
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 looks like a separate task to refactor these functions all at once.
Signed-off-by: Vadym Struts <[email protected]>
Signed-off-by: Vadym Struts <[email protected]>
Signed-off-by: Vadym Struts <[email protected]>
Signed-off-by: Vadym Struts <[email protected]>
browser/ui/brave_pages.cc
Outdated
@@ -24,8 +24,8 @@ void ShowBraveRewards(Browser* browser) { | |||
ShowSingletonTabOverwritingNTP(browser, GURL(kRewardsPageURL)); | |||
} | |||
|
|||
void ShowBraveAdblock(Browser* browser) { | |||
ShowSingletonTabOverwritingNTP(browser, GURL(kBraveUIAdblockURL)); | |||
void ShowBraveAdblock(Profile* profile) { |
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 all these functions use Browser*
to display the requested page in the exact browser window, NOT in the last active window. Passing Profile*
here will switch those function to look for the last active browser window and load the requested page there instead of the explicit browser window the caller asks for.
Signed-off-by: Vadym Struts <[email protected]>
Released in v1.78.41 |
Resolves brave/brave-browser#43955
Implemented additional menu item to the shields popup dialog. It appears just in case the current page has custom filters related to the element blocker feature (i.e. some blocked elements)
Blocked elements count is not available yet, as needs adblock engine modifications.
Desktop:
2025-03-03.11-11-35.mp4
Android:
2025-03-03.10-15-46.mp4
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
wikinpm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan: