-
Notifications
You must be signed in to change notification settings - Fork 894
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #436 from brave/default-brave-shields
Add default Brave shields
- Loading branch information
Showing
20 changed files
with
695 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
...er/resources/settings/default_brave_shields_page/default_brave_shields_browser_proxy.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<link rel="href" src="chrome://resources/html/cr.html"> | ||
<script src="default_brave_shields_browser_proxy.js"></script> |
97 changes: 97 additions & 0 deletions
97
browser/resources/settings/default_brave_shields_page/default_brave_shields_browser_proxy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* 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/. */ | ||
|
||
cr.define('settings', function() { | ||
/** @interface */ | ||
class DefaultBraveShieldsBrowserProxy { | ||
/** | ||
* @return {!Promise<string>} | ||
*/ | ||
getAdControlType() {} | ||
/** | ||
* @param {string} value name. | ||
*/ | ||
setAdControlType(value) {} | ||
|
||
/** | ||
* @return {!Promise<string>} | ||
*/ | ||
getCookieControlType() {} | ||
/** | ||
* @param {string} value name. | ||
*/ | ||
setCookieControlType(value) {} | ||
|
||
/** | ||
* @return {!Promise<string>} | ||
*/ | ||
getFingerprintingControlType() {} | ||
/** | ||
* @param {string} value name. | ||
*/ | ||
setFingerprintingControlType(value) {} | ||
|
||
/** | ||
* @param {string} value name. | ||
*/ | ||
setHTTPSEverywhereControlType(value) {} | ||
|
||
/** | ||
* @param {string} value name. | ||
*/ | ||
setNoScriptControlType(value) {} | ||
} | ||
|
||
/** | ||
* @implements {settings.DefaultBraveShieldsBrowserProxy} | ||
*/ | ||
class DefaultBraveShieldsBrowserProxyImpl { | ||
/** @override */ | ||
getAdControlType() { | ||
return cr.sendWithPromise('getAdControlType'); | ||
} | ||
|
||
/** @override */ | ||
setAdControlType(value) { | ||
chrome.send('setAdControlType', [value]); | ||
} | ||
|
||
/** @override */ | ||
getCookieControlType() { | ||
return cr.sendWithPromise('getCookieControlType'); | ||
} | ||
|
||
/** @override */ | ||
setCookieControlType(value) { | ||
chrome.send('setCookieControlType', [value]); | ||
} | ||
|
||
/** @override */ | ||
getFingerprintingControlType() { | ||
return cr.sendWithPromise('getFingerprintingControlType'); | ||
} | ||
|
||
/** @override */ | ||
setFingerprintingControlType(value) { | ||
chrome.send('setFingerprintingControlType', [value]); | ||
} | ||
|
||
/** @override */ | ||
setHTTPSEverywhereControlType(value) { | ||
chrome.send('setHTTPSEverywhereControlType', [value]); | ||
} | ||
|
||
/** @override */ | ||
setNoScriptControlType(value) { | ||
chrome.send('setNoScriptControlType', [value]); | ||
} | ||
} | ||
|
||
cr.addSingletonGetter(DefaultBraveShieldsBrowserProxyImpl); | ||
|
||
return { | ||
DefaultBraveShieldsBrowserProxy, | ||
DefaultBraveShieldsBrowserProxyImpl | ||
}; | ||
}); |
61 changes: 61 additions & 0 deletions
61
browser/resources/settings/default_brave_shields_page/default_brave_shields_page.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<link rel="import" href="chrome://resources/html/polymer.html"> | ||
|
||
<link rel="import" href="chrome://resources/html/i18n_behavior.html"> | ||
<link rel="import" href="chrome://resources/html/md_select_css.html"> | ||
<link rel="import" href="default_brave_shields_browser_proxy.html"> | ||
<link rel="import" href="../settings_shared_css.html"> | ||
<link rel="import" href="../settings_vars_css.html"> | ||
|
||
<dom-module id="settings-default-brave-shields-page"> | ||
<template> | ||
<style include="settings-shared md-select iron-flex"> | ||
</style> | ||
<div class="settings-box"> | ||
<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> | ||
<div class="settings-box"> | ||
<div class="start">$i18n{cookieControlLabel}</div> | ||
<select id="cookieControlType" class="md-select" | ||
on-change="onCookieControlChange_"> | ||
<template is="dom-repeat" items="[[cookieControlTypes_]]"> | ||
<option value="[[item.value]]" | ||
selected="[[controlEqual(item.value, cookieControlType_)]]"> | ||
[[item.name]] | ||
</option> | ||
</template> | ||
</select> | ||
</div> | ||
<div class="settings-box"> | ||
<div class="start">$i18n{fingerprintingControlLabel}</div> | ||
<select id="fingerprintingControlType" class="md-select" | ||
on-change="onFingerprintingControlChange_"> | ||
<template is="dom-repeat" items="[[fingerprintingControlTypes_]]"> | ||
<option value="[[item.value]]" | ||
selected="[[controlEqual(item.value, fingerprintingControlType_)]]"> | ||
[[item.name]] | ||
</option> | ||
</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> |
109 changes: 109 additions & 0 deletions
109
browser/resources/settings/default_brave_shields_page/default_brave_shields_page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* 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/. */ | ||
|
||
(function() { | ||
'use strict'; | ||
|
||
/** | ||
* 'settings-default-brave-shields-page' is the settings page containing brave's | ||
* default shields. | ||
*/ | ||
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, | ||
value: function() { | ||
return [ | ||
{value: '3p', name: loadTimeData.getString('block3rdPartyCookies')}, | ||
{value: 'block', name: loadTimeData.getString('blockAllCookies')}, | ||
{value: 'allow', name: loadTimeData.getString('allowAllCookies')} | ||
] | ||
} | ||
}, | ||
|
||
fingerprintingControlTypes_: { | ||
readOnly: true, | ||
type: Array, | ||
value: function() { | ||
return [ | ||
{value: '3p', name: loadTimeData.getString('block3rdPartyFingerprinting')}, | ||
{value: 'block', name: loadTimeData.getString('blockAllFingerprinting')}, | ||
{value: 'allow', name: loadTimeData.getString('allowAllFingerprinting')} | ||
] | ||
} | ||
}, | ||
|
||
adControlType_: String, | ||
cookieControlType_: String, | ||
fingerprintingControlType_: String, | ||
}, | ||
|
||
/** @private {?settings.DefaultBraveShieldsBrowserProxy} */ | ||
browserProxy_: null, | ||
|
||
/** @override */ | ||
created: function() { | ||
this.browserProxy_ = settings.DefaultBraveShieldsBrowserProxyImpl.getInstance(); | ||
}, | ||
|
||
/** @override */ | ||
ready: function() { | ||
this.onAdControlChange_= this.onAdControlChange_.bind(this) | ||
this.onCookieControlChange_ = this.onCookieControlChange_.bind(this) | ||
this.onFingerprintingControlChange_ = this.onFingerprintingControlChange_.bind(this) | ||
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; | ||
}); | ||
this.browserProxy_.getFingerprintingControlType().then(value => { | ||
this.fingerprintingControlType_ = value; | ||
}); | ||
}, | ||
|
||
/** | ||
* @param {string} value | ||
* @param {string} value | ||
* @return {boolean} | ||
* @private | ||
*/ | ||
controlEqual: function(val1, val2) { | ||
return val1 === val2; | ||
}, | ||
|
||
onAdControlChange_: function() { | ||
this.browserProxy_.setAdControlType(this.$.adControlType.value); | ||
}, | ||
onCookieControlChange_: function() { | ||
this.browserProxy_.setCookieControlType(this.$.cookieControlType.value); | ||
}, | ||
onFingerprintingControlChange_: function() { | ||
this.browserProxy_.setFingerprintingControlType(this.$.fingerprintingControlType.value); | ||
}, | ||
onHTTPSEverywhereControlChange_: function() { | ||
this.browserProxy_.setHTTPSEverywhereControlType(this.$.httpsEverywhereControlType.checked); | ||
}, | ||
onNoScriptControlChange_: function() { | ||
this.browserProxy_.setNoScriptControlType(this.$.noScriptControlType.checked); | ||
}, | ||
}); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.