Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
1. make naming consistent
Browse files Browse the repository at this point in the history
2. move site hacks to load start
  • Loading branch information
darkdh committed Aug 30, 2016
1 parent 66dc10c commit cecb967
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 45 deletions.
3 changes: 2 additions & 1 deletion app/sessionStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ module.exports.cleanAppData = (data, isShutdown) => {
if (typeof expireTime === 'number' && expireTime < now) {
delete data.siteSettings[host].flash
}
delete data.siteSettings[host].allowActiveMixedContent
// Don't write runInsecureContent to session
delete data.siteSettings[host].runInsecureContent
}
if (data.sites) {
const clearHistory = isShutdown && getSetting(settings.SHUTDOWN_CLEAR_HISTORY) === true
Expand Down
4 changes: 2 additions & 2 deletions docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ WindowStore
realm: string
},
isExtendedValidation: boolean, // is using https ev
isMixedContent: boolean, // has active mixed content
blockedMixedContent: string, // source of blocked mixed content
isRunInsecureConent: boolean, // has active mixed content
blockedRunInsecureConent: string, // source of blocked active mixed content
},
parentFrameKey: number, // the key of the frame this frame was opened from
modalPromptDetail: {...},
Expand Down
9 changes: 5 additions & 4 deletions docs/windowActions.md
Original file line number Diff line number Diff line change
Expand Up @@ -753,15 +753,16 @@ Sets the manage autofill credit card popup detail



### setBlockedMixedContent(frameProps, source)
### setBlockedRunInsecureContent(frameProps, source)

Sets which mixed content were blocked on a page.
Sets page url with blocked active mixed content.

**Parameters**

**frameProps**: `Object`, The frame to set blocked mixed content on
**frameProps**: `Object`, The frame to set source of
blocked active mixed content on

**source**: `string`, Source of blocked mixed content
**source**: `string`, Source of blocked active mixed content



Expand Down
11 changes: 6 additions & 5 deletions js/actions/windowActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -972,13 +972,14 @@ const windowActions = {
},

