-
Notifications
You must be signed in to change notification settings - Fork 871
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
Pass ShieldsSettings to renderer via mojo. #25505
Conversation
45189f3
to
f901d18
Compare
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.
LGTM % questions
if (shields_up) { | ||
auto fingerprinting_type = brave_shields::GetFingerprintingControlType( | ||
host_content_settings_map, url); | ||
if (fingerprinting_type == ControlType::BLOCK) { |
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.
Shouldn't we be using a switch here to exhaust all possible options of this control type, and catch any potential cases slipping trough if a new key is added to ControlType
.
if (shields_up) { | ||
auto fingerprinting_type = brave_shields::GetFingerprintingControlType( | ||
host_content_settings_map, primary_url); | ||
if (fingerprinting_type == ControlType::BLOCK) { |
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.
ditto
} | ||
} | ||
}); | ||
RenderFrameHost* rfh = navigation_handle->GetRenderFrameHost(); |
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.
Looks like navigation_handle->HasCommitted()
and !navigation_handle->IsSameDocument()
should be checked
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 navigation_handle->IsSameDocument()
check.
navigation_handle->HasCommitted()
doesn't make sense in ReadyToCommitNavigation
GetBraveShieldsRemote(rfh)->SetReduceLanguageEnabled( | ||
brave_shields::IsReduceLanguageEnabledForProfile(pref_service)); | ||
} | ||
SendShieldsSettingsToFrame(rfh, nullptr); |
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.
Do we really need this taking into account we handle ReadyToCommitNavigation()
?
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.
P.S. there is per-RFH structure called DocumentUserData that allows to avoid manual frame tracking.
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.
Do we really need this taking into account we handle ReadyToCommitNavigation() ?
I wanted to keep most things without changes and then do a separate cleanup, but I guess it's fine to cleanup some obvious things right now.
31f115f
to
3067fcf
Compare
3067fcf
to
dfe38fa
Compare
if (const auto& shields_settings = \ | ||
static_cast<content_settings::BraveContentSettingsAgentImpl*>(agent) \ | ||
->shields_settings()) { \ | ||
shields_settings_ = shields_settings->Clone(); \ |
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.
why isn't shields_settings part of RendererContentSettingRules?
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'm also a bit confused about why we'd have things in ContentSettingsAgent that aren't content settings like reduce langage and origins to allow scripts and then take something that is a content setting (farbling level) and treat it differently.
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'm in favor of something that gets the "effective" setting, but I'm not sure that ContentSettingsAgent is the right place for this and maybe we should create something new. There are a lot of problems with the farbling content setting (like using CONTENT_SETTINGS_DEFAULT as a distinct value) and the current issue for most settings that we always have to check shields in addition to the content setting. I've been thinking that similar to cookies we should have a real content setting (BRAVE_COOKIES) and an effective content setting (COOKIES) that gives you the value after applying shields.
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.
These settings do make sense as part of WebContentSettingsClient, but I'm not a fan of adding this to ContentSettingsAgent/RendererContentSettingRules by adding a new mojo type for shield settings. If we were going to do something like this (instead of having an effective content setting) then I think it makes more sense to be a new mojo interface
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.
why isn't shields_settings part of RendererContentSettingRules?
mainly because of the patches. This is not the usual ContentSettingsForOneType
list that's just prefilled with values from HostContentSettingsMap
. To support this as a part of RendererContentSettingRules
we will need to add some patches into PageSpecificContentSettings
, which we can avoid entirely.
I also need to use this structure for the proper workers farbling. Right now we only have this:
brave-core/chromium_src/third_party/blink/public/mojom/worker/worker_content_settings_proxy.mojom
Lines 9 to 14 in 0955815
interface WorkerContentSettingsProxy { | |
// Returns whether the worker is allowed access to privileged functions that | |
// could be used for fingerprinting. | |
[Sync] | |
GetBraveFarblingLevel() => (uint8 result); | |
}; |
I'm also a bit confused about why we'd have things in ContentSettingsAgent that aren't content settings like reduce langage and origins to allow scripts and then take something that is a content setting (farbling level) and treat it differently.
we may look into creating a separate BraveShieldsSettings
class on the blink side, but for now I think it's acceptable to keep it as part of ContentSettingsAgent
. It seems like too much plumbing will be required to introduce something like ContentSettingsAgent
and wire it will all users in the renderer.
I'm in favor of something that gets the "effective" setting
yep, one of the end goals is to calculate the effective shields configuration before passing it to the renderer, but this is out of the scope of this PR currently.
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.
It seems like too much plumbing will be required to introduce something like ContentSettingsAgent and wire it will all users in the renderer.
Supplement<ExecutionContext>
should make it available anywhere that ContentSettingsAgent is available just like we have done in other places like BraveSessionCache
? I'm fine following up with something like this and also #25505 (comment) but I think it's something we should do because this seems a bit out of place to me.
rfh->GetRemoteAssociatedInterfaces()->GetInterface(&agent); | ||
agent->SetShieldsSettings(brave_shields::mojom::ShieldsSettings::New( | ||
farbling_level, allowed_scripts_, | ||
brave_shields::IsReduceLanguageEnabledForProfile(pref_service))); |
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.
IsReduceLanguageEnabledForProfile seems like it belongs in BraveRendererUpdater ?
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.
data passed by BraveRendererUpdater
is not accessible by blink internals.
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.
not directly, but it could be exposed through our own class just like we have done in other places
patches/chrome-renderer-worker_content_settings_client.cc.patch
Outdated
Show resolved
Hide resolved
[puLL-Merge] - brave/brave-core@25505 DescriptionThis PR modifies the handling of Brave Shields settings, particularly for worker contexts. It introduces a new ChangesChanges
Possible Issues
Security Hotspots
|
This PR introduces a mojo structure to pass Shields settings to the renderer. This is part of the work to support per-site farbling.
Resolves brave/brave-browser#41023
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: