diff --git a/app/common/lib/braveryPanelUtil.js b/app/common/lib/braveryPanelUtil.js
new file mode 100644
index 00000000000..d0123e43fa5
--- /dev/null
+++ b/app/common/lib/braveryPanelUtil.js
@@ -0,0 +1,34 @@
+/* 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/. */
+
+const Immutable = require('immutable')
+
+// Utils
+const urlParse = require('../urlParse')
+
+const getDisplayHost = (lastCommittedURL) => {
+ const parsedUrl = urlParse(lastCommittedURL)
+ if (parsedUrl.protocol === 'https:' || parsedUrl.protocol === 'http:') {
+ return parsedUrl.host
+ }
+
+ return lastCommittedURL
+}
+
+const getRedirectedResourcesSet = (redirectedResources) => {
+ let result = new Immutable.List()
+ if (redirectedResources) {
+ redirectedResources.forEach((urls) => {
+ if (urls) {
+ result = result.push(urls)
+ }
+ })
+ }
+ return result
+}
+
+module.exports = {
+ getDisplayHost,
+ getRedirectedResourcesSet
+}
diff --git a/app/renderer/components/main/braveryPanel.js b/app/renderer/components/main/braveryPanel.js
index 55cf870b497..246feb24f12 100644
--- a/app/renderer/components/main/braveryPanel.js
+++ b/app/renderer/components/main/braveryPanel.js
@@ -4,9 +4,10 @@
const React = require('react')
const Immutable = require('immutable')
+const {StyleSheet, css} = require('aphrodite/no-important')
// Components
-const ImmutableComponent = require('../immutableComponent')
+const ReduxComponent = require('../reduxComponent')
const Dialog = require('../common/dialog')
const BrowserButton = require('../common/browserButton')
const SwitchControl = require('../common/switchControl')
@@ -15,29 +16,36 @@ const {BraveryPanelDropdown} = require('../common/dropdown')
// Constants
const config = require('../../../../js/constants/config')
const settings = require('../../../../js/constants/settings')
+const appConfig = require('../../../../js/constants/appConfig')
// Actions
const windowActions = require('../../../../js/actions/windowActions')
const appActions = require('../../../../js/actions/appActions')
+// State
+const siteSettingsState = require('../../../common/state/siteSettingsState')
+const siteSettings = require('../../../../js/state/siteSettings')
+const tabState = require('../../../common/state/tabState')
+
// Utils
const urlParse = require('../../../common/urlParse')
const cx = require('../../../../js/lib/classSet')
const siteUtil = require('../../../../js/state/siteUtil')
-const getSetting = require('../../../../js/settings').getSetting
+const {getSetting} = require('../../../../js/settings')
+const frameStateUtil = require('../../../../js/state/frameStateUtil')
+const braveryUtil = require('../../../common/lib/braveryPanelUtil')
-const {StyleSheet, css} = require('aphrodite/no-important')
+// Styles
const globalStyles = require('../styles/global')
const commonStyles = require('../styles/commonStyles')
-
const closeButton = require('../../../../img/toolbar/braveryPanel_btn.svg')
-class BraveryPanel extends ImmutableComponent {
+class BraveryPanel extends React.Component {
constructor () {
super()
this.onToggleSiteSetting = this.onToggleSiteSetting.bind(this)
this.onToggleAdsAndTracking = this.onToggleAdsAndTracking.bind(this)
- this.onToggleHttpseList = this.onToggleHttpseList.bind(this)
+ this.onToggleHttpsList = this.onToggleHttpsList.bind(this)
this.onToggleNoScriptList = this.onToggleNoScriptList.bind(this)
this.onToggleFpList = this.onToggleFpList.bind(this)
this.onToggleAdvanced = this.onToggleAdvanced.bind(this)
@@ -52,134 +60,82 @@ class BraveryPanel extends ImmutableComponent {
this.onEditGlobal = this.onEditGlobal.bind(this)
this.onInfoClick = this.onInfoClick.bind(this)
}
- get isBlockingTrackedContent () {
- return this.blockedByTrackingList && this.blockedByTrackingList.size > 0
- }
- get blockedByTrackingList () {
- return this.props.frameProps.getIn(['trackingProtection', 'blocked'])
- }
- get isAdvancedExpanded () {
- return this.props.braveryPanelDetail.get('advancedControls') !== false
- }
- get blockedAds () {
- return this.props.frameProps.getIn(['adblock', 'blocked'])
- }
- get isBlockingAds () {
- return this.blockedAds && this.blockedAds.size > 0
- }
- get isBlockedAdsShown () {
- return this.props.braveryPanelDetail.get('expandAdblock')
- }
- get blockedScripts () {
- return this.props.frameProps.getIn(['noScript', 'blocked'])
- }
- get isBlockingScripts () {
- return this.blockedScripts && this.blockedScripts.size > 0
- }
- get isBlockedScriptsShown () {
- return this.props.braveryPanelDetail.get('expandNoScript')
- }
- get isBlockingFingerprinting () {
- return this.blockedFingerprinting && this.blockedFingerprinting.size > 0
- }
- get blockedFingerprinting () {
- return this.props.frameProps.getIn(['fingerprintingProtection', 'blocked'])
- }
- get isHttpseShown () {
- return this.props.braveryPanelDetail.get('expandHttpse')
- }
- get isFpShown () {
- return this.props.braveryPanelDetail.get('expandFp')
- }
- get isPrivate () {
- return this.props.frameProps.getIn(['isPrivate'])
- }
- get redirectedResources () {
- return this.props.frameProps.get('httpsEverywhere')
- }
- get redirectedResourcesSet () {
- let result = new Immutable.Set([])
- if (this.redirectedResources) {
- this.redirectedResources.forEach((urls) => {
- if (urls) {
- result = result.union(urls)
- }
- })
- }
- return result
- }
- get isRedirectingResources () {
- return this.redirectedResources && this.redirectedResources.size > 0
- }
+
onToggleAdsAndTracking (e) {
windowActions.setBraveryPanelDetail({
- expandAdblock: !this.isBlockedAdsShown
+ expandAdblock: !this.props.isBlockedAdsShown
})
e.stopPropagation()
}
- onToggleHttpseList (e) {
- if (!this.isHttpseShown && this.redirectedResources &&
- this.redirectedResources.size) {
- // Display full list of rulesets in console for debugging
- console.log('httpse rulesets', JSON.stringify(this.redirectedResources.toJS()))
+
+ onToggleHttpsList (e) {
+ if (!this.props.isHttpsShown && this.props.redirectedResources &&
+ this.props.redirectedResources.size) {
+ // Display full list of rule sets in console for debugging
+ console.log('https rule sets', JSON.stringify(this.props.redirectedResources.toJS()))
}
windowActions.setBraveryPanelDetail({
- expandHttpse: !this.isHttpseShown
+ expandHttpse: !this.props.isHttpsShown
})
e.stopPropagation()
}
+
onToggleFpList (e) {
windowActions.setBraveryPanelDetail({
- expandFp: !this.isFpShown
+ expandFp: !this.props.isFpShown
})
e.stopPropagation()
}
+
onToggleNoScriptList (e) {
windowActions.setBraveryPanelDetail({
- expandNoScript: !this.isBlockedScriptsShown
+ expandNoScript: !this.props.isBlockedScriptsShown
})
e.stopPropagation()
}
+
onToggleAdvanced () {
windowActions.setBraveryPanelDetail({
- advancedControls: !this.isAdvancedExpanded
+ advancedControls: !this.props.isAdvancedExpanded
})
}
+
onReload () {
- appActions.loadURLRequested(this.props.frameProps.get('tabId'), this.props.lastCommittedURL)
+ appActions.loadURLRequested(this.props.tabId, this.props.lastCommittedURL)
}
+
onEditGlobal () {
appActions.createTabRequested({
url: 'about:preferences#shields'
})
}
+
onInfoClick () {
+ this.onHide()
appActions.createTabRequested({
url: config.fingerprintingInfoUrl
})
}
+
+ onHide () {
+ windowActions.setBraveryPanelDetail()
+ }
+
onToggleSiteSetting (setting, e) {
- if (setting !== 'shieldsUp' && !this.props.braverySettings.shieldsUp) {
+ if (setting !== 'shieldsUp' && !this.props.shieldsUp) {
return
}
+
let ruleKey = siteUtil.getOrigin(this.props.lastCommittedURL)
const parsedUrl = urlParse(this.props.lastCommittedURL)
if (setting !== 'noScript' && (parsedUrl.protocol === 'https:' || parsedUrl.protocol === 'http:')) {
ruleKey = `https?://${parsedUrl.host}`
}
- appActions.changeSiteSetting(ruleKey, setting, e.target.value, this.isPrivate)
+ appActions.changeSiteSetting(ruleKey, setting, e.target.value, this.props.isPrivate)
this.onReload()
}
- get displayHost () {
- const parsedUrl = urlParse(this.props.lastCommittedURL)
- if (parsedUrl.protocol === 'https:' || parsedUrl.protocol === 'http:') {
- return parsedUrl.host
- }
- return this.props.lastCommittedURL
- }
get compactBraveryPanelHeader () {
- const shieldsUp = this.props.braverySettings.shieldsUp
return