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

Applied Shields v2 UX to settings and shields panel and use FP V2 by default #5684

Merged
merged 4 commits into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions app/brave_generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,13 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U
Advanced view
</message>
<message name="IDS_SETTINGS_BRAVE_SHIELDS_AD_CONTROL_LABEL" desc="Default Brave block cross-site trackers control setting label">
Block trackers &amp; ads
Trackers &amp; ads blocking
</message>
<message name="IDS_SETTINGS_BRAVE_SHIELDS_COOKIE_CONTROL_LABEL" desc="Default Brave cookies control setting label">
Cookies
Cookie blocking
</message>
<message name="IDS_SETTINGS_BRAVE_SHIELDS_FINGERPRINTING_CONTROL_LABEL" desc="Default Brave fingerprinting control setting label">
Fingerprinting
Fingerprinting blocking
</message>
<message name="IDS_SETTINGS_BRAVE_SHIELDS_HTTPS_EVERYWHERE_CONTROL_LABEL" desc="Default Brave upgrade connections to HTTPS control setting label">
Upgrade connections to HTTPS
Expand All @@ -412,31 +412,31 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U
Allow LinkedIn embedded posts
</message>
<message name="IDS_SETTINGS_BLOCK_ADS_TRACKERS_AGGRESSIVE" desc="Select value">
Trackers &amp; ads blocked (aggressive)
Aggressive
</message>
<message name="IDS_SETTINGS_BLOCK_ADS_TRACKERS_STANDARD" desc="Select value">
Trackers &amp; ads blocked (standard)
Standard
</message>
<message name="IDS_SETTINGS_ALLOW_ADS_TRACKERS" desc="Select value">
Allow all trackers &amp; ads
Disabled
</message>
<message name="IDS_SETTINGS_BLOCK_3RD_PARTY_COOKIES" desc="Select value">
Only block cross-site cookies
Only cross-site
</message>
<message name="IDS_SETTINGS_ALLOW_ALL_COOKIES" desc="Select value">
Allow all cookies
Disabled
</message>
<message name="IDS_SETTINGS_BLOCK_ALL_COOKIES" desc="Select value">
Block all cookies
All
</message>
<message name="IDS_SETTINGS_BLOCK_3RD_PARTY_FINGERPRINTING" desc="Select value">
Block cross-site fingerprinting
<message name="IDS_SETTINGS_STANDARD_FINGERPRINTING" desc="Select value">
Standard
</message>
<message name="IDS_SETTINGS_ALLOW_FINGERPRINTING" desc="Select value">
Allow all fingerprinting
<message name="IDS_SETTINGS_ALLOW_ALL_FINGERPRINTING" desc="Select value">
Disabled
</message>
<message name="IDS_SETTINGS_BLOCK_FINGERPRINTING" desc="Select value">
Block all fingerprinting
<message name="IDS_SETTINGS_STRICT_FINGERPRINTING" desc="Select value">
Strict, may break sites
</message>
<!-- WebRTC Policy Setting -->
<message name="IDS_SETTINGS_WEBRTC_POLICY_LABEL" desc="WebRTC policy setting label">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ TEST_F(BraveBrowsingDataRemoverDelegateTest, ShieldsSettingsClearTest) {
brave_shields::kHTTPUpgradableResources, CONTENT_SETTING_ALLOW);
map()->SetContentSettingDefaultScope(
kBatURL, GURL(), ContentSettingsType::PLUGINS,
brave_shields::kFingerprinting, CONTENT_SETTING_ALLOW);
brave_shields::kFingerprintingV2, CONTENT_SETTING_ALLOW);
map()->SetContentSettingCustomScope(
brave_shields::GetPatternFromURL(kGoogleURL),
ContentSettingsPattern::Wildcard(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ TEST_F(BraveSiteSettingsCounterTest, Count) {
brave_shields::kHTTPUpgradableResources, CONTENT_SETTING_ALLOW);
map()->SetContentSettingDefaultScope(
kBatURL, GURL(), ContentSettingsType::PLUGINS,
brave_shields::kFingerprinting, CONTENT_SETTING_ALLOW);
brave_shields::kFingerprintingV2, CONTENT_SETTING_ALLOW);
map()->SetContentSettingCustomScope(
brave_shields::GetPatternFromURL(kGoogleURL),
ContentSettingsPattern::Wildcard(),
Expand Down
3 changes: 2 additions & 1 deletion browser/extensions/api/brave_shields_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,8 @@ BraveShieldsGetFingerprintingControlTypeFunction::Run() {

Profile* profile = Profile::FromBrowserContext(browser_context());
auto type = ::brave_shields::GetFingerprintingControlType(profile, url);
auto result = std::make_unique<base::Value>(ControlTypeToString(type));
auto result =
std::make_unique<base::Value>(ControlTypeToString(type));

return RespondNow(OneArgument(std::move(result)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ Polymer({
type: Array,
value: function() {
return [
{value: 'block_third_party', name: loadTimeData.getString('block3rdPartyCookies')},
{value: 'block', name: loadTimeData.getString('blockAllCookies')},
{value: 'block_third_party', name: loadTimeData.getString('block3rdPartyCookies')},
{value: 'allow', name: loadTimeData.getString('allowAllCookies')}
]
}
Expand All @@ -42,8 +42,8 @@ Polymer({
type: Array,
value: function() {
return [
{value: 'block_third_party', name: loadTimeData.getString('block3rdPartyFingerprinting')},
{value: 'block', name: loadTimeData.getString('blockAllFingerprinting')},
{value: 'block', name: loadTimeData.getString('strictFingerprinting')},
{value: 'default', name: loadTimeData.getString('standardFingerprinting')},
{value: 'allow', name: loadTimeData.getString('allowAllFingerprinting')}
]
}
Expand Down
7 changes: 4 additions & 3 deletions browser/ui/webui/settings/default_brave_shields_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,10 @@ void DefaultBraveShieldsHandler::SetFingerprintingControlType(
std::string value;
args->GetString(0, &value);

brave_shields::SetFingerprintingControlType(profile_,
ControlTypeFromString(value),
GURL());
brave_shields::SetFingerprintingControlType(
profile_,
ControlTypeFromString(value),
GURL());
}

void DefaultBraveShieldsHandler::SetHTTPSEverywhereEnabled(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ void BraveAddCommonStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_ALLOW_ALL_COOKIES},
{"blockAllCookies",
IDS_SETTINGS_BLOCK_ALL_COOKIES},
{"block3rdPartyFingerprinting",
IDS_SETTINGS_BLOCK_3RD_PARTY_FINGERPRINTING},
{"standardFingerprinting",
IDS_SETTINGS_STANDARD_FINGERPRINTING},
{"allowAllFingerprinting",
IDS_SETTINGS_ALLOW_FINGERPRINTING},
{"blockAllFingerprinting",
IDS_SETTINGS_BLOCK_FINGERPRINTING},
IDS_SETTINGS_ALLOW_ALL_FINGERPRINTING},
{"strictFingerprinting",
IDS_SETTINGS_STRICT_FINGERPRINTING},
{"webRTCPolicyLabel",
IDS_SETTINGS_WEBRTC_POLICY_LABEL},
{"webRTCPolicySubLabel",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,13 @@

#include "base/feature_list.h"
#include "brave/components/brave_shields/common/brave_shield_constants.h"
#include "brave/components/brave_shields/common/features.h"

#define BRAVE_GET_RENDER_CONTENT_SETTING_RULES \
map->GetSettingsForOneType(ContentSettingsType::AUTOPLAY, \
ResourceIdentifier(), &(rules->autoplay_rules)); \
if (base::FeatureList::IsEnabled( \
brave_shields::features::kFingerprintingProtectionV2)) { \
map->GetSettingsForOneType(ContentSettingsType::PLUGINS, \
brave_shields::kFingerprintingV2, \
&(rules->fingerprinting_rules)); \
} else { \
map->GetSettingsForOneType(ContentSettingsType::PLUGINS, \
brave_shields::kFingerprinting, \
&(rules->fingerprinting_rules)); \
} \
map->GetSettingsForOneType(ContentSettingsType::PLUGINS, \
brave_shields::kFingerprintingV2, \
&(rules->fingerprinting_rules)); \
map->GetSettingsForOneType(ContentSettingsType::PLUGINS, \
brave_shields::kBraveShields, \
&(rules->brave_shields_rules));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@
"message": "All cookies allowed",
"description": "Message for the option in the cookies select field to allow all cookies"
},
"thirdPartyFingerprintingBlocked": {
"message": "Cross-site fingerprinting blocked",
"standardFingerprinting": {
"message": "Fingerprinting blocked (standard)",
"description": "Message for the option in the fingerprinting select field to block all 3rd party recognition attempts"
},
"allFingerprintingBlocked": {
"message": "Fingerprinting attempts blocked",
"strictFingerprinting": {
"message": "Fingerprinting blocked (strict, may break sites)",
"description": "Message for the option in the fingerprinting select field to block all fingerprinting attempts"
},
"allFingerprintingAllowed": {
"message": "All fingerprinting attempts allowed",
"allowAllFingerprinting": {
"message": "Allow all fingerprinting",
"description": "Message for the option in the fingerprinting select field to allow all fingerprinting attempts"
},
"deviceRecognitionAttempts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export default class CookiesControl extends React.PureComponent<Props, {}> {
value={cookies}
onChange={this.onChangeBlockCookies}
>
<option value='block_third_party'>{getLocale('thirdPartyCookiesBlocked')}</option>
<option value='block'>{getLocale('allCookiesBlocked')}</option>
<option value='block_third_party'>{getLocale('thirdPartyCookiesBlocked')}</option>
<option value='allow'>{getLocale('allCookiesAllowed')}</option>
</SelectBox>
</BlockedInfoRowSingle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ export default class DeviceRecognitionControl extends React.PureComponent<Props,
value={fingerprinting}
onChange={this.onChangeBlockDeviceRecognition}
>
<option value='block_third_party'>{getLocale('thirdPartyFingerprintingBlocked')}</option>
<option value='block'>{getLocale('allFingerprintingBlocked')}</option>
<option value='allow'>{getLocale('allFingerprintingAllowed')}</option>
<option value='block'>{getLocale('strictFingerprinting')}</option>
<option value='default'>{getLocale('standardFingerprinting')}</option>
<option value='allow'>{getLocale('allowAllFingerprinting')}</option>
</SelectBox>
</BlockedInfoRowForSelect>
{
Expand Down
53 changes: 11 additions & 42 deletions components/brave_shields/browser/brave_shields_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -333,55 +333,24 @@ void SetFingerprintingControlType(Profile* profile,
return;

auto* map = HostContentSettingsMapFactory::GetForProfile(profile);
if (base::FeatureList::IsEnabled(
features::kFingerprintingProtectionV2)) {
map->SetContentSettingCustomScope(
primary_pattern, ContentSettingsPattern::Wildcard(),
ContentSettingsType::PLUGINS, kFingerprintingV2,
GetDefaultAllowFromControlType(type));
} else {
map->SetContentSettingCustomScope(
primary_pattern, ContentSettingsPattern::Wildcard(),
ContentSettingsType::PLUGINS, kFingerprinting,
GetDefaultBlockFromControlType(type));

map->SetContentSettingCustomScope(
primary_pattern,
ContentSettingsPattern::FromString("https://firstParty/*"),
ContentSettingsType::PLUGINS, kFingerprinting,
GetDefaultAllowFromControlType(type));
}
map->SetContentSettingCustomScope(
primary_pattern, ContentSettingsPattern::Wildcard(),
ContentSettingsType::PLUGINS, kFingerprintingV2,
GetDefaultAllowFromControlType(type));

RecordShieldsSettingChanged();
}

ControlType GetFingerprintingControlType(Profile* profile, const GURL& url) {
auto* map = HostContentSettingsMapFactory::GetForProfile(profile);

if (base::FeatureList::IsEnabled(
features::kFingerprintingProtectionV2)) {
ContentSetting setting = map->GetContentSetting(
url, GURL(), ContentSettingsType::PLUGINS, kFingerprintingV2);
if (setting == CONTENT_SETTING_BLOCK) {
return ControlType::BLOCK;
} else if (setting == CONTENT_SETTING_ALLOW) {
return ControlType::ALLOW;
}
return ControlType::DEFAULT;
} else {
ContentSetting setting = map->GetContentSetting(
url, GURL(), ContentSettingsType::PLUGINS, kFingerprinting);
ContentSetting fp_setting =
map->GetContentSetting(url, GURL("https://firstParty/"),
ContentSettingsType::PLUGINS, kFingerprinting);

if (setting != fp_setting || setting == CONTENT_SETTING_DEFAULT) {
return ControlType::BLOCK_THIRD_PARTY;
} else {
return setting == CONTENT_SETTING_ALLOW ? ControlType::ALLOW
: ControlType::BLOCK;
}
ContentSetting setting = map->GetContentSetting(
url, GURL(), ContentSettingsType::PLUGINS, kFingerprintingV2);
if (setting == CONTENT_SETTING_BLOCK) {
return ControlType::BLOCK;
} else if (setting == CONTENT_SETTING_ALLOW) {
return ControlType::ALLOW;
}
return ControlType::DEFAULT;
}

void SetHTTPSEverywhereEnabled(Profile* profile,
Expand Down
Loading