/**
* Sets which mixed content were blocked on a page.
* @param {Object} frameProps - The frame to set blocked mixed content on
* @param {string} source - Source of blocked mixed content
* Sets page url with blocked active mixed content.
* @param {Object} frameProps - The frame to set source of
* blocked active mixed content on
* @param {string} source - Source of blocked active mixed content
*/
setBlockedMixedContent: function (frameProps, source) {
setBlockedRunInsecureContent: function (frameProps, source) {
dispatch({
actionType: WindowConstants.WINDOW_SET_BLOCKED_MIXED_CONTENT,
actionType: WindowConstants.WINDOW_SET_BLOCKED_RUN_INSECURE_CONTENT,
frameProps,
source
})
Expand Down
23 changes: 10 additions & 13 deletions js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ class Frame extends ImmutableComponent {
return !this.webview || !!this.webview.allowRunningPlugins !== this.allowRunningPlugins()
}

allowActiveMixedContent () {
runInsecureContent () {
const activeSiteSettings = getSiteSettingsForHostPattern(this.props.allSiteSettings, this.origin)
return activeSiteSettings === undefined
? false : activeSiteSettings.get('allowActiveMixedContent')
? false : activeSiteSettings.get('runInsecureContent')
}

allowRunningPlugins (url) {
Expand Down Expand Up @@ -571,13 +571,7 @@ class Frame extends ImmutableComponent {
}
})
this.webview.addEventListener('did-block-run-insecure-content', (e) => {
const hack = siteHacks[urlParse(this.props.location).hostname]
if (hack && hack.allowRunningInsecureContent) {
appActions.changeSiteSetting(this.origin, 'allowActiveMixedContent', true)
this.webview.reload()
} else {
windowActions.setBlockedMixedContent(this.frame, this.props.location)
}
windowActions.setBlockedRunInsecureContent(this.frame, this.props.location)
})
this.webview.addEventListener('context-menu', (e) => {
contextMenus.onMainContextMenu(e.params, this.frame)
Expand Down Expand Up @@ -753,12 +747,12 @@ class Frame extends ImmutableComponent {
interceptFlash(true, e.url)
}
windowActions.onWebviewLoadStart(this.frame, e.url)
windowActions.setBlockedMixedContent(this.frame)
const isSecure = parsedUrl.protocol === 'https:' && !this.allowActiveMixedContent()
const isMixedContent = parsedUrl.protocol === 'https:' && this.allowActiveMixedContent()
windowActions.setBlockedRunInsecureContent(this.frame)
const isSecure = parsedUrl.protocol === 'https:' && !this.runInsecureContent()
const isRunInsecureContent = parsedUrl.protocol === 'https:' && this.runInsecureContent()
windowActions.setSecurityState(this.frame, {
secure: isSecure,
mixedContent: isMixedContent
runInsecureContent: isRunInsecureContent
})
if (isSecure) {
// Check that there isn't a cert error.
Expand All @@ -776,6 +770,9 @@ class Frame extends ImmutableComponent {
if (this.doNotTrack) {
this.webview.executeJavaScript('Navigator.prototype.__defineGetter__("doNotTrack", () => {return 1});')
}
if (hack && hack.allowRunningInsecureContent) {
appActions.changeSiteSetting(this.origin, 'runInsecureContent', true)
}
}
const loadEnd = (savePage) => {
windowActions.onWebviewLoadEnd(
Expand Down
18 changes: 9 additions & 9 deletions js/components/siteInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class SiteInfo extends ImmutableComponent {
this.onAllowMixedContent = this.onAllowMixedContent.bind(this)
}
onAllowMixedContent () {
appActions.changeSiteSetting(siteUtil.getOrigin(this.isMixedContentBlocked), 'allowActiveMixedContent', true)
ipc.emit(messages.SHORTCUT_ACTIVE_FRAME_LOAD_URL, {}, this.isMixedContentBlocked)
appActions.changeSiteSetting(siteUtil.getOrigin(this.isBlockedRunInsecureContent), 'runInsecureContent', true)
ipc.emit(messages.SHORTCUT_ACTIVE_FRAME_LOAD_URL, {}, this.isBlockedRunInsecureContent)
this.props.onHide()
}
get isExtendedValidation () {
Expand All @@ -28,25 +28,25 @@ class SiteInfo extends ImmutableComponent {
get isSecure () {
return this.props.frameProps.getIn(['security', 'isSecure'])
}
get isMixedContent () {
return this.props.frameProps.getIn(['security', 'isMixedContent'])
get isRunInsecureContent () {
return this.props.frameProps.getIn(['security', 'isRunInsecureContent'])
}
get isMixedContentBlocked () {
return this.props.frameProps.getIn(['security', 'blockedMixedContent'])
get isBlockedRunInsecureContent () {
return this.props.frameProps.getIn(['security', 'blockedRunInsecureContent'])
}
get partitionNumber () {
return this.props.frameProps.getIn(['partitionNumber'])
}
render () {
let secureIcon
if (this.isSecure && !this.isMixedContent) {
if (this.isSecure && !this.isRunInsecureContent) {
secureIcon = <li><span
className={cx({
fa: true,
'fa-lock': true,
extendedValidation: this.isExtendedValidation
})} /><span data-l10n-id='secureConnection' /></li>
} else if (this.isMixedContent) {
} else if (this.isRunInsecureContent) {
secureIcon = <li><span className='fa fa-unlock' /><span data-l10n-id='mixedConnection' /></li>
} else {
secureIcon = <li><span className='fa fa-unlock' /><span data-l10n-id='insecureConnection' data-l10n-args={JSON.stringify(l10nArgs)} /></li>
Expand All @@ -64,7 +64,7 @@ class SiteInfo extends ImmutableComponent {
}

let allowMixedContentButton
if (this.isMixedContentBlocked) {
if (this.isBlockedRunInsecureContent) {
allowMixedContentButton =
<Button l10nId='allowMixedContent' className='primaryButton' onClick={this.onAllowMixedContent} />
}
Expand Down
3 changes: 1 addition & 2 deletions js/constants/windowConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ const windowConstants = {
WINDOW_SET_CLEAR_BROWSING_DATA_DETAIL: _,
WINDOW_SET_AUTOFILL_ADDRESS_DETAIL: _,
WINDOW_SET_AUTOFILL_CREDIT_CARD_DETAIL: _,
WINDOW_SET_BLOCKED_MIXED_CONTENT: _,
WINDOW_SET_ALLOW_MIXED_CONTENT: _
WINDOW_SET_BLOCKED_RUN_INSECURE_CONTENT: _
}

module.exports = mapValuesByKeys(windowConstants)
4 changes: 2 additions & 2 deletions js/state/contentSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ const getContentSettingsFromSiteSettings = (appState) => {
addContentSettings(contentSettings.javascript, hostPattern, '*',
hostSetting.noScript ? 'block' : 'allow')
}
if (typeof hostSetting.allowActiveMixedContent === 'boolean') {
if (typeof hostSetting.runInsecureContent === 'boolean') {
addContentSettings(contentSettings.runInsecureContent, hostPattern, '*',
hostSetting.allowActiveMixedContent ? 'allow' : 'block')
hostSetting.runInsecureContent ? 'allow' : 'block')
}
if (hostSetting.cookieControl) {
if (hostSetting.cookieControl === 'block3rdPartyCookie') {
Expand Down
14 changes: 7 additions & 7 deletions js/stores/windowStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -742,9 +742,9 @@ const doAction = (action) => {
windowState = windowState.setIn(path.concat(['security', 'isSecure']),
action.securityState.secure)
}
if (action.securityState.mixedContent !== undefined) {
windowState = windowState.setIn(path.concat(['security', 'isMixedContent']),
action.securityState.mixedContent)
if (action.securityState.runInsecureContent !== undefined) {
windowState = windowState.setIn(path.concat(['security', 'isRunInsecureContent']),
action.securityState.runInsecureContent)
}
if (action.securityState.certDetails) {
windowState = windowState.setIn(path.concat(['security', 'certDetails']),
Expand All @@ -767,15 +767,15 @@ const doAction = (action) => {
history: addToHistory(action.frameProps)
})
break
case WindowConstants.WINDOW_SET_BLOCKED_MIXED_CONTENT:
const blockedMixedContentPath =
case WindowConstants.WINDOW_SET_BLOCKED_RUN_INSECURE_CONTENT:
const blockedRunInsecureContentPath =
['frames', FrameStateUtil.getFramePropsIndex(windowState.get('frames'), action.frameProps)]
if (action.source) {
windowState =
windowState.setIn(blockedMixedContentPath.concat(['security', 'blockedMixedContent']), action.source)
windowState.setIn(blockedRunInsecureContentPath.concat(['security', 'blockedRunInsecureContent']), action.source)
} else {
windowState =
windowState.deleteIn(blockedMixedContentPath.concat(['security', 'blockedMixedContent']))
windowState.deleteIn(blockedRunInsecureContentPath.concat(['security', 'blockedRunInsecureContent']))
}
break
default:
Expand Down

0 comments on commit cecb967

Please sign in to comment.