-
Notifications
You must be signed in to change notification settings - Fork 820
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 Shields domain-specific ad/fingerprint block setting questions #12583
Conversation
RecordShieldsFingerprintSetting(global_fp_setting); | ||
|
||
ShieldsSettingCounts fp_counts = GetFPSettingCount(map); | ||
ShieldsSettingCounts ads_counts = GetAdsSettingCount(map); |
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.
When performing the first recording of the metrics for a given profile, the domain-specific settings are counted by iterating through the HostContentSettingsMap rules. This will ensure that any settings made by the user before the browser upgrade will be accounted for in the metrics.
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 comment in the code
<< GetDomainSettingCount(profile_prefs, is_fingerprint, | ||
*prev_setting); | ||
} | ||
UpdateDomainSettingCount(profile_prefs, is_fingerprint, new_setting, 1); |
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.
Any changes made to the domain-specific settings will be recorded in internal counts stored in the profile preferences. We keep a count of domains for each setting value. When a user changes a setting for a domain, we decrement the count for the previous setting value (if one existed), and increment the count for the new setting value. This is less costly compared to iterating through the HostContentSettingsMap rules every time a user changes a setting.
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.
can you please put this comment into the code
if (url.is_empty()) { | ||
// If global setting changed, report to P3A | ||
RecordShieldsFingerprintSetting(type); | ||
if (!map->IsOffTheRecord()) { |
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 is important that we ignore any domain-specific changes made in the guest/incognito 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.
The policy looks good to me, but others would be better than me to review the implementation
4bd6752
to
d6d353e
Compare
@@ -92,6 +92,10 @@ constexpr const char* kCollectedHistograms[] = { | |||
"Brave.Shields.UsageStatus", | |||
"Brave.Shields.AdBlockSetting", | |||
"Brave.Shields.FingerprintBlockSetting", | |||
"Brave.Shields.DomainAdsSettingsAboveGlobal", |
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.
let's keep it sorted
d6d353e
to
b0a4e8e
Compare
@@ -56,6 +61,10 @@ AdBlockPrefService::AdBlockPrefService(AdBlockService* ad_block_service, | |||
OnPreferenceChanged(prefs::kFBEmbedControlType); | |||
OnPreferenceChanged(prefs::kTwitterEmbedControlType); | |||
OnPreferenceChanged(prefs::kLinkedInEmbedControlType); | |||
|
|||
if (is_regular_profile) { | |||
MaybeRecordInitialShieldsSettings(prefs, host_content_settings_map); |
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 don't really follow why do we need to pass all the stuff (HostContentSettingsMap, is_regular_profile) to this service (why this one?) just to record P3A. Am I missing something important about this specific location? Maybe we could do that around BraveProfileManager
that already has some P3A initialization?
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.
now that you point it out, i agree. moved the function call to browser/profiles/profile_util.cc
@@ -335,9 +334,6 @@ bool AdBlockService::Start() { | |||
regional_service_manager(); | |||
subscription_service_manager(); | |||
|
|||
MaybeRecordDefaultShieldsAdsSetting(local_state_); |
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 recording here doesn't work?
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 access to profile
Profile::FromBrowserContext(context)->GetPrefs()); | ||
g_brave_browser_process->ad_block_service(), profile->GetPrefs(), | ||
HostContentSettingsMapFactory::GetForProfile(profile), | ||
profile->IsRegularProfile() && !profile->IsGuestSession()); |
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 guess GuestSession is never Regular (see comments for IsRegularProfile()
)
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 general I'm not in favor of passing new things to this service just for P3A
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.
agreed, removed
@@ -335,12 +355,21 @@ bool AllowReferrers(HostContentSettingsMap* map, const GURL& url) { | |||
void SetFingerprintingControlType(HostContentSettingsMap* map, | |||
ControlType type, | |||
const GURL& url, | |||
PrefService* local_state) { | |||
PrefService* local_state, | |||
PrefService* profile_state) { |
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 not use local_state?
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.
or vice versa, erase local state and use only prefs
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.
Shields settings are per profile, so it may be best to store global/domain-specific setting counts on a per profile basis. The info from the last used profile will be transmitted at P3A report time.
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.
The only shields P3A function that uses local_state is MaybeRecordShieldsUsageP3A
, which was present before this PR. Perhaps it would be best to refactor that function to use profile prefs in a separate issue/PR
const ContentSettingsForOneType& ads_rules) { | ||
ShieldsSettingCounts result = {}; | ||
|
||
std::unordered_set<std::string> block_set; |
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.
using unordered_set
is discouraged in chromium, see https://chromium.googlesource.com/chromium/src/+show/master/base/containers/README.md#32
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.
switched to set
b0a4e8e
to
67de76a
Compare
c8f09f5
to
dfa29c6
Compare
dfa29c6
to
d9ebe58
Compare
@@ -15,6 +15,7 @@ | |||
|
|||
class PrefChangeRegistrar; | |||
class PrefService; | |||
class HostContentSettingsMap; |
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 needed
@@ -10,6 +10,7 @@ | |||
#include "brave/components/brave_shields/browser/ad_block_regional_service_manager.h" | |||
#include "brave/components/brave_shields/browser/ad_block_service.h" | |||
#include "brave/components/brave_shields/browser/ad_block_subscription_service_manager.h" | |||
#include "brave/components/brave_shields/browser/brave_shields_p3a.h" |
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 needed
@@ -7,6 +7,7 @@ | |||
|
|||
#include "brave/browser/brave_browser_process.h" | |||
#include "brave/components/brave_shields/browser/ad_block_pref_service.h" | |||
#include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
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 needed
d9ebe58
to
cb01fb3
Compare
@@ -239,16 +239,21 @@ void BraveShieldsDataController::SetAdBlockMode(AdBlockMode mode) { | |||
|
|||
if (mode == AdBlockMode::AGGRESSIVE) { | |||
control_type_cosmetic = ControlType::BLOCK; // aggressive | |||
} else { | |||
} else if (mode == AdBlockMode::STANDARD) { |
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 @antonok-edm
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 confirmed with @nullhook yesterday
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 change looks ok
cb01fb3
to
2e08e18
Compare
2e08e18
to
066a3dd
Compare
force-pushed a rebase |
Verification PASSED on
[Note: Discussed with @DJAndries, the fix is only for the adblocking "Allow". The other two settings "Aggressive" and "Block" give the same internal preferences values in both Case 1:Verify cosmetic filtering preference_ad blocking settings set to "Allow"
Case 2:Verify cosmetic filtering preference_ad blocking settings set to "Aggressive" |
@DJAndries I don't see any difference in cosmetic filtering preference for shields v1 and v2 when ad blocking settings are set to "Allow" or "Aggressive" or "Block". Compared the internal cosmetic filtering preferences in 1.37.x and 1.39.x. Just trying to understand what is fixed as part of this PR. Also, this PR is only for ad-blocking cosmetic filtering internal preferences? does it not applicable for Fingerprint and block cookies settings?
|
@GeetaSarvadnya it would be best to compare 1.39.53 against a slightly older version of nightly, since this bug is related to the new Shields UI, which is not available in 1.37.x. This PR involves both the ad-block/cosmetic filtering, and fingerprint blocking settings. However, the commit that addresses brave/brave-browser#22249 only involves the ad-block/cosmetic setting. |
Resolves brave/brave-browser#21546
Resolves brave/brave-browser#22064
Resolves brave/brave-browser#22063
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:
Brave.Shields.DomainAdsSettingsAboveGlobal
,Brave.Shields.DomainAdsSettingsBelowGlobal
,Brave.Shields.DomainFingerprintSettingsAboveGlobal
,Brave.Shields.DomainFingerprintSettingsBelowGlobal
all have values of 0 on thebrave://local-state
page.Brave.Shields.DomainAdsSettingsAboveGlobal
has a value of 1.Brave.Shields.DomainAdsSettingsBelowGlobal
has a value of 1, and thatBrave.Shields.DomainAdsSettingsAboveGlobal
still has a value of 1.Brave.Shields.DomainFingerprintSettingsAboveGlobal
has a value of 1.Brave.Shields.DomainFingerprintSettingsBelowGlobal
has a value of 1, and thatBrave.Shields.DomainFingerprintSettingsAboveGlobal
still has a value of 1.