Merge pull request #2149 from brave/ca-shields-settings

Use same labels on Shields global settings and panel
This commit is contained in:
Brian Clifton
2019-06-12 01:17:23 -05:00
committed by GitHub
11 changed files with 99 additions and 94 deletions
+22 -22
View File
@@ -280,28 +280,34 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U
Shields
</message>
<message name="IDS_SETTINGS_BRAVE_SHIELDS_DEFAULTS_TITLE" desc="The title for Brave shields Defaults sub-section in settings">
Defaults
Block trackers and ads which follow you across the web.
</message>
<message name="IDS_SETTINGS_BRAVE_SHIELDS_DEFAULTS_DESCRIPTION" desc="The description for Brave shields Defaults sub-section in settings">
Your current per-site settings will be retained.
<message name="IDS_SETTINGS_BRAVE_SHIELDS_DEFAULTS_DESCRIPTION_1" desc="The description for Brave shields Defaults sub-section in settings">
These are the default Shields settings. They apply to all websites unless you change something in the Shields panel on a particular site. Changing these won't affect your existing per-site settings.
</message>
<message name="IDS_SETTINGS_BRAVE_SHIELDS_DEFAULTS_DESCRIPTION_2" desc="The partial description for Brave shields Defaults sub-section in settings. The sentence is completed with `Brave rewards settings`">
This will block most ads on websites, not Brave private ads — those are controlled in the
</message>
<message name="IDS_SETTINGS_BRAVE_SHIELDS_DEFAULTS_DESCRIPTION_3" desc="The partial description for Brave shields Defaults sub-section in settings. Partial of `This will block most ads on websites, not Brave private ads — those are controlled in the Brave Rewards (settings)`">
settings.
</message>
<message name="IDS_SETTINGS_SOCIAL_BLOCKING_DEFAULTS_TITLE" desc="The title the settings section which has options for blocking third-party embeds, commonly from social media sites">
Social media blocking
</message>
<message name="IDS_SETTINGS_BRAVE_SHIELDS_AD_CONTROL_LABEL" desc="Default Brave ad control setting label">
Ad control
<message name="IDS_SETTINGS_BRAVE_SHIELDS_AD_CONTROL_LABEL" desc="Default Brave block cross-site trackers control setting label">
Block cross-site trackers
</message>
<message name="IDS_SETTINGS_BRAVE_SHIELDS_COOKIE_CONTROL_LABEL" desc="Default Brave cookie control setting label">
Cookie control
<message name="IDS_SETTINGS_BRAVE_SHIELDS_COOKIE_CONTROL_LABEL" desc="Default Brave cookies control setting label">
Cookies
</message>
<message name="IDS_SETTINGS_BRAVE_SHIELDS_FINGERPRINTING_CONTROL_LABEL" desc="Default Brave fingerprinting control setting label">
Fingerprinting protection
<message name="IDS_SETTINGS_BRAVE_SHIELDS_FINGERPRINTING_CONTROL_LABEL" desc="Default Brave device recognition control setting label">
Device recognition
</message>
<message name="IDS_SETTINGS_BRAVE_SHIELDS_HTTPS_EVERYWHERE_CONTROL_LABEL" desc="Default Brave HTTPS Everywhere control setting label">
HTTPS Everywhere
<message name="IDS_SETTINGS_BRAVE_SHIELDS_HTTPS_EVERYWHERE_CONTROL_LABEL" desc="Default Brave upgrade connections to HTTPS control setting label">
Upgrade connections to HTTPS
</message>
<message name="IDS_SETTINGS_BRAVE_SHIELDS_NO_SCRIPT_CONTROL_LABEL" desc="Default Brave script blocking control setting label">
Script blocking
Block scripts
</message>
<message name="IDS_SETTINGS_BRAVE_SHIELDS_GOOGLE_LOGIN_LABEL" desc="Label for a switch control which allows Google social buttons to be enabled/disabled">
Allow Google login buttons on third party sites
@@ -315,14 +321,8 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U
<message name="IDS_SETTINGS_BRAVE_SHIELDS_LINKEDIN_EMBEDDED_POSTS_LABEL" desc="Label for a switch control which allows LinkedIn embedded posts">
Allow LinkedIn embedded posts
</message>
<message name="IDS_SETTINGS_BLOCK_ADS" desc="Select value">
Block ads
</message>
<message name="IDS_SETTINGS_ALLOW_ADS_AND_TRACKING" desc="Select value">
Allow ads and tracking
</message>
<message name="IDS_SETTINGS_BLOCK_3RD_PARTY_COOKIES" desc="Select value">
Block 3rd party cookies
Only block cross-site cookies
</message>
<message name="IDS_SETTINGS_ALLOW_ALL_COOKIES" desc="Select value">
Allow all cookies
@@ -331,13 +331,13 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U
Block all cookies
</message>
<message name="IDS_SETTINGS_BLOCK_3RD_PARTY_FINGERPRINTING" desc="Select value">
Block 3rd party fingerprinting
Only block cross-site device recognition attempts
</message>
<message name="IDS_SETTINGS_ALLOW_FINGERPRINTING" desc="Select value">
Allow fingerprinting
Allow all device recognition attempts
</message>
<message name="IDS_SETTINGS_BLOCK_FINGERPRINTING" desc="Select value">
Block all fingerprinting
Block all device recognition attempts
</message>
<!-- WebRTC Policy Setting -->
<message name="IDS_SETTINGS_WEBRTC_POLICY_LABEL" desc="WebRTC policy setting label">
+1
View File
@@ -49,6 +49,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
// Default Brave shields
registry->RegisterBooleanPref(kHTTPSEVerywhereControlType, true);
registry->RegisterBooleanPref(kNoScriptControlType, false);
registry->RegisterBooleanPref(kAdControlType, true);
registry->RegisterBooleanPref(kGoogleLoginControlType, true);
registry->RegisterBooleanPref(kFBEmbedControlType, true);
registry->RegisterBooleanPref(kTwitterEmbedControlType, true);
@@ -29,6 +29,8 @@ IN_PROC_BROWSER_TEST_F(BraveProfilePrefsBrowserTest, MiscBravePrefs) {
kHTTPSEVerywhereControlType));
EXPECT_FALSE(
browser()->profile()->GetPrefs()->GetBoolean(kNoScriptControlType));
EXPECT_TRUE(
browser()->profile()->GetPrefs()->GetBoolean(kAdControlType));
EXPECT_TRUE(
browser()->profile()->GetPrefs()->GetBoolean(kGoogleLoginControlType));
EXPECT_TRUE(
@@ -35,6 +35,8 @@ const PrefsUtil::TypedPrefMap& BravePrefsUtil::GetWhitelistedKeys() {
(*s_brave_whitelist)[::prefs::kImportDialogWindows] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
// Default Brave shields
(*s_brave_whitelist)[kAdControlType] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_brave_whitelist)[kHTTPSEVerywhereControlType] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_brave_whitelist)[kNoScriptControlType] =
@@ -15,25 +15,34 @@
padding-top: 1em;
font-size: 1.05em;
}
.label.shields-secondary-title {
padding-bottom: 1em;
}
</style>
<div class="settings-box first">
<div class="flex">
<div class="label shields-primary-title">$i18n{braveShieldsDefaultsSectionTitle}</div>
<div class="label secondary shields-secondary-title">$i18n{braveShieldsDefaultsSectionDescription}</div>
<div class="label secondary shields-secondary-title">
<p>$i18n{braveShieldsDefaultsSectionDescription1}</p>
<p>$i18n{braveShieldsDefaultsSectionDescription2} <a href="chrome://rewards" target="_blank">Brave Rewards</a> $i18n{braveShieldsDefaultsSectionDescription3}</p>
</div>
</div>
</div>
<div class="settings-box continuation">
<div class="start">$i18n{adControlLabel}</div>
<select id="adControlType" class="md-select"
on-change="onAdControlChange_">
<template is="dom-repeat" items="[[adControlTypes_]]">
<option value="[[item.value]]"
selected="[[controlEqual(item.value, adControlType_)]]">
[[item.name]]
</option>
</template>
</select>
</div>
<settings-toggle-button id="adControlType"
pref="{{prefs.brave.ad_default}}"
label="$i18n{adControlLabel}"
on-settings-boolean-control-change="onAdControlChange_">
</settings-toggle-button>
<settings-toggle-button id="httpsEverywhereControlType"
pref="{{prefs.brave.https_everywhere_default}}"
label="$i18n{httpsEverywhereControlLabel}"
on-settings-boolean-control-change="onHTTPSEverywhereControlChange_">
</settings-toggle-button>
<settings-toggle-button id="noScriptControlType"
pref="{{prefs.brave.no_script_default}}"
label="$i18n{noScriptControlLabel}"
on-settings-boolean-control-change="onNoScriptControlChange_">
</settings-toggle-button>
<div class="settings-box">
<div class="start">$i18n{cookieControlLabel}</div>
<select id="cookieControlType" class="md-select"
@@ -58,16 +67,6 @@
</template>
</select>
</div>
<settings-toggle-button id="httpsEverywhereControlType"
pref="{{prefs.brave.https_everywhere_default}}"
label="$i18n{httpsEverywhereControlLabel}"
on-settings-boolean-control-change="onHTTPSEverywhereControlChange_">
</settings-toggle-button>
<settings-toggle-button id="noScriptControlType"
pref="{{prefs.brave.no_script_default}}"
label="$i18n{noScriptControlLabel}"
on-settings-boolean-control-change="onNoScriptControlChange_">
</settings-toggle-button>
</template>
<script src="default_brave_shields_page.js"></script>
</dom-module>
@@ -13,17 +13,6 @@ Polymer({
is: 'settings-default-brave-shields-page',
properties: {
adControlTypes_: {
readOnly: true,
type: Array,
value: function() {
return [
{value: 'block', name: loadTimeData.getString('blockAds')},
{value: 'allow', name: loadTimeData.getString('allowAdsAndTracking')}
]
}
},
cookieControlTypes_: {
readOnly: true,
type: Array,
@@ -48,7 +37,6 @@ Polymer({
}
},
adControlType_: String,
cookieControlType_: String,
fingerprintingControlType_: String,
},
@@ -69,9 +57,6 @@ Polymer({
this.onHTTPSEverywhereControlChange_ = this.onHTTPSEverywhereControlChange_.bind(this)
this.onNoScriptControlChange_ = this.onNoScriptControlChange_.bind(this)
this.browserProxy_.getAdControlType().then(value => {
this.adControlType_= value;
});
this.browserProxy_.getCookieControlType().then(value => {
this.cookieControlType_ = value;
});
@@ -91,7 +76,7 @@ Polymer({
},
onAdControlChange_: function() {
this.browserProxy_.setAdControlType(this.$.adControlType.value);
this.browserProxy_.setAdControlType(this.$.adControlType.checked);
},
onCookieControlChange_: function() {
this.browserProxy_.setCookieControlType(this.$.cookieControlType.value);
@@ -1,4 +1,5 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* Copyright (c) 2019 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
@@ -36,16 +37,19 @@ void DefaultBraveShieldsHandler::RegisterMessages() {
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"getFingerprintingControlType",
base::BindRepeating(&DefaultBraveShieldsHandler::GetFingerprintingControlType,
base::Unretained(this)));
base::BindRepeating(
&DefaultBraveShieldsHandler::GetFingerprintingControlType,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"setFingerprintingControlType",
base::BindRepeating(&DefaultBraveShieldsHandler::SetFingerprintingControlType,
base::Unretained(this)));
base::BindRepeating(
&DefaultBraveShieldsHandler::SetFingerprintingControlType,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"setHTTPSEverywhereControlType",
base::BindRepeating(&DefaultBraveShieldsHandler::SetHTTPSEverywhereControlType,
base::Unretained(this)));
base::BindRepeating(
&DefaultBraveShieldsHandler::SetHTTPSEverywhereControlType,
base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"setNoScriptControlType",
base::BindRepeating(&DefaultBraveShieldsHandler::SetNoScriptControlType,
@@ -63,14 +67,14 @@ void DefaultBraveShieldsHandler::GetAdControlType(const base::ListValue* args) {
AllowJavascript();
ResolveJavascriptCallback(
args->GetList()[0].Clone(),
base::Value(setting == CONTENT_SETTING_ALLOW ? "allow" : "block"));
base::Value(setting == CONTENT_SETTING_ALLOW));
}
void DefaultBraveShieldsHandler::SetAdControlType(const base::ListValue* args) {
CHECK_EQ(args->GetSize(), 1U);
CHECK(profile_);
std::string value;
args->GetString(0, &value);
bool value;
args->GetBoolean(0, &value);
HostContentSettingsMapFactory::GetForProfile(profile_)->
SetContentSettingCustomScope(
@@ -78,26 +82,29 @@ void DefaultBraveShieldsHandler::SetAdControlType(const base::ListValue* args) {
ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_PLUGINS,
brave_shields::kAds,
value == "allow" ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK);
value ? CONTENT_SETTING_BLOCK : CONTENT_SETTING_ALLOW);
HostContentSettingsMapFactory::GetForProfile(profile_)->
SetContentSettingCustomScope(
ContentSettingsPattern::Wildcard(),
ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_PLUGINS,
brave_shields::kTrackers,
value == "allow" ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK);
value ? CONTENT_SETTING_BLOCK : CONTENT_SETTING_ALLOW);
}
void DefaultBraveShieldsHandler::GetCookieControlType(const base::ListValue* args) {
void DefaultBraveShieldsHandler::GetCookieControlType(
const base::ListValue* args) {
CHECK_EQ(args->GetSize(), 1U);
CHECK(profile_);
ContentSetting setting =
HostContentSettingsMapFactory::GetForProfile(profile_)->GetContentSetting(
GURL(), GURL(), CONTENT_SETTINGS_TYPE_PLUGINS, brave_shields::kCookies);
GURL(), GURL(), CONTENT_SETTINGS_TYPE_PLUGINS,
brave_shields::kCookies);
ContentSetting fp_setting =
HostContentSettingsMapFactory::GetForProfile(profile_)->GetContentSetting(
GURL(), GURL("https://firstParty/"), CONTENT_SETTINGS_TYPE_PLUGINS, brave_shields::kCookies);
GURL(), GURL("https://firstParty/"), CONTENT_SETTINGS_TYPE_PLUGINS,
brave_shields::kCookies);
std::string value = "block";
if (setting == CONTENT_SETTING_ALLOW) {
@@ -112,7 +119,8 @@ void DefaultBraveShieldsHandler::GetCookieControlType(const base::ListValue* arg
base::Value(value));
}
void DefaultBraveShieldsHandler::SetCookieControlType(const base::ListValue* args) {
void DefaultBraveShieldsHandler::SetCookieControlType(
const base::ListValue* args) {
CHECK_EQ(args->GetSize(), 1U);
CHECK(profile_);
std::string value;
@@ -141,16 +149,19 @@ void DefaultBraveShieldsHandler::SetCookieControlType(const base::ListValue* arg
value == "block" ? CONTENT_SETTING_BLOCK : CONTENT_SETTING_ALLOW);
}
void DefaultBraveShieldsHandler::GetFingerprintingControlType(const base::ListValue* args) {
void DefaultBraveShieldsHandler::GetFingerprintingControlType(
const base::ListValue* args) {
CHECK_EQ(args->GetSize(), 1U);
CHECK(profile_);
ContentSetting setting =
HostContentSettingsMapFactory::GetForProfile(profile_)->GetContentSetting(
GURL(), GURL(), CONTENT_SETTINGS_TYPE_PLUGINS, brave_shields::kFingerprinting);
GURL(), GURL(), CONTENT_SETTINGS_TYPE_PLUGINS,
brave_shields::kFingerprinting);
ContentSetting fp_setting =
HostContentSettingsMapFactory::GetForProfile(profile_)->GetContentSetting(
GURL(), GURL("https://firstParty/"), CONTENT_SETTINGS_TYPE_PLUGINS, brave_shields::kFingerprinting);
GURL(), GURL("https://firstParty/"), CONTENT_SETTINGS_TYPE_PLUGINS,
brave_shields::kFingerprinting);
std::string value;
if (setting != fp_setting || setting == CONTENT_SETTING_DEFAULT) {
@@ -165,7 +176,8 @@ void DefaultBraveShieldsHandler::GetFingerprintingControlType(const base::ListVa
base::Value(value));
}
void DefaultBraveShieldsHandler::SetFingerprintingControlType(const base::ListValue* args) {
void DefaultBraveShieldsHandler::SetFingerprintingControlType(
const base::ListValue* args) {
CHECK_EQ(args->GetSize(), 1U);
CHECK(profile_);
std::string value;
@@ -187,7 +199,8 @@ void DefaultBraveShieldsHandler::SetFingerprintingControlType(const base::ListVa
value == "block" ? CONTENT_SETTING_BLOCK : CONTENT_SETTING_ALLOW);
}
void DefaultBraveShieldsHandler::SetHTTPSEverywhereControlType(const base::ListValue* args) {
void DefaultBraveShieldsHandler::SetHTTPSEverywhereControlType(
const base::ListValue* args) {
CHECK_EQ(args->GetSize(), 1U);
CHECK(profile_);
bool value;
@@ -202,7 +215,8 @@ void DefaultBraveShieldsHandler::SetHTTPSEverywhereControlType(const base::ListV
value ? CONTENT_SETTING_BLOCK : CONTENT_SETTING_ALLOW);
}
void DefaultBraveShieldsHandler::SetNoScriptControlType(const base::ListValue* args) {
void DefaultBraveShieldsHandler::SetNoScriptControlType(
const base::ListValue* args) {
CHECK_EQ(args->GetSize(), 1U);
CHECK(profile_);
bool value;
@@ -58,8 +58,12 @@ void BraveAddCommonStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_BRAVE_SHIELDS_TITLE},
{"braveShieldsDefaultsSectionTitle",
IDS_SETTINGS_BRAVE_SHIELDS_DEFAULTS_TITLE},
{"braveShieldsDefaultsSectionDescription",
IDS_SETTINGS_BRAVE_SHIELDS_DEFAULTS_DESCRIPTION},
{"braveShieldsDefaultsSectionDescription1",
IDS_SETTINGS_BRAVE_SHIELDS_DEFAULTS_DESCRIPTION_1},
{"braveShieldsDefaultsSectionDescription2",
IDS_SETTINGS_BRAVE_SHIELDS_DEFAULTS_DESCRIPTION_2},
{"braveShieldsDefaultsSectionDescription3",
IDS_SETTINGS_BRAVE_SHIELDS_DEFAULTS_DESCRIPTION_3},
{"socialBlocking",
IDS_SETTINGS_SOCIAL_BLOCKING_DEFAULTS_TITLE},
{"adControlLabel",
@@ -80,10 +84,6 @@ void BraveAddCommonStrings(content::WebUIDataSource* html_source,
IDS_SETTINGS_BRAVE_SHIELDS_TWITTER_EMBEDDED_TWEETS_LABEL},
{"linkedInEmbedControlLabel",
IDS_SETTINGS_BRAVE_SHIELDS_LINKEDIN_EMBEDDED_POSTS_LABEL},
{"blockAds",
IDS_SETTINGS_BLOCK_ADS},
{"allowAdsAndTracking",
IDS_SETTINGS_ALLOW_ADS_AND_TRACKING},
{"block3rdPartyCookies",
IDS_SETTINGS_BLOCK_3RD_PARTY_COOKIES},
{"allowAllCookies",
+1
View File
@@ -40,6 +40,7 @@ const char kReferralCheckedForPromoCodeFile[] =
"brave.referral.checked_for_promo_code_file";
const char kHTTPSEVerywhereControlType[] = "brave.https_everywhere_default";
const char kNoScriptControlType[] = "brave.no_script_default";
const char kAdControlType[] = "brave.ad_default";
const char kGoogleLoginControlType[] = "brave.google_login_default";
const char kFBEmbedControlType[] = "brave.fb_embed_default";
const char kTwitterEmbedControlType[] = "brave.twitter_embed_default";
+1
View File
@@ -35,6 +35,7 @@ extern const char kReferralHeaders[];
extern const char kReferralCheckedForPromoCodeFile[];
extern const char kHTTPSEVerywhereControlType[];
extern const char kNoScriptControlType[];
extern const char kAdControlType[];
extern const char kGoogleLoginControlType[];
extern const char kFBEmbedControlType[];
extern const char kTwitterEmbedControlType[];
@@ -48,7 +48,7 @@
"description": "Message for the main blocked resources text when there is at least one ad/track/script blocked and one connection upgrade (singular)"
},
"thirdPartyTrackersBlocked": {
"message": "3rd-party trackers blocked",
"message": "Cross-site trackers blocked",
"description": "Message for the scripts blocked row label"
},
"connectionsUpgradedHTTPS": {
@@ -64,7 +64,7 @@
"description": "Message for the scripts blocked row label"
},
"thirdPartyCookiesBlocked": {
"message": "3rd-party cookies blocked",
"message": "Cross-site cookies blocked",
"description": "Message for the option in the cookies select field to block all 3rd party cookies"
},
"allCookiesBlocked": {
@@ -76,15 +76,15 @@
"description": "Message for the option in the cookies select field to allow all cookies"
},
"thirdPartyFingerprintingBlocked": {
"message": "3rd-party device recognition blocked",
"message": "Cross-site device recognition blocked",
"description": "Message for the option in the device recognition select field to block all 3rd party recognition attempts"
},
"allFingerprintingBlocked": {
"message": "Device recognition blocked",
"message": "Device recognition attempts blocked",
"description": "Message for the option in the device recognition select field to block all device recognition attempts"
},
"allFingerprintingAllowed": {
"message": "All device recognition allowed",
"message": "All device recognition attempts allowed",
"description": "Message for the option in the device recognition select field to allow all device recognition attempts"
},
"deviceRecognitionAttempts": {